Implementing a ROS 2 action in C++
In this section, we will implement an action server and action client in ROS 2 C++ APIs. The custom action type we will create is master_ros2_interface/action/MyCustomAction.action
, and the action name is "my_custom_action"
. The action client will send a value as the goal value, and the action server will count from 0 to that value with a 1-second delay. The action server will also send the client feedback on the current count. If the count is complete, it will send the final count.
You can find the action server and action client in Chapter03
| master_ros2_pkg
| src
| action_server.cpp
and action_client.cpp
.
Creating a custom action interface for the ROS 2 action and server
Let’s create a custom action type inside the master_ros2_interface/action folder. The name of the action file is MyCustomAction.action
. The .action
file is used to define an action type in ROS 2. Here is the definition of the MyCustomAction.action...