ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

message_filter synchronize boolean msg

asked 2020-10-10 16:27:54 -0500

kaponloto gravatar image

updated 2020-10-11 02:31:44 -0500

gvdhoorn gravatar image

Hello I want to add a boolean msg in my synchronizer but it seems that BoolConstPtr definition in the callback function is not working. Here is my class and callback dsefiniton.

class LandingNode {

public:
LandingNode (ros::NodeHandle &nh);
~LandingNode ();
void proc_callback (const sensor_msgs::ImageConstPtr& msgLeft,const sensor_msgs::ImageConstPtr& msgRight, const std_msgs::BoolConstPtr& msgHover);
private:
  typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, std_msgs::Bool> sync_pol;
  message_filters::Subscriber<sensor_msgs::Image> *sub_left;
  message_filters::Subscriber<sensor_msgs::Image> *sub_right;
  message_filters::Subscriber<std_msgs::Bool>  *sub_hover;
  message_filters::Synchronizer<sync_pol> *sync_;
};

LandingNode::LandingNode( ros::NodeHandle &nh) {
 sub_left = new message_filters::Subscriber<sensor_msgs::Image> (nh, "/left/image_raw", 10);
 sub_right = new message_filters::Subscriber<sensor_msgs::Image> (nh, "/right/image_raw", 10);
 sub_hover = new message_filters::Subscriber<std_msgs::Bool> (nh, "/is_hover", 10);
 sync_ = new message_filters::Synchronizer<sync_pol> (sync_pol(10), *sub_left, *sub_right, *sub_hover);

 sync_->registerCallback(boost::bind(&LandingNode::proc_callback, this, _1, _2, _3));
 boost::thread t = boost::thread(boost::bind(&spinthread));
}
void LandingNode::proc_callback(const sensor_msgs::ImageConstPtr& msgLeft, const sensor_msgs::ImageConstPtr& msgRight, const std_msgs::BoolConstPtr& msgHover) {

i see the following errors

error: ‘__s_getMD5Sum’ is not a member of ‘boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >’
     return M::__s_getMD5Sum().c_str();

error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::Bool_<std::allocator<void> >, void>’
     ros::Time msg_time = mt::TimeStamp<typename mpl::at_c<Messages, i>::type>::value(msg);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
 error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::Bool_<std::allocator<void> >, void>’
       if ((mt::TimeStamp<M2>::value(*m2.getMessage()) < time) ^ end)
            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/opt/ros/melodic/include/message_filters/sync_policies/approximate_time.h:565:40: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::Bool_<std::allocator<void> >, void>’
         time = mt::TimeStamp<M2>::value(*m2.getMessage());
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~

The whole terminal msg id the following

opt/ros/melodic/include/message_filters/subscriber.h:146:7:   required from ‘void message_filters::Subscriber<M>::subscribe(ros::NodeHandle&, const string&, uint32_t, const ros::TransportHints&, ros::CallbackQueueInterface*) [with M = boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >; std::__cxx11::string = std::__cxx11::basic_string<char>; uint32_t = unsigned int]’
/opt/ros/melodic/include/message_filters/subscriber.h:114:14:   required from ‘message_filters::Subscriber<M>::Subscriber(ros::NodeHandle&, const string&, uint32_t, const ros::TransportHints&, ros::CallbackQueueInterface*) [with M = boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >; std::__cxx11::string = std::__cxx11::basic_string<char>; uint32_t = unsigned int]’
/home/ubuntu/catkin_ws/src/landing/src/landing2.cpp:52:93:   required from here
/opt/ros/melodic/include/ros/message_traits.h:121:28: error: ‘__s_getMD5Sum’ is not a member of ‘boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >’
     return M::__s_getMD5Sum().c_str();
            ~~~~~~~~~~~~~~~~^~
/opt/ros/melodic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value() [with M = boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >]’:
/opt/ros/melodic/include/ros/message_traits.h:237:104:   required from ‘const char* ros::message_traits::datatype() [with M = boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >]’
/opt/ros/melodic/include/ros/subscribe_options.h:90:53:   required from ‘void ros::SubscribeOptions::initByFullCallbackType(const string&, uint32_t, const boost::function<void(P)>&, const boost::function<boost::shared_ptr<typename ros::ParameterAdapter<P>::Message>()>&) [with P = const ros::MessageEvent<const boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > > >&; std::__cxx11::string = std::__cxx11::basic_string<char>; uint32_t = unsigned int; typename ros::ParameterAdapter<P>::Message = boost::shared_ptr<const std_msgs::Bool_<std::allocator<void> > >]’
/opt ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-10-11 02:36:47 -0500

gvdhoorn gravatar image

The message_filter synchroniser classes only support messages with std_msgs/Headers in them -- otherwise it would not have any time information with which to synchronise the message streams.

std_msgs/Bool does not contain a header, so you cannot pass it to message_filters.

This is also clearly stated on the wiki page:

The TimeSynchronizer filter synchronizes incoming channels by the timestamps contained in their headers [..]

Unlike the Python version, I believe the C++ version does not support headerless messages.

It could be worthwhile to check fkie_message_filters, although I'm not sure whether it can work around/with headerless messages.

edit flag offensive delete link more

Comments

Indeed. thank you for your answer.

kaponloto gravatar image kaponloto  ( 2020-10-11 06:19:24 -0500 )edit

Question Tools

Stats

Asked: 2020-10-10 16:27:54 -0500

Seen: 679 times

Last updated: Oct 11 '20