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

TimeSynchronizer compilation error

asked 2016-02-22 19:14:04 -0500

bigbrett gravatar image

updated 2016-02-23 09:28:47 -0500


I am trying to implement a simple approximate time synchronizer that synchronizes two topics, Imu data and a twist message from an xbox controller

I have not even departed from the structure of the example here, but I can't for the life of me figure out where my build errors are coming from since it is buried somewhere in a sea of boost warning messages that I can't decrypt.

The node I wrote is below.

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <sensor_msgs/Imu.h>
#include <sensor_msgs/Joy.h>

#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>

using namespace sensor_msgs;
using namespace geometry_msgs;
using namespace message_filters;

void syncCallback(const sensor_msgs::Imu::ConstPtr& msg, const geometry_msgs::Twist::ConstPtr& vel)

int main(int argc, char** argv)
    /* initialize ros and create node */ 
    ros::init(argc, argv, "sync_cmd");

    /* create node handle */ 
    ros::NodeHandle nh; 

    /* create filtered subscriber objects for imu and xbox topics */
    message_filters::Subscriber<sensor_msgs::Imu> imu_sub(nh, "/imu/data", 1); 
    message_filters::Subscriber<geometry_msgs::Twist> xbox_sub(nh, "/cmd_vel", 1); 

    typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Imu, geometry_msgs::Twist> MySyncPolicy;
    // ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)

    message_filters::Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), imu_sub, xbox_sub);
    sync.registerCallback(boost::bind(&syncCallback, _1, _2)); 


    return 0;

There are a huge amount of error messages from boost which are really hard for me to make sense of, but the first thing that looked important was the error message below. The full error message can be found at

/home/ubuntu/catkin_ws/src/mvp_ros/src/synchronizer.cpp:34:89:   required from here
/opt/ros/indigo/include/message_filters/sync_policies/approximate_time.h:167:89: error: 'value' is not a member of 'ros::message_traits::TimeStamp<geometry_msgs::Twist_<std::allocator<void> >, void>'
     ros::Time msg_time = mt::TimeStamp<typename mpl::at_c<Messages, i>::type>::value(msg);
/opt/ros/indigo/include/message_filters/sync_policies/approximate_time.h:177:99: error: 'value' is not a member of 'ros::message_traits::TimeStamp<geometry_msgs::Twist_<std::allocator<void> >, void>'
       previous_msg_time = mt::TimeStamp<typename mpl::at_c<Messages, i>::type>::value(previous_msg);
/opt/ros/indigo/include/message_filters/sync_policies/approximate_time.h:183:100: error: 'value' is not a member of 'ros::message_traits::TimeStamp<geometry_msgs::Twist_<std::allocator<void> >, void>'
       previous_msg_time =  mt::TimeStamp<typename mpl::at_c<Messages, i>::type>::value(previous_msg);


Ughh ok I thought the suggestion from @ahendrix would work, but now I'm hitting another error that is even more cryptic.....

CMakeFiles/synchronizer.dir/src/synchronizer.cpp.o: In function `message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime<sensor_msgs::Imu_<std::allocator<void> >, geometry_msgs::TwistStamped_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType> >::disconnectAll()':
synchronizer.cpp:(.text._ZN15message_filters12SynchronizerINS_13sync_policies15ApproximateTimeIN11sensor_msgs4Imu_ISaIvEEEN13geometry_msgs13TwistStamped_IS5_EENS_8NullTypeESA_SA_SA_SA_SA_SA_EEE13disconnectAllEv[_ZN15message_filters12SynchronizerINS_13sync_policies15ApproximateTimeIN11sensor_msgs4Imu_ISaIvEEEN13geometry_msgs13TwistStamped_IS5_EENS_8NullTypeESA_SA_SA_SA_SA_SA_EEE13disconnectAllEv]+0x24): undefined reference to `message_filters::Connection::disconnect()'

The key error here seems to be the undefined reference to message_filters::Connection::Connection(boost::function<void ()> const&). I feel terrible just posting error codes and asking or addition to helping me solve this ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-22 20:32:05 -0500

ahendrix gravatar image

Twist messages don't have a header, which normally contains the timestamp used by the synchronizers.

I think this error message is trying to tell you that you can't use a Twist with a synchronizer.

edit flag offensive delete link more


thanks for the response. Looks like I'll need to define a custom message type then (which is allowed I believe?)

bigbrett gravatar image bigbrett  ( 2016-02-22 21:42:10 -0500 )edit

There is a TwistStamped which is a Twist message with a header. I would recommend that instead of defining your own message.

ahendrix gravatar image ahendrix  ( 2016-02-22 22:36:01 -0500 )edit

arghh that answer makes perfect sense now, so I marked this as solved, but then upon implementing it, I am now getting another even more cryptic error (see the edit in my OP). Any ideas?

bigbrett gravatar image bigbrett  ( 2016-02-23 08:59:54 -0500 )edit

solved, your suggestion was indeed the correct answer, and I was just inappropriately handling the geometry_msgs/TwistStamped type. Will edit OP. Thanks much!

bigbrett gravatar image bigbrett  ( 2016-02-23 09:19:14 -0500 )edit

Hello,i just want to use TimeSynchronizer,do i need install boost?Bescause when i include these headers and compile code,it seems to show boost error.Thank you.

aids293 gravatar image aids293  ( 2016-02-23 23:23:55 -0500 )edit

@aids293: if you have the topic_tools package installed, it should install the libraries you need too. Please ask a new question and include your source code and the full error message.

ahendrix gravatar image ahendrix  ( 2016-02-24 01:11:19 -0500 )edit

Ok ,thank you

aids293 gravatar image aids293  ( 2016-02-26 00:25:43 -0500 )edit

Question Tools

1 follower


Asked: 2016-02-22 19:14:04 -0500

Seen: 2,670 times

Last updated: Feb 23 '16