1.4.3 ROS Actions code illustration: Part 1
Course subject(s)
Module 1. ROS Essentials
In this lecture, you will learn how to make your own action file. Furthermore, you will learn how to look into the message definition of an action file.
Creating an action file
Let’s first create our action folder and our new action file.
$ mkdir action
$ cd action
$ vim CounterWithDelay.action
We first define the goal message as the number of counts to count up to. Then a result message which is a string message for the result and a feedback message to indicate the numbers of counts elapsed.
Now we update the CMakeLists.txt
file with the vim editor in the action files subsection. (#L25
)
CounterWithDelay.action
(#L27
)
We need to add the actionlib package that provides all the ROS action functionalities. We need to add it at all dependancy locations. (#L4,37,45
)
actionlib actionlib_mgs
Update the package.xml file also with the dependency. (#L21
)
Now run catkin build
or in short catkin b.
Action message
Don’t forget to source your ROS workspace first!
$ source $HOME/hrwros_ws/devel/setup.bash
If we type the complete action name $ rosmsg show_hwros_msgs/CounterWithDelay
you will see the complete message definition.
We need to pay attention to where our message definitions are located as a lot of the message is for the actionlib package.
If you want to see the message definition, you can go to the hrwros_msgs package folder.
$
roscd hrwros_msgs
A
nd run the following script.
$ rosrun actionlib_msgs genaction.py -o msg action/CounterWithDelay.action
There we find all the action definitions.
$ rosmsg show hrwros_msgs/
Hello (Real) World with ROS - Robot Operating System by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://online-learning.tudelft.nl/courses/hello-real-world-with-ros-robot-operating-systems//.