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

subscribe to two topics of int and sensormsg types

asked 2016-11-27 00:02:39 -0500

anadgopi1994 gravatar image

I want to subscribe to topics that are of types int and sensor_msg .I want only one call back function to proces these two messages together .Please give an example code for this:

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2016-11-27 04:21:59 -0500

gvdhoorn gravatar image

If both messages have headers, then look into the Time Synchronizers in the message_filters package.

That would allow you to handle (time synchronised) pairs of incoming msgs in a single callback.

edit flag offensive delete link more

Comments

I tried the code in time synchronizer which subscribe to two sensor_msg data types that is working.But when i tried to subcribe to two Int8 msg of type std_msgs A lot errors are showing.

anadgopi1994 gravatar image anadgopi1994  ( 2016-11-27 08:40:44 -0500 )edit

Well, both msgs need to have a header. Int8 doesn't have a header, so that could explain the errors.

Any synchronisation strategy will need some piece of information with which it can determine which msgs 'belong together'. The stamp is one way of doing that. Without it, it won't work.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-27 10:09:58 -0500 )edit

Could you please mention that you've posted those 'errors' to another question in the future? Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2016-11-27 10:13:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-27 00:02:39 -0500

Seen: 520 times

Last updated: Nov 27 '16