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

Add playback rate command line arg #304

Merged
merged 8 commits into from
Mar 19, 2020
Merged

Add playback rate command line arg #304

merged 8 commits into from
Mar 19, 2020

Conversation

mabelzhang
Copy link
Contributor

Addresses #290

Both -r and -s were taken, so I wasn't sure what is the next best letter to use for rate / speed. I just put in -x for this first implementation.

Examples of usage:

$ ros2 bag play -x 2.5 rosbag2_2020_01_15-21_25_18
$ ros2 bag play -x 0.5 rosbag2_2020_01_15-21_25_18
$ ros2 bag play -x 1 rosbag2_2020_01_15-21_25_18

with updated usage message:

$ ros2 bag play -h
usage: ros2 bag play [-h] [-s STORAGE] [-r READ_AHEAD_QUEUE_SIZE] [-x RATE]
                     bag_file

ros2 bag play

positional arguments:
  bag_file              bag file to replay

optional arguments:
  -h, --help            show this help message and exit
  -s STORAGE, --storage STORAGE
                        storage identifier to be used, defaults to "sqlite3"
  -r READ_AHEAD_QUEUE_SIZE, --read-ahead-queue-size READ_AHEAD_QUEUE_SIZE
                        size of message queue rosbag tries to hold in memory
                        to help deterministic playback. Larger size will
                        result in larger memory needs but might prevent delay
                        of message playback.
  -x RATE, --rate RATE  rate at which to play back messages

Signed-off-by: Mabel Zhang mabel@openrobotics.org

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
@oceanusxiv
Copy link

So this is speculation on my part, but what would happen if the user enters a negative rate, nothing in the options forbid this and it would I think result in the player playing all messages as fast as possible with the current implementation. Maybe add a check on the sign of the rate?

Copy link
Collaborator

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

Like @eric1221bday mentioned, the input isn't being validated. I think the requirement we want is rate > 0 because 0 seems unecessary and negative seems like a potentially desirable feature but is not implemented in this PR

Also, could you include a unit test for this feature? Some simple smoke test at least

ros2bag/ros2bag/verb/play.py Outdated Show resolved Hide resolved
@Karsten1987
Copy link
Collaborator

just throwing in an idea here: We could also remove the -r from the read ahead queue. This would clearly break stuff, but I am also convinced that -r will be used more frequently for rate than for the read ahead queue.

@emersonknapp
Copy link
Collaborator

-r will be used more frequently for rate than for the read ahead queue.

Agreed, i think it should be fine to have the queue be long-form only

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
@mabelzhang
Copy link
Contributor Author

bbb4215 should address all the comments above -

  • removed -r from --read-ahead-queue-size and use for --rate.
  • added range > 0.0 check
  • added tests

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
@Karsten1987
Copy link
Collaborator

@mabelzhang Can you run CI on this? I want to make sure we don't have regression on OSX and Windows with this.

@mabelzhang
Copy link
Contributor Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator

new round of CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@mabelzhang
Copy link
Contributor Author

Oh oops didn't see that. I just started another round with a better .repos file heh

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator

@mabelzhang you might have to rebase your work on top of master.

@mabelzhang
Copy link
Contributor Author

mabelzhang commented Mar 11, 2020

New set of CIs. The previous one was building on eloquent branch for many repos, I must have copied from the wrong ros2.repos file.

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
@mabelzhang
Copy link
Contributor Author

Finally

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

The Windows cmake just has this mysterious complaint that some other builds also have:

No project() command is present. The top-level CMakeLists.txt file must

@Karsten1987
Copy link
Collaborator

Can you point to that other project which also has this warning? Are you aware of any ticket tracking this issue already?

I just want to avoid any regression introduced by this patch.

@mabelzhang
Copy link
Contributor Author

mabelzhang commented Mar 12, 2020

So the warning is this one:
https://ci.ros2.org/job/ci_windows/9516/cmake/new/
and the history graph looks like up and down from 0 to 1 alternately.

This earlier build with the same warning is just building plain ros2.repos with no additional flags:
https://ci.ros2.org/job/ci_windows/9512/cmake/new/

This one has the same warning too:
https://ci.ros2.org/job/ci_windows/9509/cmake/new/
This is the earliest one I see. There are other builds that say 1 warning in the graph, but when I check their page, they say 0, like 9506, 9500, 9499. I'm not sure why it's like that.

I don't know if a ticket is tracking this.

@Karsten1987
Copy link
Collaborator

@mabelzhang with #323 being merged, do you mind rebasing your branch and re-run CI? I am confident that CI should return all green then and this PR finally being ready to get merged ;)

@mabelzhang
Copy link
Contributor Author

Hurray

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

lgtm. @mabelzhang feel free to merge.

@mabelzhang mabelzhang merged commit bd7cf42 into ros2:master Mar 19, 2020
@mabelzhang mabelzhang deleted the playback_rate branch March 19, 2020 19:36
JoonasMelin pushed a commit to JoonasMelin/rosbag2 that referenced this pull request Aug 10, 2020
* add playback rate command line arg

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>

* uncrustify

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>

* add range check for rate; rename rate flag; add tests

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>

* fix flake8

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>

* fix uncrustify

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>

* fix windows msbuild warning

Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants