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

compile error for actionlib fibonacciServer.cpp tutorial

asked 2015-06-17 10:49:59 -0500

mmckenna gravatar image

updated 2016-11-17 02:12:05 -0500

gvdhoorn gravatar image

Hi.. I"m trying to compile the fibonacciServer.cpp code shown on the tutorial for the actionlib SimpleActionServer(ExecuteCallbackMethod) page. I've created the action file per the instructions and have copied the CMakeList.txt from the tutorial listing to the package. However, I get a compile error when trying to use the catkin_make command. Here are the errors:

Linking CXX executable /home/mark/devel/catkin_ws/devel/lib/learning_actionlib/fibonacci_server
CMakeFiles/fibonacci_server.dir/action/fibonacci_server.cpp.o: In function `actionlib::ActionServerBase<learning_actionlib::FibonacciAction_<std::allocator<void> > >::ActionServerBase(boost::function<void (actionlib::ServerGoalHandle<learning_actionlib::FibonacciAction_<std::allocator<void> > >)>, boost::function<void (actionlib::ServerGoalHandle<learning_actionlib::FibonacciAction_<std::allocator<void> > >)>, bool)':
fibonacci_server.cpp:(.text._ZN9actionlib16ActionServerBaseIN18learning_actionlib16FibonacciAction_ISaIvEEEEC2EN5boost8functionIFvNS_16ServerGoalHandleIS4_EEEEESB_b[_ZN9actionlib16ActionServerBaseIN18learning_actionlib16FibonacciAction_ISaIvEEEEC5EN5boost8functionIFvNS_16ServerGoalHandleIS4_EEEEESB_b]+0xa5): undefined reference to `actionlib::GoalIDGenerator::GoalIDGenerator()'
CMakeFiles/fibonacci_server.dir/action/fibonacci_server.cpp.o: In function `actionlib::StatusTracker<learning_actionlib::FibonacciAction_<std::allocator<void> > >::StatusTracker(boost::shared_ptr<learning_actionlib::FibonacciActionGoal_<std::allocator<void> > const> const&)':
fibonacci_server.cpp:(.text._ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC2ERKN5boost10shared_ptrIKNS1_20FibonacciActionGoal_IS3_EEEE[_ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC5ERKN5boost10shared_ptrIKNS1_20FibonacciActionGoal_IS3_EEEE]+0x60): undefined reference to `actionlib::GoalIDGenerator::GoalIDGenerator()'
fibonacci_server.cpp:(.text._ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC2ERKN5boost10shared_ptrIKNS1_20FibonacciActionGoal_IS3_EEEE[_ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC5ERKN5boost10shared_ptrIKNS1_20FibonacciActionGoal_IS3_EEEE]+0xbb): undefined reference to `actionlib::GoalIDGenerator::generateID()'
CMakeFiles/fibonacci_server.dir/action/fibonacci_server.cpp.o: In function `actionlib::StatusTracker<learning_actionlib::FibonacciAction_<std::allocator<void> > >::StatusTracker(actionlib_msgs::GoalID_<std::allocator<void> > const&, unsigned int)':
fibonacci_server.cpp:(.text._ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC2ERKN14actionlib_msgs7GoalID_IS3_EEj[_ZN9actionlib13StatusTrackerIN18learning_actionlib16FibonacciAction_ISaIvEEEEC5ERKN14actionlib_msgs7GoalID_IS3_EEj]+0x5c): undefined reference to `actionlib::GoalIDGenerator::GoalIDGenerator()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/mark/devel/catkin_ws/devel/lib/learning_actionlib/fibonacci_server] Error 1
make[1]: *** [learning_actionlib/CMakeFiles/fibonacci_server.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j8 -l8" failed

To my mind and another programmer more experienced in using the older rosbuild, it appears that the include path is not set correctly.

Thanks for any help

Mark

fibonacci_server.cpp

#include <ros/ros.h>
#include <actionlib/server/simple_action_server.h>
#include <learning_actionlib/FibonacciAction.h>

class FibonacciAction
{
protected:

  ros::NodeHandle nh_;
  // NodeHandle instance must be created before this line. Otherwise strange error may occur.
  actionlib::SimpleActionServer<learning_actionlib::FibonacciAction> as_; 
  std::string action_name_;
  // create messages that are used to published feedback/result
  learning_actionlib::FibonacciFeedback feedback_;
  learning_actionlib::FibonacciResult result_;

public:

  FibonacciAction(std::string name) :
    as_(nh_, name, boost::bind(&FibonacciAction::executeCB, this, _1), false),
    action_name_(name)
  {
    as_.start();
  }
FibonacciAction(void)
  {
  }

  void executeCB(const learning_actionlib::FibonacciGoalConstPtr &goal)
  {
    // helper variables
    ros::Rate r(1);
    bool success = true;

    // push_back the seeds for the fibonacci sequence
    feedback_.sequence.clear();
    feedback_.sequence.push_back(0);
    feedback_.sequence.push_back(1);

    // publish info to the console for the user
    ROS_INFO("%s: Executing, creating fibonacci sequence of order %i with seeds %i, %i", action_name_.c_str(), goal->order, feedback_.sequence[0], feedback_.sequence[1]);

    // start executing the action
    for(int i=1; i<=goal->order; i++)
    {
      // check that preempt has not been requested by the client
      if (as_.isPreemptRequested() || !ros::ok())
      {
        ROS_INFO("%s: Preempted", action_name_.c_str());
        // set the action state to preempted
        as_.setPreempted();
        success = false;
        break;
      }
      feedback_.sequence.push_back(feedback_.sequence[i] + feedback_.sequence[i-1]);
      // publish the feedback
      as_.publishFeedback(feedback_);
      // this sleep is not necessary, the sequence is computed at 1 Hz for demonstration purposes
      r.sleep();
    }
if(success)
    {
      result_.sequence = feedback_.sequence;
      ROS_INFO("%s: Succeeded", action_name_.c_str ...
(more)
edit retag flag offensive close merge delete

Comments

What is your code? This doesn't look like a include path error at all.

dornhege gravatar image dornhege  ( 2015-06-17 11:01:30 -0500 )edit

I edited the question to add the code for fibonnacci_server.cpp and the CMakeLists.txt files.

mmckenna gravatar image mmckenna  ( 2015-06-17 11:06:20 -0500 )edit

The first error says

Error: no matching function for call to ‘actionlib::SimpleActionServer<learning_actionlib::FibonacciAction_<std::allocator<void>>>::SimpleActionServer()’

Why is there an underscore in FibonacciAction_? Do you have a typo somewhere?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2015-06-18 02:09:56 -0500 )edit

Hi Javi. thank you for repsonding. If this was code I created, then I can see many opportunities for typos. However, I copied both the cpp and the CMakeLists.txt from the http://wiki.ros.org/actionlib_tutoria... tutorial page, without changes

mmckenna gravatar image mmckenna  ( 2015-06-18 08:22:35 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2015-06-18 02:56:09 -0500

dornhege gravatar image

The problem is the extra empty constructor that you added. This calls the default constructor of the action server, which does not exist.

edit flag offensive delete link more

Comments

Hi Dornhenge: thank you for replying. I commented out the second empty constructor and get the same error messages.

mmckenna gravatar image mmckenna  ( 2015-06-18 08:20:28 -0500 )edit

Show the exact code and error messages.

dornhege gravatar image dornhege  ( 2015-06-18 08:33:34 -0500 )edit

Errors posted above in a revision to original post. Code is posted there and taken directly from http://wiki.ros.org/actionlib_tutoria...

mmckenna gravatar image mmckenna  ( 2015-06-18 09:35:01 -0500 )edit

The new errors are completely different. You are probably missing a dependency or target_link_libraries in your CMakeLists.txt

dornhege gravatar image dornhege  ( 2015-06-18 09:40:56 -0500 )edit

Update from the future :-). The empty class constructor is actually supposed to be a class desctructor with the tilde somehow lost in the copying. Also it isn't connected to the problem. The correct solution is adding actionlib into find_package (as described bellow by tonka46).

AdamSorrel gravatar image AdamSorrel  ( 2018-04-05 09:14:59 -0500 )edit
4

answered 2016-11-16 15:30:36 -0500

gguy1 gravatar image

check your CMakeLists.txt and make sure you have actionlib and actionlib_msg in both catkin_package and find_package macro's

Also make sure that in your package.xml file you have <build_depend>actionlib</build_depend> <run_depend>actionlib</run_depend> <build_depend>actionlib_msgs</build_depend> <run_depend>actionlib_msgs</run_depend>

edit flag offensive delete link more

Comments

1

incase someone else comes across this actionlib needs to be added to find_package not catkin_package, this was missing in the tutorial.

tonka46 gravatar image tonka46  ( 2017-06-21 00:04:38 -0500 )edit

Thank you so much. This has solved my issue

eng_hish gravatar image eng_hish  ( 2021-07-13 21:25:35 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-17 10:49:59 -0500

Seen: 2,017 times

Last updated: Nov 17 '16