-
Notifications
You must be signed in to change notification settings - Fork 251
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 delay option #789
Add delay option #789
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR!
I left a couple comments/suggestions.
@@ -215,6 +215,13 @@ void Player::play() | |||
is_in_play_ = true; | |||
try { | |||
do { | |||
float delay = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move delay
out of the loop? I don't think it can change between iterations.
I'd also suggest raising a warning or exception when delay is an invalid value. That way the user knows when they enter an invalid value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it out of the loop. And raising warning and set to 0 if dealy value is invalid. 0b4687f
@@ -43,6 +43,8 @@ TEST_F(RosBag2PlayTestFixture, play_bag_file_twice) { | |||
const size_t read_ahead_queue_size = 1000; | |||
const float rate = 1.0; | |||
const bool loop_playback = false; | |||
double clock_publish_frequency = 0.0; | |||
const float delay = 1.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also test for an invalid delay value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added tests for delay in dfee76a.
I know at one point there was a plan to implement node lifecycles for rosbag. Is this still the case, because this seems like a case where it would fit in really well. |
@zmichaels11 |
ros2bag/ros2bag/verb/play.py
Outdated
@@ -116,6 +119,7 @@ def main(self, *, args): # noqa: D102 | |||
play_options.loop = args.loop | |||
play_options.topic_remapping_options = topic_remapping | |||
play_options.clock_publish_frequency = args.clock | |||
play_options.delay=args.delay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter is failing on this line - it will help you to run the tests locally before putting up for review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thaks for your review and advice. I modified it and checked that test_flake8.py
paased. 1c0cbff
There isn't an active effort going on - I don't personally have a concrete idea what this would look like. We could take that discussion to another issue if we want to pick it up. With some quick diagrams or something showing what we would want. |
Looking very close - you will need to sign your commits for the DCO check to pass. You can do that with |
@emersonknapp |
Gist: https://gist.githubusercontent.com/emersonknapp/df22ce71e23066faa49f1ad4b777faee/raw/e66eb02dae79a8dbe4184fb2c6bf28be493f1741/ros2.repos |
The Windows runners are very slow - and so timing-based tests don't always work the way you would expect there. Is there any deterministic way to check on this test, without depending on actual timing? (worst case, we could just expand the error margin to accommodate these slow runners) |
@emersonknapp rosbag2/rosbag2_transport/test/rosbag2_transport/test_play_timing.cpp Lines 122 to 123 in c8b1032
I don't think there are many cases where we actually want to delay by 0.x seconds, so how about simply increasing the margin (1.0, etc.)? |
And this test is included in the rate test, but it's better to separate them. |
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
Signed-off-by: kosuke55 <[email protected]>
auto reader = std::make_unique<rosbag2_cpp::Reader>(std::move(prepared_mock_reader)); | ||
auto player = std::make_shared<rosbag2_transport::Player>( | ||
std::move( | ||
reader), storage_options_, play_options_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. It would be better if
std::move(
reader), storage_options_, play_options_);
would be on one line
std::move(reader), storage_options_, play_options_);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I modified all same part in 75eca9f.
Signed-off-by: kosuke55 <[email protected]>
@emersonknapp |
No - nothing left. I just didn't look at it over the holiday weekend. Please feel free to open a Galactic backport PR |
* Add delay option Signed-off-by: kosuke55 <[email protected]>
Backport #789 to galactic * Add delay option Signed-off-by: kosuke55 <[email protected]>
Hi, thank you for your work.
In this PR I added
--delay
option related to #786.If we run for the following, the rosbag will play after a 5 second sleep.
It also works with
--loop
like