Ask Your Question

Revision history [back]

Change your commented out lines to:

typedef sync_policies::ApproximateTime<myMsg, myMsg> MySyncPolicy;
typedef Synchronizer<MySyncPolicy> Sync;
boost::shared_ptr<Sync> sync;

In your constructor initialize and register:

sync.reset(new Sync(MySyncPolicy(10), sub1, sub2));      
sync->registerCallback(boost::bind(&Node::callback, this, _1, _2));

Change your commented out lines to:

typedef sync_policies::ApproximateTime<myMsg, myMsg> MySyncPolicy;
typedef Synchronizer<MySyncPolicy> Sync;
boost::shared_ptr<Sync> sync;

In your constructor initialize and register:

sync.reset(new Sync(MySyncPolicy(10), sub1, sub2));      
sync->registerCallback(boost::bind(&Node::callback, this, _1, _2));

Update

A couple of other things to keep in mind.

  1. The messages you are subscribing to require a std_msgs/Header field so that message times can be compared.
  2. Change the signature of your callback to void callback(const myMsgConstPtr &in1, const myMsgConstPtr &in2).

With those types of changes I was able to get a node to compile that basically mimics what you have. I had to substitue myMsg for sensor_msgs/Image in order to use a message type I have access to.

Change your commented out lines to:

typedef sync_policies::ApproximateTime<myMsg, myMsg> MySyncPolicy;
typedef Synchronizer<MySyncPolicy> Sync;
boost::shared_ptr<Sync> sync;

In your constructor initialize and register:

sync.reset(new Sync(MySyncPolicy(10), sub1, sub2));      
sync->registerCallback(boost::bind(&Node::callback, this, _1, _2));

Update

A couple of other things to keep in mind.

  1. The messages you are subscribing to require a std_msgs/Header field so that message times can be compared.
  2. Change the signature of your callback to void callback(const myMsgConstPtr control_sys::IntWithHeaderConstPtr &in1, const myMsgConstPtr control_sys::IntWithHeaderConstPtr &in2).

With those types of changes I was able to get a node to compile that basically mimics what you have. I had to substitue myMsg for sensor_msgs/Image in order to use a message type I have access to.