Passing many arguments to the callback

asked 2018-05-15 14:27:51 -0600

Younès gravatar image

Hi,

I am using Ubuntu 16.04 and ROS lunar. I would like to pass several arguments to a callback using the subscriber. My code is :

float testeur=ps.getSignGlob();

ros::Subscriber sub_odometry = node.subscribe<nav_msgs::Odometry>(topic_root + "/odom", 0, boost::bind(ps.odo_callback, _1, pc,testeur, &pub_pc), ros::VoidConstPtr(),
  ros::TransportHints().tcpNoDelay());

The callback prototype is : void odo_callback(nav_msgs::OdometryConstPtr odo, ratslam::PosecellNetwork *pc, ros::Publisher * pub_pc, float testeur); I was getting this error :

error: invalid use of non-static member function
ros::Subscriber sub_odometry = node.subscribe<nav_msgs::Odometry>(topic_root + "/odom", 0, boost::bind(ps.odo_callback, _1, pc,&testeur, &pub_pc), ros::VoidConstPtr(),
edit retag flag offensive close merge delete

Comments

You probably need to pass this as pointer to the object on which the registered callback should be invoked.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-15 14:56:50 -0600 )edit