Robotics StackExchange | Archived questions

Passing many arguments to the callback

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 odocallback(navmsgs::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(),

Asked by Younès on 2018-05-15 14:27:51 UTC

Comments

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

Asked by gvdhoorn on 2018-05-15 14:56:50 UTC

Answers