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

throw 'no matching function for call ' compilation error when subscribe message [closed]

asked 2017-05-13 04:15:42 -0500

westeast gravatar image

updated 2017-05-13 04:18:57 -0500

code :

void MotionCore::run(){
    std::cout << "start MotionCore run";

    // init subscriber  to todo:add callback function from subscibe msg and publishmsg
    _sub_object = _nh.subscribe("/perception/object",10,boost::bind(& MotionCore::_callback_from_perception_obstacle,this));

    // init publiser,the msg publisher rate depends on perception rate from wenbo.
    _pub_trajectory = _nh.advertise<trajectory::trajectory>("obstacle_trajectory",10);


    ROS_INFO_STREAM("start MotionCore run: "<< ros::Time());
    ros::spin();
}

the callback:

    void MotionCore::_callback_from_perception_obstacle(){
    set_current_state();
    set_need_pub_msg_true();
    gen_trajectory();
}

the error infomation:

 7:08:01: Running steps for project Enmodel...
17:08:01: Starting: "/usr/bin/cmake" --build . --target all
Scanning dependencies of target Enmodel_OTHER_FILES
[ 27%] Built target Enmodel_OTHER_FILES
Scanning dependencies of target final_trajectory
[ 33%] Building CXX object trajectory/CMakeFiles/final_trajectory.dir/nodes/final_trajectory.cpp.o
In file included from /home/westeast/git/enmodel/src/trajectory/nodes/final_trajectory.cpp:4:0:
/home/westeast/git/enmodel/src/trajectory/nodes/motion/MotionCore.cpp: In member function ‘void trajectory_prediction::MotionCore::run()’:
/home/westeast/git/enmodel/src/trajectory/nodes/motion/MotionCore.cpp:14:127: error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [19], int, boost::_bi::bind_t<void, boost::_mfi::mf0<void, trajectory_prediction::MotionCore>, boost::_bi::list1<boost::_bi::value<trajectory_prediction::MotionCore*> > >)’
         _sub_object = _nh.subscribe("/perception/object",10,boost::bind(& MotionCore::_callback_from_perception_obstacle,this));
                                                                                                                               ^
/home/westeast/git/enmodel/src/trajectory/nodes/motion/MotionCore.cpp:14:127: note: candidates are:
In file included from /opt/ros/indigo/include/ros/ros.h:45:0,
                 from /home/westeast/git/enmodel/src/trajectory/nodes/final_trajectory.cpp:2:
/opt/ros/indigo/include/ros/node_handle.h:401:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), T*, const ros::TransportHints&)
   Subscriber subscribe(const std::string& topic, uint32_t queue_size, void(T::*fp)(M), T* obj, 
              ^
/opt/ros/indigo/include/ros/node_handle.h:401:14: note:   template argument deduction/substitution failed:
In file included from /home/westeast/git/enmodel/src/trajectory/nodes/final_trajectory.cpp:4:0:
/home/westeast/git/enmodel/src/trajectory/nodes/motion/MotionCore.cpp:14:127: note:   mismatched types ‘void (T::*)(M)’ and ‘boost::_bi::bind_t<void, boost::_mfi::mf0<void, trajectory_prediction::MotionCore>, boost::_bi::list1<boost::_bi::value<trajectory_prediction::MotionCore*> > >’
         _sub_object = _nh.subscribe("/perception/object",10,boost::bind(& MotionCore::_callback_from_perception_obstacle,this));
                                                                                                                               ^
In file included from /opt/ros/indigo/include/ros/ros.h:45:0,
                 from /home/westeast/git/enmodel/src/trajectory/nodes/final_trajectory.cpp:2:
/opt/ros/indigo/include/ros/node_handle.h:412:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M)const, T*, const ros::TransportHints&)
   Subscriber subscribe(const std::string& topic, uint32_t queue_size, void(T::*fp)(M) const, T* obj, 
              ^
/opt/ros/indigo/include/ros/node_handle.h:412:14: note:   template argument deduction/substitution failed:
In file included from /home/westeast/git/enmodel/src/trajectory/nodes/final_trajectory.cpp:4:0:
/home/westeast/git/enmodel/src/trajectory/nodes/motion/MotionCore.cpp:14:127: note:   mismatched types ‘void (T::*)(M)const’ and ‘boost::_bi::bind_t<void, boost::_mfi::mf0<void, trajectory_prediction::MotionCore>, boost::_bi::list1<boost::_bi::value<trajectory_prediction::MotionCore ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by NEngelhard
close date 2017-05-13 06:12:08.300134

1 Answer

Sort by » oldest newest most voted
0

answered 2017-05-13 04:41:30 -0500

westeast gravatar image

I solve the problem by add param to callbak function

void MotionCore::_callback_from_perception_obstacle(const std_msgs::StringConstPtr &msg){
    set_current_state();
    set_need_pub_msg_true();
    gen_trajectory();
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-05-13 04:15:42 -0500

Seen: 770 times

Last updated: May 13 '17