본문 바로가기
기계공학부 시절의 기록/ROS2 Study

ROS2 course week4. homework

by juhyeonglee 2021. 10. 6.
728x90
반응형

1. run turtlesim

$ ros2 run turtlesim turtlesim_node

$ ros2 run turtlesim turtle_teleop_key

$ rqt_graph

 

* executable name is not same with real node name

 

 

 

2. node

a single purpose, reusable

 

 

$ ros2 run <package_name> <executable_name>

 

$ ros2 pkg list

and find executable nodes in a package

$ ros2 pkg excutables <package_name>

 

3. run the same node with different name

$ ros2 run turtlesim turtlesim_node --ros-args --remap __node:=turtle2

or

$ ros2 run turtlesim turtlesim_node __node:=new_turtle

 

 

4. node information

$ ros2 node info <node_name>

$ ros2 node info /turtle2

 

 

 

 

5. Topic

$ ros2 topic list

$ ros2 topic list -t

$ ros2 topic info /turtle1/cmd_vel

topic echo

$ ros2 topic echo /turtle1/cmd_vel

topic bw

$ ros2 topic bw /turtle1/cmd_vel

topic hz

$ ros2 topic hz /turtle1/cmd_vel

 

 

 

 

 

6. publish

it is usual that publish code in a source code

but now we'll try by terminal

$ ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

 

$ ros2 topic pub --rate 1 /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

 

 

 

7. topic record

$ ros2 bag record /turtle1/cmd_vel

$ ros2 bag info rosbag2_2021_10_06-14_55_49/

$ ros2 bag play rosbag2_2021_10_06-14_55_49/

 

8. service

 

$ ros2 run turtlesim turtlesim_node

$ ros2 service list

$ ros2 service list -t

728x90
반응형

댓글