Passing an argument to a subscriber callback [closed]
Hello,
I need to pass an argument to a subscriber callback function. Following the answer at (http://answers.ros.org/question/12045/how-to-deliver-arguments-to-a-callback-function/), I'm using the syntax below:
ros::Subscriber subscriber = node.subscribe("joint_states", 1000, boost::bind(selfcollisionCallback, _1, current_state));
The argument is a reference to a MoveIt! class member:
robot_state::RobotState& current_state = planning_scene.getCurrentStateNonConst();
and the callback function definition is
void selfcollisionCallback(const sensor_msgs::JointState& msg, robot_state::RobotState& current_state)
I get the following errors at compilation:
/home/jml/catkin_ws/src/jaco_collision/collision_subs.cpp: In function ‘void selfcollisionCallback(const JointState&, robot_state::RobotState&)’:
/home/jml/catkin_ws/src/jaco_collision/collision_subs.cpp:47:18: error: expected primary-expression before ‘.’ token
/home/jml/catkin_ws/src/jaco_collision/collision_subs.cpp: In function ‘int main(int, char**)’:
/home/jml/catkin_ws/src/jaco_collision/collision_subs.cpp:76:123: error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [13], int, boost::_bi::bind_t<void, void (*)(const sensor_msgs::JointState_<std::allocator<void> >&, robot_state::RobotState&), boost::_bi::list2<boost::arg<1>, boost::_bi::value<robot_state::RobotState> > >)’
Any clues?
Many thanks, JML