작성자: 박준규
최초작성 2023.01.25(수) 수정 2023.01.27(금)
Turtlesim에서 아래 조건을 만족하면서 입력 명령을 받아 거북이를 등속원운동하게하는 ROS2 패키지를 설계해보자:
Our custom node should:
Should include radius
, velocity
, and direction
We could name the message as TurtlesimUcmMsg
(Turtlesim Uniform Circular Motion Message)
<aside>
💡 .msg
files should be named in camel case. Snake case will give you an error.
</aside>
We could name the topic as turtlesim_ucm
cmd_vel
topic type
cmd_vel
topic type is geometry_msgs/Twist
linear.x
in cmd_vel
= velocity
from TurtlesimUcmMsg
angular.z
in cmd_vel
= velocity
/radius
from TurtlesimUcmMsg
turtlesim_node
node using cmd_vel
topic.<aside>
⚠️ Since calling rosidl_generate_interfaces
and ament_python_install_package
in the same CMake project does not work, we need to create a package for the message, and another package for the processing of data.
See this Github issue for more info. It is best practice to instead separate out the message generation into a separate package.
https://github.com/osrf/buoy_msgs/pull/20
https://github.com/ros2/ros2_documentation/pull/2882
https://github.com/ros2/rosidl_python/issues/141
</aside>
Let’s first make a new package called ts_circle_msg
(turtlesim_circle_message):
cd ~/ros2_workspace/src
#since custom messages and services can only be made in a C++ package:
ros2 pkg create --build-type ament_cmake ts_circle_msg