Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented rate-control-topic and rate-control-max-delay. #947

Merged
merged 11 commits into from
Feb 14, 2017

Conversation

EliteMasterEric
Copy link
Contributor

Added the ability to add a rate-control-topic, which allows you to specify a topic where, if it has not been published to in the last seconds, playback will be delayed (distinguished from paused) until the topic continues.

@EliteMasterEric
Copy link
Contributor Author

I closed the pull request to make some fixes, and now it is open again.

Below is a zip file containing:
Test.msg, a message type with a timestamp and a string message.
test_control_in.py, a python script that simply prints a timestamped message 20 times a second, used to create a bag.
2016-12-15-12-17-30.bag, a bag file created by recording the output of the above script for 60 seconds.
test_control.py, a python script that simulates a processing function by waiting 100 ms every time it waits a message, before it can receive another.

To test, run test_control.py, then run

rosrun rosbag play --rate-control-topic /test/out --rate-control-max-delay 1.0 --bags /home/eric/ros_workspace/2016-12-15-12-17-30.bag

If the test_control.py script becomes more than 1 second behind, the rosbag playback will be automatically delayed until the test_control.py script catches up.

This is a useful feature to allow rosbag playback that prioritizes processing every message, rather than running at the required rate.

RateControlTopicTest.zip

@kmhallen
Copy link
Contributor

kmhallen commented Dec 15, 2016

Added arguments

--rate-control-topic /some/topic

  • Watch the given topic, and if the last publish was more than [rate-control-max-delay] ago, wait until the topic publishes again to continue playback
  • Defaults to empty string

--rate-control-max-delay 12.34

  • Maximum time difference in seconds from the timestamp in [rate-control-topic] to bag time before pausing
  • Defaults to 1.0

Use Case

Playing back recorded lidar data to build a map offline, but how fast can the bag run without dropping messages?

Example

The bag was recorded at 20Hz. A simulated system can only handle 10Hz. This shows the benefits of the added rate-control arguments.

  • Start a roscore
    • roscore
  • Simulate 100ms processing delay with queue size of 10
    • ./test.py
  • Play bag with messages every 50ms, some messages will be dropped
    • rosrun rosbag play test.bag --clock -r 1.0
  • Play bag with rate control, bag will pause to prevent dropped messages
    • rosrun rosbag play test.bag --clock -r 1.0 --rate-control-topic /test/out --rate-control-max-delay 0.5

test.tar.gz

Copy link
Contributor

@kmhallen kmhallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't compile, please update the boost::bind that references updateRateTopicTime(), and check that it compiles.

@dirk-thomas
Copy link
Member

@mastereric Thanks for addressing the compilation problem. In the mean time I have resolved the merge conflict to make the patch mergable again. @kmhallen Can you please try this again and update your review status.

@dirk-thomas
Copy link
Member

This change does break ABI. @ros/ros_comm-maintainers what do you think? Should this target Lunar instead?

@mikepurvis
Copy link
Member

We already broke rosbag::Player ABI recently, see discussion in #949 (comment), so I don't think it's a concern.

@Bhupesh19
Copy link

Bhupesh19 commented Apr 12, 2018

Is it designed to work with only one topic in the bag file? What happens in the following scenario:

  • Bag file has multiple topics
  • Node subscribe to one topic and publish one topic (rate-control-topic)

@kmhallen
Copy link
Contributor

Yes, it was designed to work with one topic. The bag playback will pause, so all topics will stop until the rate-control-topic catches up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants