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

Synchronize headerless messages

asked 2014-04-14 01:17:40 -0600

Hansg91 gravatar image

Hi,

I want to synchronize messages without headers. I know synchronization can be done with message_filters when they have timestamps, but these messages are the simple std_msgs/Float32 kind. Can this be done?

My goal is to receive two angle positions from two motors that actuate the same joint, in order to send a sensor_msgs/JointState message regarding the entire joint.

Best regards, Hans

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2014-04-14 01:49:10 -0600

updated 2014-04-14 01:50:03 -0600

If you want to do this properly, there is no way around adding a Header to the messages. Otherwise you have no information at all about when the messages are created, only when they are received by your node. There might be different delays etc. on the two topics, so that is going to fail in a lot of cases.

If you have no way of modifying the publisher so that it includes a Header, the only thing you can do is wait until you've received one message on each topic and then pretend they are synchronized, like this:

msg1 = msg2 = null;

motor1_callback(msg) {
   msg1 = msg;
   check_and_process();
}

motor2_callback(msg) {
   msg2 = msg;
   check_and_process();
}

check_and_process() {
   if (msg1 != null && msg2 != null) {
       do_something(msg1, msg2);
       msg1 = msg2 = null;
   }
}

Take-home message: add a Header to your messages, modify your publisher and use message_filters if at all possible.

edit flag offensive delete link more

Comments

Thank you for your reply, that is what I was doing now. I was hoping for a different solution but I understand what you mean. This perhaps deserves a separate topic, but my goal is to publish a joint state with pitch and yaw. Should I make one joint for both rotations, or one joint per rotation?

Hansg91 gravatar image Hansg91  ( 2014-04-14 02:17:02 -0600 )edit

You should make two `revolute` joints, because that captures your degrees of freedom correctly. If you wanted to only make one joint, you would have to use a `floating` joint, and that would be incorrect (you don't have 6 DoF).

Martin Günther gravatar image Martin Günther  ( 2014-04-14 02:58:34 -0600 )edit

Thank you very much for your reply! I will get to it :)

Hansg91 gravatar image Hansg91  ( 2014-04-14 08:33:08 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2014-04-14 01:17:40 -0600

Seen: 799 times

Last updated: Apr 14 '14