[ROS Q&A] 131 – Compilation error in ROS Action Server


Written by Alberto Ezquerro



In this video we are going to see why a user gets a compilation error when trying to compile his ROS Action Server node.

This is a video trying to answer the following question posted at the ROS answers forum: https://answers.ros.org/question/294052/compilation-error-in-ros-action-server-code/

Step 1. Create a project in ROS Development Studio(ROSDS)

ROSDS helps you follow our tutorial in a fast pace without dealing without setting up an environment locally. If you haven’t had an account yet, you can create a free account here. Let’s create a new project and call it testing_action.

Step 2. Create package

At first, let’s create the package with dependencies

cd ~/catkin_ws/src
catkin_create_pkg test_action roscpp actionlib actionlib_msgs robot_calibration_msgs

Then we create a file called action_code.cpp under test_action/src folder with the following content from the question

#include <ros/ros.h>
#include <actionlib/server/simple_action_server.h>
#include <robot_calibration_msgs/GripperLedCommandAction.h>

typedef actionlib::SimpleActionServer<robot_calibration_msgs::GripperLedCommandAction> led_actn_srvr_t;

class led_action

ros::NodeHandle nh;
led_actn_srvr_t ls;
std::string action_name;

led_action(std::string name):
    ls(nh, name, boost::bind(&led_action::execute_cb, this, _1), false),
void execute_cb(const robot_calibration_msgs::GripperLedCommandActionConstPtr &action)

int main(int argc, char** argv)
    return 0;

To compile the code, we have to add the following code into BUILD part of the CMakeLists.txt file

add_executable(action_code src_action_code.cpp)
add_dependencies(action_code ${action_code_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

If we try to compile the code with the following command

cd ~/catkin_ws

We got some error.

Step 3. Solve the problem

It turns out the actionlib generates topics for us in the following format


But inside the code, we have to directly use


So we only have to change one line in the source file to make it work

void execute_cb(const robot_calibration_msgs::GripperLedCommandGoalConstPtr &action)

Then it compiles successfully!



Edit by: Tony Huang


▸ Original question: https://answers.ros.org/question/294052/compilation-error-in-ros-action-server-code/
Robot Ignite Academy
ROS Basics in 5 days (C++)
ROS Development Studio (RDS)


Did you like this video? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.

Topics: ROS Action

Discover How to Equip Your Teams with ROS Skills Fast

The Construct For Enterprise

Check Out These Related Posts

5 Mistakes Robotics & ROS Teachers Make

5 Mistakes Robotics & ROS Teachers Make

Last week, a colleague of mine asked me for advice on how to teach ROS at university because she is going to start delivering a ROS class next month. Then I decided to record this video with 5 mistakes I have made in the past while teaching ROS at the university. I hope that this video is useful for you and helps you avoid the mistakes that I made so you can start delivering ROS classes smoothly.

read more


Share This