Synchronization of multiple messages
I am trying to subscribe to 3 ros topics using the message_filters::Synchronizer
I am subscribing to the three messages sensor_msgs::Image, sensor_msgs::LaserScan
and nav_msgs::Odometry
. The synchronizer works fine for the image and laser scan but when I add the Odometry message I am getting errors. Here is the code I use:
ros::topic::waitForMessage<sensor_msgs::Image>("/robot1/front_camera/image_raw");
ros::topic::waitForMessage<sensor_msgs::LaserScan>("/robot1/front_laser/scan");
ros::topic::waitForMessage<nav_msgs::Odometry>("/robot1/odom");
message_filters::Subscriber<sensor_msgs::Image> image_sub(n, "/robot1/front_camera/image_raw", 1);
message_filters::Subscriber<sensor_msgs::LaserScan> laser_sub(n, "/robot1/front_laser/scan", 1);
message_filters::Subscriber<nav_msgs::Odometry> odom_sub(n, "/robot1/odom", 1);
message_filters::Synchronizer<approx_sync> sync(approx_sync(30), image_sub, laser_sub, odom_sub);
sync.registerCallback(boost::bind(&perception_callback, _1, _2, _3, &recognise,n));
And here are errors that I am getting after adding the Odometry message:
/usr/include/boost/bind/bind.hpp:525: error: invalid initialization of reference of type 'const boost::shared_ptr<const nav_msgs::Odometry_<std::allocator<void> > >&' from expression of type 'const boost::shared_ptr<const message_filters::NullType>'
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_], a[base_type::a4_], a[base_type::a5_]);
/opt/ros/jade/include/message_filters/signal1.h:75: error: no matching function for call to 'ros::MessageEvent<const message_filters::NullType>::MessageEvent(const ros::MessageEvent<const nav_msgs::Odometry_<std::allocator<void> > >&, bool)'
Event my_event(event, nonconst_force_copy || event.nonConstWillCopy());
I know that it probably means that the input parameters of the callback function differs from the ones that I ma inputing. But I am not able to figure out what should I modify. Here is my callback function:
void perception_callback(const sensor_msgs::Image::ConstPtr& msg_img, const sensor_msgs::LaserScan::ConstPtr& msg_laser,const nav_msgs::Odometry::ConstPtr& odom_msg, DetectPuck* recognise,ros::NodeHandle n)
Asked by horczech on 2016-06-01 04:26:13 UTC
Comments
Did you find the issue?
Asked by Vic on 2021-01-29 04:36:51 UTC