ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
ImgProcessor(..) : it_(nh_)
{
...
// Subscribe to input video and publish output video
message_filters::Subscriber<sensor_msgs::Image> image_sub_L(nh_,IMG_DEST_L_,40);
message_filters::Subscriber<sensor_msgs::Image> image_sub_R(nh_,IMG_DEST_R_,40);
message_filters::TimeSynchronizer<sensor_msgs::Image,sensor_msgs::Image> sync(image_sub_L,image_sub_R,40);
sync.registerCallback(boost::bind(&ImgProcessor::Process,this, _1, _2));
...
}
This is more basic C++ than ROS, but your TimeSynchronizer
instance and both message_filters::Subscriber
instances are not member variables, so it will go out-of-scope as soon as your constructor runs to completion.
As they then no longer exist, I'd expect your callback to never be called, as you observed.
2 | No.2 Revision |
ImgProcessor(..) : it_(nh_)
{
...
// Subscribe to input video and publish output video
message_filters::Subscriber<sensor_msgs::Image> image_sub_L(nh_,IMG_DEST_L_,40);
message_filters::Subscriber<sensor_msgs::Image> image_sub_R(nh_,IMG_DEST_R_,40);
message_filters::TimeSynchronizer<sensor_msgs::Image,sensor_msgs::Image> sync(image_sub_L,image_sub_R,40);
sync.registerCallback(boost::bind(&ImgProcessor::Process,this, _1, _2));
...
}
This is more basic C++ than ROS, but your TimeSynchronizer
instance and both message_filters::Subscriber
instances are not member variables, so it will go out-of-scope as soon as your constructor runs to completion.
As they then no longer exist, I'd expect your callback to never be called, as you observed.
3 | No.3 Revision |
ImgProcessor(..) : it_(nh_)
{
...
// Subscribe to input video and publish output video
message_filters::Subscriber<sensor_msgs::Image> image_sub_L(nh_,IMG_DEST_L_,40);
message_filters::Subscriber<sensor_msgs::Image> image_sub_R(nh_,IMG_DEST_R_,40);
message_filters::TimeSynchronizer<sensor_msgs::Image,sensor_msgs::Image> sync(image_sub_L,image_sub_R,40);
sync.registerCallback(boost::bind(&ImgProcessor::Process,this, _1, _2));
...
}
This is more basic C++ than ROS, but your TimeSynchronizer
instance and both message_filters::Subscriber
instances are not member variables, so will go out-of-scope as soon as your constructor runs to completion.
As they then no longer exist, I'd expect your callback to never be called, as you observed.
You may also want to look at topic remapping.