Skip to content

Check rclcpp::ok before sleeping for clean shutdown #3484

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

Merged
merged 2 commits into from
May 28, 2025

Conversation

MarqRazz
Copy link
Contributor

@MarqRazz MarqRazz commented May 28, 2025

Description

In MTC PR#684 I found move_group fails to shut down cleanly when preempting motion. This is because we are asking the node to sleep when the stack has been requested to shut down. To fix this I added a simple guard to make sure rclcpp::ok() before sleeping.

Here is a snippet of the stack trace when shutting down.

[move_group-5] #10   Source "/root/my_ws/src/moveit2/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp", line 549, in scenePublishingThread [0x7d8db9c1afaf]
[move_group-5]         546:       planning_scene_publisher_->publish(msg);
[move_group-5]         547:       if (is_full)
[move_group-5]         548:         RCLCPP_DEBUG(logger_, "Published full planning scene: '%s'", msg.name.c_str());
[move_group-5]       > 549:       rate.sleep();
[move_group-5]         550:     }
[move_group-5] #9    Object "/opt/ros/jazzy/lib/librclcpp.so", at 0x7d8db914c480, in rclcpp::Rate::sleep()
[move_group-5] #8    Object "/opt/ros/jazzy/lib/librclcpp.so", at 0x7d8db90a0238, in rclcpp::Clock::sleep_for(rclcpp::Duration, std::shared_ptr<rclcpp::Context>)

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

Copy link

codecov bot commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.24%. Comparing base (7907501) to head (d178050).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3484      +/-   ##
==========================================
+ Coverage   45.84%   46.24%   +0.40%     
==========================================
  Files         718      718              
  Lines       62668    62690      +22     
  Branches     7587     7589       +2     
==========================================
+ Hits        28727    28985     +258     
+ Misses      33774    33538     -236     
  Partials      167      167              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

Is this a new issue, i.e. a regression in rclcpp? If so, that should be reported upstream.

…monitor.cpp

Co-authored-by: Robert Haschke <rhaschke@users.noreply.github.com>
@rhaschke rhaschke merged commit f4cf780 into moveit:main May 28, 2025
9 of 10 checks passed
@github-project-automation github-project-automation bot moved this to ✅ Done in MoveIt May 28, 2025
@MarqRazz MarqRazz added backport-humble Mergify label that triggers a PR backport to Humble backport-jazzy Mergify label that triggers a PR backport to Jazzy labels May 28, 2025
mergify bot pushed a commit that referenced this pull request May 28, 2025
Calling rate.sleep() on shutdown will crash

(cherry picked from commit f4cf780)

# Conflicts:
#	moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp
mergify bot pushed a commit that referenced this pull request May 28, 2025
Calling rate.sleep() on shutdown will crash

(cherry picked from commit f4cf780)
@MarqRazz MarqRazz deleted the clean_shutdown branch May 28, 2025 19:20
valmikikothare added a commit to valmikikothare/moveit2 that referenced this pull request May 28, 2025
PSM: finish thread on rclcpp::shutdown (moveit#3484) (moveit#3486)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble Mergify label that triggers a PR backport to Humble backport-jazzy Mergify label that triggers a PR backport to Jazzy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants