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

Revision history [back]

click to hide/show revision 1
initial version

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

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