ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

undefined reference to actionlib::GoalIDGenerator::GoalIDGenerator()

asked 2017-01-31 10:19:46 -0500

Beaucay gravatar image

updated 2017-01-31 10:21:12 -0500

I tried adapting the Actionlib Client-Tutorial to a action I already used in some python scripts but as soon as I insert

add_executable(urdf_optimizer_beta src/urdf_optimizer_beta.cpp)
target_link_libraries(urdf_optimizer_beta ${catkin_LIBRARIES})
add_dependencies(urdf_optimizer_beta pilatus_EXPORTED_TARGETS)

into the CMakeLists.txt i get the following error when trying to catkin_make

CMakeFiles/urdf_optimizer_beta.dir/src/urdf_optimizer_beta.cpp.o: In function `actionlib::GoalManager<pilatus::DrivePosesAction_<std::allocator<void> > >::GoalManager(boost::shared_ptr<actionlib::DestructionGuard> const&)':
/opt/ros/indigo/include/actionlib/client/client_helpers.h:80: undefined reference to `actionlib::GoalIDGenerator::GoalIDGenerator()'
CMakeFiles/urdf_optimizer_beta.dir/src/urdf_optimizer_beta.cpp.o: In function `actionlib::ActionClient<pilatus::DrivePosesAction_<std::allocator<void> > >::initClient(ros::CallbackQueueInterface*)':
/opt/ros/indigo/include/actionlib/client/action_client.h:214: undefined reference to `actionlib::ConnectionMonitor::ConnectionMonitor(ros::Subscriber&, ros::Subscriber&)'
/opt/ros/indigo/include/actionlib/client/action_client.h:217: undefined reference to `actionlib::ConnectionMonitor::goalDisconnectCallback(ros::SingleSubscriberPublisher const&)'
/opt/ros/indigo/include/actionlib/client/action_client.h:217: undefined reference to `actionlib::ConnectionMonitor::goalConnectCallback(ros::SingleSubscriberPublisher const&)'
/opt/ros/indigo/include/actionlib/client/action_client.h:221: undefined reference to `actionlib::ConnectionMonitor::cancelDisconnectCallback(ros::SingleSubscriberPublisher const&)'
/opt/ros/indigo/include/actionlib/client/action_client.h:221: undefined reference to `actionlib::ConnectionMonitor::cancelConnectCallback(ros::SingleSubscriberPublisher const&)'
CMakeFiles/urdf_optimizer_beta.dir/src/urdf_optimizer_beta.cpp.o: In function `actionlib::ActionClient<pilatus::DrivePosesAction_<std::allocator<void> > >::statusCb(ros::MessageEvent<actionlib_msgs::GoalStatusArray_<std::allocator<void> > const> const&)':
/opt/ros/indigo/include/actionlib/client/action_client.h:266: undefined reference to `actionlib::ConnectionMonitor::processStatus(boost::shared_ptr<actionlib_msgs::GoalStatusArray_<std::allocator<void> > const> const&, std::string const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [devel/lib/pilatus/urdf_optimizer_beta] Error 1
make[1]: *** [CMakeFiles/urdf_optimizer_beta.dir/all] Error 2
make: *** [all] Error 2

The code that causes this crash is rather simple:

#include <ros/ros.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <pilatus/DrivePosesAction.h>

int main (int argc, char **argv)
{
    ros::init(argc, argv, "urdf_optimizer_beta");

    actionlib::SimpleActionClient<pilatus::DrivePosesAction> ac("drive_poses", true);

    return 0;
}

my CMakeLists.txt :

cmake_minimum_required(VERSION 2.8.3)
project(pilatus)

## Find catkin and any catkin packages
find_package(
        catkin
        REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        genmsg
        actionlib_msgs
        sensor_msgs
        geometry_msgs
)

## Declare ROS messages and services
add_action_files(
        DIRECTORY action
        FILES DrivePoses.action
)

## Generate added messages and services

generate_messages(
        DEPENDENCIES actionlib_msgs std_msgs sensor_msgs geometry_msgs
)

## Declare a catkin package
catkin_package(
        CATKIN_DEPENDS actionlib_msgs
)

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker pilatus_generate_messages_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener    pilatus_generate_messages_cpp)

add_executable(urdf_optimizer_beta src/urdf_optimizer_beta.cpp)
target_link_libraries(urdf_optimizer_beta ${catkin_LIBRARIES})
add_dependencies(urdf_optimizer_beta pilatus_EXPORTED_TARGETS)

Because of my python scripts which use the "DrivePose.action" successfully, I know that the action per se works. I therefore assume that the error must lie somewhere within the CMakeLists.txt . Any ideas what this could be?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
8

answered 2017-01-31 11:50:17 -0500

gvdhoorn gravatar image

updated 2017-01-31 11:51:47 -0500

This is C++, not Python, so you need to make sure you link against all the required libraries.

find_package(
        catkin
        REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        genmsg
        actionlib_msgs
        sensor_msgs
        geometry_msgs
)

I don't see actionlib here in your COMPONENTS list.

Add that and try again.

Note that this is documented on the wiki: wiki/actionlib - Catkin.

edit flag offensive delete link more

Comments

1

thank you very much! adding this to the CMakeLists.txt and package.xml fixed the problem

Beaucay gravatar image Beaucay  ( 2017-01-31 12:13:09 -0500 )edit

You saved my day

volume_8091 gravatar image volume_8091  ( 2019-04-02 04:28:29 -0500 )edit
1

It appears that using an action server only requires actionlib_msgs while using an action client requires both actionlib and actionlib_msgs

Rufus gravatar image Rufus  ( 2020-11-25 02:45:04 -0500 )edit

@Rufus Thanks a lot for your comment, these are the kind of things I find the official documentation to not always be very specific about or easy to find.

abhishek47 gravatar image abhishek47  ( 2021-07-18 06:17:08 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-01-31 10:19:46 -0500

Seen: 2,928 times

Last updated: Jan 31 '17