0
$\begingroup$

Rosanswers logo

I tried to subscribe to two integer types .But lot of errors are showing .Please help me to correct the code code:

#include <ros/ros.h>

#include <std_msgs/Int8.h>
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>

using namespace std_msgs;

using namespace message_filters;

void callback(const Int8ConstPtr& angle,const Int8ConstPtr& range_data) {

}
   int main( int argc, char** argv )
   {
    ros::init(argc, argv, "basic_shapes");
     ros::NodeHandle n;
     ros::Rate r(1);
 message_filters::Subscriber<Int8> sub1(n,"angle", 1);
message_filters::Subscriber<Int8> sub2(n,"range_data", 1);
TimeSynchronizer<Int8,Int8> sync(sub1,sub2,10);
sync.registerCallback(boost::bind(&callback,_1, _2));
   
ros::spin();
return 0;

}  

error msgs: /opt/ros/indigo/include/message_filters/sync_policies/exact_time.h: In instantiation of ‘void message_filters::sync_policies::ExactTime<M0, M1, M2, M3, M4, M5, M6, M7, M8>::add(const typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type&) [with int i = 0; M0 = std_msgs::Int8_std::allocator<void >; M1 = std_msgs::Int8_std::allocator<void >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType; typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type = ros::MessageEvent<const std_msgs::Int8_std::allocator<void > >]’: /opt/ros/indigo/include/message_filters/synchronizer.h:358:5: required from ‘void message_filters::Synchronizer::cb(const typename boost::mpl::at_c<typename Policy::Events, i>::type&) [with int i = 0; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>; typename boost::mpl::at_c<typename Policy::Events, i>::type = ros::MessageEvent<const std_msgs::Int8_std::allocator<void > >]’ /opt/ros/indigo/include/message_filters/synchronizer.h:290:138: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; F7 = message_filters::NullFilter<message_filters::NullType>; F8 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:282:52: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; F7 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:275:48: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:268:44: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:261:40: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:254:36: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:247:32: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:240:28: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/time_synchronizer.h:120:24: required from ‘message_filters::TimeSynchronizer<M0, M1, M2, M3, M4, M5, M6, M7, M8>::TimeSynchronizer(F0&, F1&, uint32_t) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; M0 = std_msgs::Int8_std::allocator<void >; M1 = std_msgs::Int8_std::allocator<void >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType; uint32_t = unsigned int]’ /home/anand/catkin_ws/src/using_markers/src/basic_shapes.cpp:40:46: required from here /opt/ros/indigo/include/message_filters/sync_policies/exact_time.h:127:101: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::Int8_std::allocator<void >, void>’ Tuple& t = tuples_[mt::TimeStamp<typename mpl::at_c<Messages, i>::type>::value(*evt.getMessage())]; ^ /opt/ros/indigo/include/message_filters/sync_policies/exact_time.h: In instantiation of ‘void message_filters::sync_policies::ExactTime<M0, M1, M2, M3, M4, M5, M6, M7, M8>::add(const typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type&) [with int i = 1; M0 = std_msgs::Int8_std::allocator<void >; M1 = std_msgs::Int8_std::allocator<void >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType; typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type = ros::MessageEvent<const std_msgs::Int8_std::allocator<void > >]’: /opt/ros/indigo/include/message_filters/synchronizer.h:358:5: required from ‘void message_filters::Synchronizer::cb(const typename boost::mpl::at_c<typename Policy::Events, i>::type&) [with int i = 1; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>; typename boost::mpl::at_c<typename Policy::Events, i>::type = ros::MessageEvent<const std_msgs::Int8_std::allocator<void > >]’ /opt/ros/indigo/include/message_filters/synchronizer.h:291:138: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; F7 = message_filters::NullFilter<message_filters::NullType>; F8 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:282:52: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; F7 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:275:48: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; F6 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:268:44: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&, F5&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; F5 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:261:40: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&, F4&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; F4 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:254:36: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&, F3&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; F3 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:247:32: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&, F2&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F2 = message_filters::NullFilter<message_filters::NullType>; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/synchronizer.h:240:28: required from ‘void message_filters::Synchronizer::connectInput(F0&, F1&) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; Policy = message_filters::sync_policies::ExactTime<std_msgs::Int8_std::allocator<void >, std_msgs::Int8_std::allocator<void >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’ /opt/ros/indigo/include/message_filters/time_synchronizer.h:120:24: required from ‘message_filters::TimeSynchronizer<M0, M1, M2, M3, M4, M5, M6, M7, M8>::TimeSynchronizer(F0&, F1&, uint32_t) [with F0 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; F1 = message_filters::Subscriber<std_msgs::Int8_std::allocator<void > >; M0 = std_msgs::Int8_std::allocator<void >; M1 = std_msgs::Int8_std::allocator<void >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType; uint32_t = unsigned int]’ /home/anand/catkin_ws/src/using_markers/src/basic_shapes.cpp:40:46: required from here /opt/ros/indigo/include/message_filters/sync_policies/exact_time.h:127:101: error: ‘value’ is not a member of ‘ros::message_traits::TimeStamp<std_msgs::Int8_std::allocator<void >, void>’ make[2]: *** [using_markers/CMakeFiles/basic_shapes.dir/src/basic_shapes.cpp.o] Error 1 make[1]: *** [using_markers/CMakeFiles/basic_shapes.dir/all] Error 2

But the same code work for sensor_msg type. why?


Originally posted by anadgopi1994 on ROS Answers with karma: 81 on 2016-11-27

Post score: -1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

"The TimeSynchronizer filter synchronizes incoming channels by the timestamps contained in their headers,"

No header -> No TimeSynchronizer

And please:

  1. invest some seconds to check your spelling
  2. don't post irrelevant code (commented includes??)
  3. format code as such (use to 101010-Button)
  4. "But lot of errors are showing" The is no ROS-interface to chrystal balls yet, so please post the error messages.

Originally posted by NEngelhard with karma: 3519 on 2016-11-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by anadgopi1994 on 2016-11-27:
i edited my post and put the error messages in the post,Now can you please help me to resolve this problem.

Comment by NEngelhard on 2016-11-27:
I already answered the question. and @gvdhoorn also told you in your first thread "If both messages have headers"... And you broke the code formatting and still have typos in the question.

Comment by anadgopi1994 on 2016-11-27:
Both message have the header #include <std_msgs/Int8.h>.I didn't understand what you are saying?Can you clarify

Comment by NEngelhard on 2016-11-27:
Please fix your question (formatting, typos)

Comment by anadgopi1994 on 2016-11-27:
I already corrected my question

Comment by NEngelhard on 2016-11-27:
neither is the code formatted correctly nor have you removed the typos. I'm sorry to be a bit pedantic, but you want some help here and some effort on your side should be visible.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.