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

Fix crash if MoveIt Servo collision check is disabled #568

Merged

Conversation

schornakj
Copy link
Contributor

@schornakj schornakj commented Jul 23, 2021

Description

If the Servo collision check parameter is set to false, CollisionCheck's rclcpp::TimerBase::SharedPtr timer_ member is never initialized. Since ~CollisionCheck() calls timer_->cancel(), requesting that Servo start if collision checking was not enabled causes a crash.

This fixes the crash by checking if timer_ was actually set before trying to cancel it.

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

@codecov
Copy link

codecov bot commented Jul 23, 2021

Codecov Report

Merging #568 (755b321) into main (faee9a4) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
- Coverage   46.73%   46.71%   -0.01%     
==========================================
  Files         184      184              
  Lines       19685    19686       +1     
==========================================
- Hits         9198     9195       -3     
- Misses      10487    10491       +4     
Impacted Files Coverage Δ
...oveit_servo/include/moveit_servo/collision_check.h 0.00% <0.00%> (ø)
...dl_kinematics_plugin/src/kdl_kinematics_plugin.cpp 74.72% <0.00%> (-1.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faee9a4...755b321. Read the comment docs.

Copy link
Contributor

@jliukkonen jliukkonen left a comment

Choose a reason for hiding this comment

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

Why is the timer shared_ptr in the first place? In MoveIt1 it is just ros::Timer. This will fix the problem but I think the fix could also be unifying the timer initialization to match the MoveIt1.

@schornakj
Copy link
Contributor Author

Why is the timer shared_ptr in the first place? In MoveIt1 it is just ros::Timer. This will fix the problem but I think the fix could also be unifying the timer initialization to match the MoveIt1.

In ROS1, the NodeHandle's createTimer function only returns a ros::Timer. The equivalent function in ROS2 is Node's create_wall_timer, which only returns a shared_ptr. ROS2 made a deliberate decision to interact with publishers, subscribers, timers, etc. through shared_ptrs, and while the rationale behind that is still debatable (unique_ptr would be preferable in many cases) that's the approach which is favored by the API.

Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

Thanks! Good catch.

@AndyZe AndyZe merged commit 64535cb into moveit:main Jul 26, 2021
christianlandgraf pushed a commit to christianlandgraf/moveit2 that referenced this pull request Aug 12, 2021
tylerjw pushed a commit to tylerjw/moveit2 that referenced this pull request Aug 27, 2021
MikeWrock pushed a commit to MikeWrock/moveit2 that referenced this pull request Aug 15, 2022
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