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

Upstream quality changes from Apex.AI part 1 #1903

Merged
merged 11 commits into from
Feb 6, 2025

Conversation

MichaelOrlov
Copy link
Contributor

@MichaelOrlov MichaelOrlov commented Jan 28, 2025

This PR consolidates fixes related to the code quality and stability after backporting Rosbag2 PRs to Apex.AI. PART 1

List of changes:

  1. Fix for memory leaks in tests
    Details: Need to use custom deleter when releasing rcl serialized buffer to a shared pointer.
  2. Move wait_for_playback_to_start() to public section
    • Rationale: Need to use in another package
    • Also added timeout parameter for the wait_for_playback_to_start(..) to make it non-blocking call optionally and return boolean value.
  3. Gracefully handle exceptions from on-play callbacks in player
    Rationale: Avoid abnormal termination in case of unhandled exceptions happening in callbacks.
  4. Address Axivion warnings in rosbag2_py
    Description:
    1. MisraC++2023-8.1.1 [required]: _transport.cpp:286 This variable shall not be implicitly captured in a lambda expression.; Field: []
    2. MisraC++2023-8.2.3 [required]: _transport.cpp:50 Cast removes const qualification; Field: [const char*->char*]
  5. Fix the clang16 warning that the timestamp comparator is not initialized
  6. Make sure to start with a clean subscriptions list in Recorder::record()
    Rationale: It could be some residual subscriptions in the list in case if the previous call to Recorder::record() failed for some reason and Recorder::stop() wasn't called.
  7. Call discovery_future_.get() if it's ready in the stop_discovery()
  8. Use absolute path instead of relative path in the InfoEndToEndTestFixture
  9. Don't keep trying to publish the next message if we fail the first time. The Player::play_next() should return false right away if, for some reason, failed to publish the current message.

@MichaelOrlov MichaelOrlov marked this pull request as ready for review January 28, 2025 09:35
@MichaelOrlov MichaelOrlov force-pushed the morlov/upstream_quality_changes_from_apex_ai branch from 893afc6 to 8c86347 Compare January 28, 2025 09:42
@MichaelOrlov MichaelOrlov marked this pull request as draft January 28, 2025 15:57
@MichaelOrlov
Copy link
Contributor Author

There are a few failures on CI that need to be addressed. Turning this PR back to draft.
Sorry it was premature to ask for review.

@MichaelOrlov MichaelOrlov force-pushed the morlov/upstream_quality_changes_from_apex_ai branch 2 times, most recently from 0cde47c to c35e501 Compare January 28, 2025 21:11
@MichaelOrlov
Copy link
Contributor Author

Ok. Now the CI is green and this PR is ready for review.

@MichaelOrlov MichaelOrlov marked this pull request as ready for review January 28, 2025 22:07
Copy link
Member

@christophebedard christophebedard left a comment

Choose a reason for hiding this comment

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

Minor changes.

@christophebedard
Copy link
Member

Also, you don't really need to mention/frame the title of this PR as a "sync with Apex.AI"

@MichaelOrlov MichaelOrlov changed the title Upstream quality changes after sync with Apex.AI part 1 Upstream quality changes from Apex.AI part 1 Jan 29, 2025
- It could be some residual subscriptions in list in case if previous
call to Recorder::record() failed for some reason and Recorder::stop()
wasn't called.

Signed-off-by: Michael Orlov <[email protected]>
1. MisraC++2023-8.1.1 [required]: _transport.cpp:286 This variable shall
 not be implicitly captured in a lambda expression.; Field: []
2. MisraC++2023-8.2.3 [required]: _transport.cpp:50
 Cast removes const qualification; Field: [const char*->char*]

Signed-off-by: Michael Orlov <[email protected]>
- Rationale: Need to use in another package
- Added timeout parameter for the wait_for_playback_to_start(..) to make
it non-blocking call optionally and return boolean value.

Signed-off-by: Michael Orlov <[email protected]>
- Use custom deleter when releasing rcl serialized buffer to a shared
pointer.

Signed-off-by: Michael Orlov <[email protected]>
- The Player::play_next() should return false right away if for some
reason failed to publish current message.

Signed-off-by: Michael Orlov <[email protected]>
- Also added `play_next_returns_false_if_pre_callback_throw_exception`
unit test.

Signed-off-by: Michael Orlov <[email protected]>
- Also add missing `include <unordered_set>`

