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

avoid mapping memory and comparing joints with zero variables #519

Closed
wants to merge 1 commit into from

Conversation

marioprats
Copy link
Contributor

Calling getJointPositions() on a joint model with zero variables is buggy on the MoveIt side. It will return a meaningless value most of the time, but can access out of bounds memory in some edge cases (fixed joints at the end of a robot model).
This had been okay until now because RobotState had big chunk of memory accessed via raw pointers, so out of bounds memory access was silently happening. RobotState now uses std::vector internally for data allocation, which means that any out-of-bounds access will now trigger an exception.
We should fix the getJointPositions() (and others) behavior in MoveIt (follow up PR), but this change won't hurt anyway because there is no need to Eigen::Map and compare zero-sized memory.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d6af5d2) 42.42% compared to head (5638733) 42.39%.
Report is 1 commits behind head on ros2.

Additional details and impacted files
@@            Coverage Diff             @@
##             ros2     #519      +/-   ##
==========================================
- Coverage   42.42%   42.39%   -0.02%     
==========================================
  Files          83       83              
  Lines        8045     8047       +2     
==========================================
- Hits         3412     3411       -1     
- Misses       4633     4636       +3     

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

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.

While adding this check doesn't harm, it shouldn't be necessary as well. Both, creating and mapping zero-length vectors is fine with Eigen: https://godbolt.org/z/xKEK9ccT9

@marioprats
Copy link
Contributor Author

This should fix the underlying issue in MoveIt:
moveit/moveit2#2617

@rhaschke
Copy link
Contributor

Closing as this is a MoveIt2 core issue.

@rhaschke rhaschke closed this Dec 18, 2023
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