이번 시간에는 topic이 무엇인지와 topic의 주체가 되는 publisher, subscriber에 대해 배워봅니다.

Moving Robot


$ rosfoxy
$ cbp py_topic_pkg

# Windows
> colcon build --symlink-install --packages-select py_topic_pkg
> install\\setup.bat

Starting >>> py_topic_pkg
Finished <<< py_topic_pkg [0.84s]          

Summary: 1 package finished [0.96s]

# Terminal 1
$ ros2 launch gcamp_gazebo gcamp_world.launch.py

# Terminal 2
$ ros2 run py_topic_pkg cmd_vel_pub_node 
[INFO] [1624889609.708600174] [cmd_vel_pub_node]: DriveForward node Started, move forward during 5 seconds 

[INFO] [1624889610.195565654] [cmd_vel_pub_node]: 1 seconds passed
[INFO] [1624889610.695526857] [cmd_vel_pub_node]: 1 seconds passed
[INFO] [1624889611.195481779] [cmd_vel_pub_node]: 2 seconds passed
[INFO] [1624889611.695450639] [cmd_vel_pub_node]: 2 seconds passed
[INFO] [1624889612.195593873] [cmd_vel_pub_node]: 3 seconds passed
[INFO] [1624889612.695474598] [cmd_vel_pub_node]: 3 seconds passed
[INFO] [1624889613.196404202] [cmd_vel_pub_node]: 4 seconds passed
[INFO] [1624889613.695493502] [cmd_vel_pub_node]: 4 seconds passed
[INFO] [1624889614.195716743] [cmd_vel_pub_node]: 5 seconds passed
[INFO] [1624889614.196065373] [cmd_vel_pub_node]: 
==== Stop Publishing ====

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/fa8261eb-007e-4c65-8326-5006644ccd1d/Untitled.png

gazebo 상의 로봇이 5초간 회전한 후 멈출 것입니다!! 이때, 내부적으로 어떤 작업이 이루어졌는지 rqt_graph로 살펴봅시다.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4765cc1f-508e-419a-a328-d0ff745ce8b0/Untitled.png

ROS2 Topic