Signed-off-by: Michael Orlov <[email protected]>
@MichaelOrlov MichaelOrlov force-pushed the morlov/upstream_quality_changes_from_apex_ai branch from 6bcb7be to f4f1104 Compare February 5, 2025 02:05
@MichaelOrlov
Copy link
Contributor Author

@christophebedard Could you please give a one more round of review?
I've addressed review comments and also added a few more fixes

  1. Call discovery_future_.get() if it's ready in the stop_discovery()
  2. Use absolute path instead of relative path in the InfoEndToEndTestFixture
  3. Don't keep trying to publish the next message if we fail the first time. The Player::play_next() should return false right away if, for some reason, failed to publish the current message.

Copy link
Member

@christophebedard christophebedard left a comment

Choose a reason for hiding this comment

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

If you really want to proceed as-is with the wait_for_playback_to_start() docs, this looks good to me with green CI.

@MichaelOrlov
Copy link
Contributor Author

Pulls: #1903
Gist: https://gist.githubusercontent.com/MichaelOrlov/09606b1727cd650b8ad81063eca5060f/raw/2aab4e80b4711be3bfd625549652c96db827c46d/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_transport rosbag2_py rosbag2_storage_mcap rosbag2_test_common rosbag2_tests
TEST args: --packages-above rosbag2_transport rosbag2_py rosbag2_storage_mcap rosbag2_test_common rosbag2_tests
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15128

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

@MichaelOrlov
Copy link
Contributor Author

@christophebedard Thank you for review.

@MichaelOrlov MichaelOrlov merged commit 871a447 into rolling Feb 6, 2025
12 checks passed
@MichaelOrlov MichaelOrlov deleted the morlov/upstream_quality_changes_from_apex_ai branch February 6, 2025 21:06
@MichaelOrlov
Copy link
Contributor Author

https://github.com/Mergifyio backport jazzy

Copy link

mergify bot commented Feb 6, 2025

backport jazzy

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Feb 6, 2025
* Make sure to start with clean subscriptions list in Recorder::record()

- It could be some residual subscriptions in list in case if previous
call to Recorder::record() failed for some reason and Recorder::stop()
wasn't called.

Signed-off-by: Michael Orlov <[email protected]>

* Fix clang16 warning that timestamp comparator is not initialized

Signed-off-by: Michael Orlov <[email protected]>

* Address Axivion warnings in rosbag2_py

1. MisraC++2023-8.1.1 [required]: _transport.cpp:286 This variable shall
 not be implicitly captured in a lambda expression.; Field: []
2. MisraC++2023-8.2.3 [required]: _transport.cpp:50
 Cast removes const qualification; Field: [const char*->char*]

Signed-off-by: Michael Orlov <[email protected]>

* Gracefully handle exceptions from on-play callbacks in player

Signed-off-by: Michael Orlov <[email protected]>

* Move wait_for_playback_to_start() to public section

- Rationale: Need to use in another package
- Added timeout parameter for the wait_for_playback_to_start(..) to make
it non-blocking call optionally and return boolean value.

Signed-off-by: Michael Orlov <[email protected]>

* Fix memory leaks in tests

- Use custom deleter when releasing rcl serialized buffer to a shared
pointer.

Signed-off-by: Michael Orlov <[email protected]>

* Don't keep trying to publish next message if we failed first time

- The Player::play_next() should return false right away if for some
reason failed to publish current message.

Signed-off-by: Michael Orlov <[email protected]>

* Wrap run_play_msg_pre_callbacks(message) in its own try-catch

- Also added `play_next_returns_false_if_pre_callback_throw_exception`
unit test.

Signed-off-by: Michael Orlov <[email protected]>

* Use absolute path instead of relative path in the InfoEndToEndTestFixture

Signed-off-by: Michael Orlov <[email protected]>

* Call discovery_future_.get() if it's ready in the `stop_discovery()`

- Also add missing `include <unordered_set>`

Signed-off-by: Michael Orlov <[email protected]>

* Move wait_for_playback_to_start(..) declaration and fixed wording

Signed-off-by: Michael Orlov <[email protected]>

---------

Signed-off-by: Michael Orlov <[email protected]>
(cherry picked from commit 871a447)

# Conflicts:
#	rosbag2_transport/src/rosbag2_transport/player.cpp
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.

3 participants