Robotics StackExchange | Archived questions

TimeSynchronizer question : callback not called

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.cpp:14:
/opt/ros/hydro/include/message_filters/synchronizer.h:189:3: note: template<class F0, class F1, class F2, class F3, class F4, class F5> message_filters::Synchronizer::Synchronizer(const Policy&, F0&, F1&, F2&, F3&, F4&, F5&)
/opt/ros/hydro/include/message_filters/synchronizer.h:189: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 7 arguments, 2 provided
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:38:0,

Update: I modified the MyPolicy to 1000. Here is a rostopic echo for /rrbot/joint1positioncontroller/state and /rrbot/joint2positioncontroller/state. They are published with identical time stamps.

rostopic echo /rrbot/joint1_position_controller/state
header: 
  seq: 121
  stamp: 
    secs: 12
    nsecs: 742000000
  frame_id: ''
set_point: 0.0
process_value: -0.0157292577876
process_value_dot: 0.0
error: 0.0157292577876
time_step: 0.01
command: 0.707721581498
p: 45.0
i: 0.2
d: 0.1
i_clamp: 0.0

rostopic echo /rrbot/joint2_position_controller/state

header: 
  seq: 121
  stamp: 
    secs: 12
    nsecs: 742000000
  frame_id: ''
set_point: 0.0
process_value: -0.00342763697945
process_value_dot: 0.0
error: 0.00342763697945
time_step: 0.01
command: 0.154095246248
p: 45.0
i: 0.2
d: 0.1
i_clamp: 0.0

The callback is never called. The ROS_INFO print line does print so this code is executed. The topics are published by gazebo via the gazebo-ros plugin for the two joints. So why is the callback not called?

  // 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(10), j1_sub, j2_sub);
     sync.registerCallback(boost::bind(&PublishOdometry::handelerOdometry, this, _1, _2));
     ROS_INFO("handelerInitialPose finished processing");

Asked by rnunziata on 2013-09-27 04:34:44 UTC

Comments

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).

Asked by georgebrindeiro on 2013-09-27 04:58:00 UTC

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...

Asked by georgebrindeiro on 2013-09-27 06:24:46 UTC

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.

Asked by georgebrindeiro on 2013-09-27 10:52:21 UTC

I use them all the time...even within the same node that is having this problem.

Asked by rnunziata on 2013-09-27 11:22:45 UTC

Answers

New item opened with test program demonstrating problem

Asked by rnunziata on 2013-09-28 06:09:57 UTC

Comments