TimeSynchronizer question : callback not called [closed]
update:
tried to pass just one subscriber.
// Listen for motor control response
Subscriber<JointControllerState> j1_sub(n, "/rrbot/joint1_position_controller/state", 10);
// Subscriber<JointControllerState> j2_sub(n, "/rrbot/joint2_position_controller/state", 10);
typedef sync_policies::ApproximateTime<JointControllerState, JointControllerState> MySyncPolicy;
Synchronizer<MySyncPolicy> sync(MySyncPolicy(1000), j1_sub);
sync.registerCallback(boost::bind(&PublishOdometry::handelerOdometry, this, _1));
ROS_INFO("handelerInitialPose finished processing");
get compilation error:
Building CXX object gazebo_ros_demos/rrbot_control/CMakeFiles/robot_odometry.dir/src/robot_odometry.cpp.o
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp: In member function ‘void PublishOdometry::handelerInitialPose(geometry_msgs::PoseWithCovarianceStampedConstPtr)’:
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:163:64: error: no matching function for call to ‘message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<control_msgs::JointControllerState_<std::allocator<void> >, control_msgs::JointControllerState_<std::allocator<void> > > >::Synchronizer(MySyncPolicy, message_filters::Subscriber<control_msgs::JointControllerState_<std::allocator<void> > >&)’
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:163:64: note: candidates are:
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:38:0,
from /home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:14:
/opt/ros/hydro/include/message_filters/synchronizer.h:220:3: note: message_filters::Synchronizer<Policy>::Synchronizer(const Policy&) [with Policy = message_filters::sync_policies::ApproximateTime<control_msgs::JointControllerState_<std::allocator<void> >, control_msgs::JointControllerState_<std::allocator<void> > >]
/opt/ros/hydro/include/message_filters/synchronizer.h:220:3: note: candidate expects 1 argument, 2 provided
/opt/ros/hydro/include/message_filters/synchronizer.h:213:3: note: template<class F0, class F1, class F2, class F3, class F4, class F5, class F6, class F7, class F8> message_filters::Synchronizer::Synchronizer(const Policy&, F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&)
/opt/ros/hydro/include/message_filters/synchronizer.h:213:3: note: template argument deduction/substitution failed:
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:163:64: note: candidate expects 10 arguments, 2 provided
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:38:0,
from /home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:14:
/opt/ros/hydro/include/message_filters/synchronizer.h:205:3: note: template<class F0, class F1, class F2, class F3, class F4, class F5, class F6, class F7> message_filters::Synchronizer::Synchronizer(const Policy&, F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&)
/opt/ros/hydro/include/message_filters/synchronizer.h:205:3: note: template argument deduction/substitution failed:
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:163:64: note: candidate expects 9 arguments, 2 provided
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:38:0,
from /home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:14:
/opt/ros/hydro/include/message_filters/synchronizer.h:197:3: note: template<class F0, class F1, class F2, class F3, class F4, class F5, class F6> message_filters::Synchronizer::Synchronizer(const Policy&, F0&, F1&, F2&, F3&, F4&, F5&, F6&)
/opt/ros/hydro/include/message_filters/synchronizer.h:197:3: note: template argument deduction/substitution failed:
/home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry.cpp:163:64: note: candidate expects 8 arguments, 2 provided
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:38:0,
from /home/viki/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_odometry ...
Two things come to mind when I look at your code: check your subscribed topics in rqt_graph (rrbot seems like a typo for robot) and check if your synchronization policy is being too strict by echoing both topics and looking at timestamps (10 ms might be too little depending on what you are syncing).
I can't think of a good reason. I was having issue with TimeSynchronizer being called the other day, but that's because I wasn't using the ApproximateTime sync policy. One thing you could try is just seeing if you can get separate subscribers to work, just as a sanity check. Or check DEBUG output...
I don't think what you did is valid, since it doesn't make sense to synchronize a channel alone. I meant regular ROS subscribers.
I use them all the time...even within the same node that is having this problem.