compile error for actionlib fibonacciServer.cpp tutorial
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 ...
What is your code? This doesn't look like a include path error at all.
I edited the question to add the code for fibonnacci_server.cpp and the CMakeLists.txt files.
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?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