Summary
In this chapter, you worked on ROS 2 actions. You created various actions to solve a problem that services don’t handle well: when the server may take some time to execute the request.
With actions, you can properly handle this case. While the goal is being executed, you can get some feedback from the server, or even decide to cancel the goal. Also, you could handle several goals at the same time, queue them, replace one with another one, and so on (we haven’t seen this in this chapter as it’s something you can look into if you want to develop your skills further).
You can implement action servers and clients in your code using the rclpy.action
library for Python and the rclcpp_action
library for C++.
Here are the main steps for writing an action server:
- Since we’re on the server side, we must choose the action name and interface. Usually, for an action, you will have to create a custom interface (in a dedicated package).
- Then...