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

What is the best way to synchronize messages?

asked 2021-03-28 23:34:55 -0500

Kansai gravatar image

I wrote a script with two subscribers. The general way to do this is of course

subN = rospy.Subscriber("topicN", TypeN,CallbackN)

so I have two callbacks: Callback1 for topic1 and Callback2 for topic2

However my objective is to use the information of both these topics to generate (and publish) another message.

I am wondering how should I proceed to use both of these messages? Where should I put the code? In a third callback function? How can I synchronize receiving these two messages?

edit retag flag offensive close merge delete

Comments

@Kansai: I'm trying to figure out what leads people to post new questions on topics already discussed on ROS Answers. There are many duplicates of your question (and of @Rufus answer).

Could you write a bit about how you approached posting here? Did you search before you posted? If so: how did you search? With which tools? If not: why not? If you did search, and did find previous Q&As: did those not answer your question? Could you describe why not?

gvdhoorn gravatar image gvdhoorn  ( 2021-03-29 01:15:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-29 00:10:47 -0500

Rufus gravatar image

You can use a message_filter for this. If you want to synchronize by time, you can use the TimeSynchronizer or ApproximateTimeSynchronizer.

edit flag offensive delete link more

Comments

Kansai gravatar image Kansai  ( 2021-03-29 00:16:41 -0500 )edit

Mmmm. I tried the example in the link and eventhough both topics are publishing (I checked this) the callback function is not being called. then I found this https://answers.ros.org/question/1726...

Kansai gravatar image Kansai  ( 2021-03-29 02:18:07 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-03-28 23:34:55 -0500

Seen: 2,800 times

Last updated: Mar 29 '21