turtlesim 배경 색 바꾸기
kw-cobot@kwcobot-HGDT-Series:~$ rosparam list
/rosapi/params_glob
/rosapi/services_glob
/rosapi/topics_glob
/rosbridge_websocket/actual_port
/rosbridge_websocket/address
/rosbridge_websocket/authenticate
/rosbridge_websocket/bson_only_mode
/rosbridge_websocket/delay_between_messages
/rosbridge_websocket/fragment_timeout
/rosbridge_websocket/max_message_size
/rosbridge_websocket/params_glob
/rosbridge_websocket/port
/rosbridge_websocket/retry_startup_delay
/rosbridge_websocket/services_glob
/rosbridge_websocket/topics_glob
/rosbridge_websocket/unregister_timeout
/rosbridge_websocket/use_compression
/rosbridge_websocket/websocket_external_port
/rosbridge_websocket/websocket_ping_interval
/rosbridge_websocket/websocket_ping_timeout
/rosdistro
/roslaunch/uris/host_kwcobot_hgdt_series__43503
/rosversion
/run_id
/turtlesim/background_b
/turtlesim/background_g
/turtlesim/background_r
kw-cobot@kwcobot-HGDT-Series:~$ rosparam get /turtlesim/background_r 255
kw-cobot@kwcobot-HGDT-Series:~$ rosparam get /turtlesim/background_r
255
kw-cobot@kwcobot-HGDT-Series:~$ rosparam set /turtlesim/background_b 50
kw-cobot@kwcobot-HGDT-Series:~$ rosparam get /turtlesim/background_b
50
kw-cobot@kwcobot-HGDT-Series:~$ rosservice call /reset
parameter server에 등록하거나 값을 받아올 수 있다.
대신 launch 파일 값을 바꿀 수 있다.
뒤로 갈수록 launch파일을 수정해서 테스트하는 작업을 많이 할 것임.
터미널에서 how 런치파일에 접근할 지 배워보자.
kw-cobot@kwcobot-HGDT-Series:~$ roslaunch scout_sim_launch simulater.launch
아래를 보면
SUMMARY
========
PARAMETERS
* /rosapi/params_glob: [*]
* /rosapi/services_glob: [*]
* /rosapi/topics_glob: [*]
* /rosbridge_websocket/address: 0.0.0.0
* /rosbridge_websocket/authenticate: False
* /rosbridge_websocket/bson_only_mode: False
* /rosbridge_websocket/delay_between_messages: 0
* /rosbridge_websocket/fragment_timeout: 600
* /rosbridge_websocket/max_message_size: None
* /rosbridge_websocket/params_glob: [*]
* /rosbridge_websocket/port: 9090
* /rosbridge_websocket/retry_startup_delay: 5
* /rosbridge_websocket/services_glob: [*]
* /rosbridge_websocket/topics_glob: [*]
* /rosbridge_websocket/unregister_timeout: 10
* /rosbridge_websocket/use_compression: False
* /rosbridge_websocket/websocket_external_port: None
* /rosbridge_websocket/websocket_ping_interval: 0
* /rosbridge_websocket/websocket_ping_timeout: 30
* /rosdistro: melodic
* /rosversion: 1.14.12
파라미터를 보여주고
노드를 쭉 보여준다.
NODES
/
base_link_to_camera (tf/static_transform_publisher)
base_link_to_imu (tf/static_transform_publisher)
base_link_to_laser (tf/static_transform_publisher)
rosapi (rosapi/rosapi_node)
rosbridge_websocket (rosbridge_server/rosbridge_websocket)
그 아래는 프로세스 진행 상태를 보여준다.
kw-cobot@kwcobot-HGDT-Series:~$ rosparam list
/rosapi/params_glob
/rosapi/services_glob
/rosapi/topics_glob
/rosbridge_websocket/actual_port
/rosbridge_websocket/address
/rosbridge_websocket/authenticate
/rosbridge_websocket/bson_only_mode
/rosbridge_websocket/delay_between_messages
/rosbridge_websocket/fragment_timeout
/rosbridge_websocket/max_message_size
/rosbridge_websocket/params_glob
/rosbridge_websocket/port
/rosbridge_websocket/retry_startup_delay
/rosbridge_websocket/services_glob
/rosbridge_websocket/topics_glob
/rosbridge_websocket/unregister_timeout
/rosbridge_websocket/use_compression
/rosbridge_websocket/websocket_external_port
/rosbridge_websocket/websocket_ping_interval
/rosbridge_websocket/websocket_ping_timeout
/rosdistro
/roslaunch/uris/host_kwcobot_hgdt_series__41299
/roslaunch/uris/host_kwcobot_hgdt_series__43503
/rosversion
/run_id
/turtlesim/background_b
/turtlesim/background_g
/turtlesim/background_r
를 직접 수정하는 방법을 배워보자
<launch>
<!-- rosrun turtlesim turtlesim_node-->
<node name="a" pkg="turtlesim" type="turtlesim_node"/>
<node name="b" pkg="turtlesim" type="turtlesim_node"/>
<!--rosrun scout_sim_launch twist_pub.py-->
<!--<node />-->
</launch>
kw-cobot@kwcobot-HGDT-Series:~$ roslaunch scout_sim_launch turtlesim.launch
... logging to /home/kw-cobot/.ros/log/7e99fd8c-9aca-11ec-955f-04d4c4919854/roslaunch-kwcobot-HGDT-Series-4882.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
WARNING: disk usage in log directory [/home/kw-cobot/.ros/log] is over 1GB.
It's recommended that you use the 'rosclean' command.
started roslaunch server http://kwcobot-HGDT-Series:34315/
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.12
NODES
/
a (turtlesim/turtlesim_node)
b (turtlesim/turtlesim_node)
ROS_MASTER_URI=http://localhost:11311
process[a-1]: started with pid [4897]
process[b-2]: started with pid [4898]
[ INFO] [1646295910.266705958]: Starting turtlesim with node name /b
[ INFO] [1646295910.269779841]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]
<launch>
<!-- rosrun turtlesim turtlesim_node-->
<node name="a" pkg="turtlesim" type="turtlesim_node" output="log"/>
<node name="b" pkg="turtlesim" type="turtlesim_node" output="screen"/>
<!--rosrun scout_sim_launch twist_pub.py-->
<!--<node />-->
</launch>
터미널에 출력되는 것이 screen
log 형태로 출력됨
log 로 출력되는 값은 rqt_console로 볼 수 있다.
<launch>
<!-- rosrun turtlesim turtlesim_node-->
<node name="turtlesim" pkg="turtlesim" type="turtlesim_node" output="log"/>
<!--rosrun scout_sim_launch twist_pub.py-->
<node name="mover" pkg="scout_sim_launch" type="twist_pub.py" />
</launch>
<launch>
<!-- rosrun turtlesim turtlesim_node-->
<node name="turtlesim" pkg="turtlesim" type="turtlesim_node" output="log"/>
<!--rosrun scout_sim_launch twist_pub.py-->
<node ns="turtle1" name="mover" pkg="scout_sim_launch" type="twist_pub.py" />
</launch>
통째로 모두 바꿔야 할 때는 namespace(ns) 값을 바꾸는 것이 맞지만
개별적으로 바꾸고 싶으면 remap을 걸어줘야 한다.
remap: 특정 문자열을 다른 문자열로 바꿔준다.
노드 안에다 쓰는 방법으로 쓰자.
<launch>
<!-- rosrun turtlesim turtlesim_node-->
<node name="turtlesim" pkg="turtlesim" type="turtlesim_node" output="log"/>
<!--rosrun scout_sim_launch twist_pub.py-->
<node ns="turtle1" name="mover" pkg="scout_sim_launch" type="twist_pub.py" >
<remap from="cmd_vel" to="turtle1/cmd_vel" />
</node>
</launch>
rqt_graph를 보면 remap은 특정 값만 바뀌었음을 알 수 있다.
터미널로 py 파일 변경할 때
물결을 꼭 넣어줘야 한다.
def timer_CB(self, event):
publishing_data = Twist()
publishing_data.linear.x = rospy.get_param("~linear_speed", 1.0) # nodename/linear_speed
publishing_data.linear.y = 0.0
publishing_data.linear.z = 0.0
publishing_data.angular.x = 0
publishing_data.angular.y = 0
publishing_data.angular.z = rospy.get_param("~angular_speed", 1.0) # ~ 표시 없을 시에는 angular_speed
kw-cobot@kwcobot-HGDT-Series:~$ rosparam set /mov/linear_speed 2.0
kw-cobot@kwcobot-HGDT-Series:~$ rosparam set /mover/angular_speed 2.0
이런 식으로 터미널로 바꿀 수 있다.
오픈된 소스 파일을 쓸 때 hector_slam 안에 launch 파일 안 파라미터 서버로 바꿀 수 있다.
launch 파일에 있는 parameter를 터미널로 수정할 수 있는 방법
'Robot > ROS' 카테고리의 다른 글
킴 [시뮬레이터 환경설정] (0) | 2022.03.04 |
---|---|
민 [ROS1] PID (0) | 2022.03.04 |
민 [simulator] Lidar Clustering Algorithm (0) | 2022.03.03 |
[simulator] publisher (0) | 2022.03.03 |
[simulator] 범용적인 publisher 코드 짜기 (0) | 2022.03.02 |