Two sets of tutorials have been created for the actionlib package in addition to the tutorials listed below. You can browse these tutorials by roscd-ing to the actionlib_tutorials or turtle_actionlib package, i.e.
roscd actionlib_tutorials roscd turtle_actionlib
Workspace Setup
If you have not yet created a workspace in which to complete the tutorials, click here for some brief instructions .
Show EOL distros:
Create a file named ~/tutorials.rosinstall with the following content:
- other: { local-name: workspace }
To overlay on the ROS distro you are using:
rosinstall ~/tutorials /opt/ros/$ROS_DISTRO>> ~/tutorials.rosinstall
To use this workspace whenever you open a new terminal setup your ROS environment by typing:
source ~/tutorials/setup.bash
Sourcing this file adds ~/tutorials/workspace to your ROS_PACKAGE_PATH.
Any packages you create in that directory will be found by rospack.
An alternative to source your script file is to add it to your .bashrc, but remember that this will persist in your .bashrc into the future, and you can only have one environment setup. For more on what this is doing see this page
Create a catkin workspace like so:
$ source /opt/ros/$ROS_DISTRO/setup.bash $ mkdir -p ~/tutorial_ws/src $ cd ~/tutorial_ws $ catkin_init_workspace src $ catkin_make
And now source the setup file from the result-space, so that packages you add to this workspace's src folder will be findable by rospack, and the built binaries by rosrun and roslaunch:
$ source devel/setup.bash
Before starting any of the actionlib tutorials take the time to create a scratch package to work in and manipulate the example code. Create a sandbox package with the following dependencies:
$ cd %YOUR_CATKIN_WORKSPACE%/src $ catkin_create_pkg actionlib_tutorials actionlib message_generation roscpp rospy std_msgs actionlib_msgs
(If you're not familliar with creating catkin packages, see Creating_a_catkin_Package tutorial (in that page, don't forget to choose catkin as build system).
$ roscd tutorials $ roscreate-pkg learning_actionlib actionlib roscpp rospy roslib std_msgs actionlib_msgs
Make sure that the learning_actionlib directory is included in your ROS_PACKAGE_PATH. Uncomment rosbuild_genmsg() in the learning_actionlib/CMakeLists.txt and build it:
$ rosmake learning_actionlib
(Note: These tutorials require common-0.5.0 or greater)
Beginner Tutorials
In C++
- Writing a Simple Action Server using the Execute Callback
This tutorial covers using the simple_action_server library to create a Fibonacci action server. This example action server generates a Fibonacci sequence, the goal is the order of the sequence, the feedback is the sequence as it is computed, and the result is the final sequence.
- Writing a Simple Action Client
This tutorial covers using the simple_action_client library to create a Fibonacci action client. This example program creates an action client and sends a goal to the action server.
In Python
- Writing a Simple Action Server using the Execute Callback (Python)
This tutorial covers using the simple_action_server library to create a Fibonacci action server in Python. This example action server generates a Fibonacci sequence, the goal is the order of the sequence, the feedback is the sequence as it is computed, and the result is the final sequence.
- Writing a Simple Action Client (Python)
This tutorial covers using the action_client library to create a Fibonacci simple action client in Python.
Execution
- Running an Action Client and Server
This tutorial covers running the Fibonacci server and client then visualizing the channel output and node graph.
- Send a Goal to Action Server without Action Client
This tutorial shows ways of send a Goal to an Action Server without the need of create an Action Client.
Intermediate Tutorials
- Writing a Simple Action Server using the Goal Callback Method
This tutorial covers using the simple_action_server library to create an averaging action server. This example shows how to use an action to process or react to incoming data from ros nodes. The action server averages data from a ros node, the goal is the number of samples to average, the feedback is the sample number, the sample data, the current average, and current standard deviation, and the result is the average and standard deviation of the requested number of samples.
- Writing a Threaded Simple Action Client
This tutorial covers using the simple_action_client library to create a averaging action client. This example program spins a thread, creates an action client, and sends a goal to the action server.
- Running an Action Server and Client with Other Nodes
This tutorial covers running the averaging action server and client with another data node then visualizing the channel output and node graph.
Advanced Tutorials
- Writing a Callback Based SimpleActionClient
Example of using callbacks for program flow that's more complicated than a simple, linear script.