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

When using sim time, wait for /clock before beginning recording #1378

Merged
merged 4 commits into from
Jun 12, 2023

Conversation

emersonknapp
Copy link
Collaborator

Fixes #1276
Retry at #1354 after reverting

When using sim-time, check that /clock has actually been received before writing any messages into the bag, to avoid the time jump that then happens on first /clock message, given that initial messages are written with a timestamp of 0.
This potentially drops some messages that it could have written, but is more correct, in that those messages are "out of time" and have no temporal standing in simulated time.

@emersonknapp emersonknapp requested a review from a team as a code owner June 7, 2023 05:26
@emersonknapp emersonknapp requested review from MichaelOrlov and jhdcs and removed request for a team June 7, 2023 05:26
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@emersonknapp While implementation looks good to me, the failure on the record_all_with_sim_time Is a big surprise for me.

20: [ RUN      ] RecordIntegrationTestFixture.record_all_with_sim_time
20: stdin is not a terminal device. Keyboard handling disabled.[INFO] [1686360701.266425264] [rosbag2_recorder]: Press SPACE for pausing/resuming
20: [INFO] [1686360701.268967062] [rosbag2_recorder]: Event publisher thread: Starting
20: [INFO] [1686360701.270181670] [rosbag2_recorder]: Listening for topics...
20: [INFO] [1686360701.270365093] [rosbag2_recorder]: use_sim_time set, waiting for /clock before starting recording...
20: /tmp/ws/src/rosbag2/rosbag2_transport/test/rosbag2_transport/test_record_all_use_sim_time.cpp:64: Failure
20: Value of: pub_manager.wait_for_matched(string_topic.c_str())
20:   Actual: false
20: Expected: true
20: [INFO] [1686360711.281632076] [rosbag2_recorder]: Event publisher thread: Exiting
20: [  FAILED  ] RecordIntegrationTestFixture.record_all_with_sim_time (10034 ms)
20: [----------] 1 test from RecordIntegrationTestFixture (10034 ms total)

It looks like our check for the

if (node->get_clock()->wait_until_started(record_options_.topic_polling_interval))

doesn't work as we expected.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
…ry after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/sim-time-wait-for-clock-redo branch from 8d5624b to 786f648 Compare June 12, 2023 00:19
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Jun 12, 2023

The test failure was a side effect of changing the discovery behavior. The test was treating /clock like any other topic to record.

  • Recorder was waiting for first /clock message before creating subscriptions
  • Test was waiting for both /clock and /string_topic publishers to have matched subscriptions before publishing messages

The above two conditions created a deadlock. I've rewritten the test to publish /clock constantly, and only worry about recording /string_topic.

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

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

@emersonknapp LGTM. Thanks for the PR!

@emersonknapp
Copy link
Collaborator Author

Pulls: #1378
Gist: https://gist.githubusercontent.com/emersonknapp/36579bb645001b58e67310f066d1f600/raw/a112d00e3d040cabccbf7c01f10c5bade79bd4bb/ros2.repos
BUILD args: --packages-above-and-dependencies ros2bag rosbag2_transport
TEST args: --packages-above ros2bag rosbag2_transport
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/12208

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

@emersonknapp emersonknapp merged commit d52ddbb into rolling Jun 12, 2023
13 of 14 checks passed
@delete-merged-branch delete-merged-branch bot deleted the emersonknapp/sim-time-wait-for-clock-redo branch June 12, 2023 19:48
@emersonknapp
Copy link
Collaborator Author

@Mergifyio backport iron humble

@mergify
Copy link

mergify bot commented Jun 12, 2023

backport iron humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jun 12, 2023
* When using sim time, wait for /clock before beginning recording
* Disable use-sim-time && no-discovery combo, allow re-enabling discovery after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
(cherry picked from commit d52ddbb)
mergify bot pushed a commit that referenced this pull request Jun 12, 2023
* When using sim time, wait for /clock before beginning recording
* Disable use-sim-time && no-discovery combo, allow re-enabling discovery after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
(cherry picked from commit d52ddbb)

# Conflicts:
#	ros2bag/ros2bag/verb/record.py
#	rosbag2_transport/src/rosbag2_transport/recorder.cpp
emersonknapp pushed a commit that referenced this pull request Jun 12, 2023
… (#1391)

* When using sim time, wait for /clock before beginning recording
* Disable use-sim-time && no-discovery combo, allow re-enabling discovery after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
(cherry picked from commit d52ddbb)
emersonknapp pushed a commit that referenced this pull request Jun 14, 2023
…ing (backport #1378) (#1392)

* When using sim time, wait for /clock before beginning recording (#1378)
* Disable use-sim-time && no-discovery combo, allow re-enabling discovery after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
(cherry picked from commit d52ddbb)
@ros-discourse
Copy link

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/ros-2-tsc-meeting-minutes-2023-06-15/32038/1

scpeters pushed a commit to scpeters/rosbag2 that referenced this pull request Jan 3, 2024
…#1378) (ros2#1391)

* When using sim time, wait for /clock before beginning recording
* Disable use-sim-time && no-discovery combo, allow re-enabling discovery after stop()

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
(cherry picked from commit d52ddbb)
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.

Messages published before /clock recorded with timestamp 0 (--use-sim-time)
3 participants