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

[rospy] simultaneous subscribe at a given frequency

asked 2012-11-20 17:43:34 -0500

Cyprien gravatar image

Hi,

I have 2 publisher who provide me 2 topics in real time, but I would like to write a listener which will, every 2 seconds, store the last topic published from those 2 publishers. And also, I'm coding in python. Do you have any idea?

Thanks and regards

Cyprien

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2012-11-20 20:27:11 -0500

Stephan gravatar image

updated 2012-11-20 20:28:16 -0500

It is not possible to subscribe at a given frequency, you have to filter the incoming messages yourself:

If the topics have to be synchronized, use a TimeSynchronizer for your subscription. In your callback, check the last time you stored the messages and if it is more than 2 seconds ago, store again and store the timestamp.

If your topics do not have to be synchronized and you just want the output to be logged to a textfile you can use throttle to republish your topic at the desired rate and rostopic for logging:

rosrun topic_tools throttle messages /topic 2.0
rostopic echo -p /topic_throttled > topiclog.txt
edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-20 17:43:34 -0500

Seen: 1,414 times

Last updated: Nov 20 '12