ROS Action
Different from ROS service which consists of request and response only, ROS action additionally provides feedback. An action consists off three main parts: request, feedback, and result (which is similar to response in service). While a service is appropriate to be used for a non-progressive task, an action is appropriate to be used for a progressive (long running) task, i.e. a task that needs some progress to achieve the goal. While a service has two parts in its .srv file, an action has three parts in its .action file: 1) goal, 2) result, and 3) feedback. In a dish-washing task, the .action file will look like this:
1 2 3 4 5 6 7 8 |
# Define the goal uint32 dishwasher_id # Specify which dishwasher we want to use --- # Define the result uint32 total_dishes_cleaned --- # Define a feedback message float32 percent_complete |
Similar to service, an action also consists of an action server and an action client. The difference is in the communication mechanism between the server and the client. The mechanism in an action is the following:
- The action client send a goal (request) to the action server.
- The action server is performing the task requested. However, since the task is progressive, the action server gives feedback to the client on the progress of the task. The action server also sends the current status of the goaal.
- The action client can cancel the task if it wants.
- If the task is not cancelled and the task is complete, the action server sends the result to the action client.
The communication between the action client and server keeps running like topic communication until the action server completes the goal and send the result to the client, or the action client cancels its request. Therefore, an action can be seen as multiple topics:
- goal – Used to send new goals to servers.
- cancel – Used to send cancel requests to servers.
- status – Used to notify clients on the current state of every goal in the system.
- feedback – Used to send clients periodic auxiliary information for a goal.
- result – Used to send clients one-time auxiliary information upon completion of a goal.