-
Notifications
You must be signed in to change notification settings - Fork 545
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
Add assertion mechanism If shape is invalid #2340
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution! I like the idea behind these changes but there are a couple of chance I'd like to request
@@ -390,6 +390,15 @@ bool PositionConstraint::configure(const moveit_msgs::msg::PositionConstraint& p | |||
std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.primitives[i])); | |||
if (shape) | |||
{ | |||
for(std::size_t j = 0; i < pc.constraint_region.primitives[i].dimensions.size(); ++j) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you transform this into a range-based for loop if possible?
@@ -798,6 +798,18 @@ class MOVEIT_PLANNING_SCENE_EXPORT PlanningScene : public std::enable_shared_fro | |||
return motion_feasibility_; | |||
} | |||
|
|||
/** \brief Check if a given shape is valid to prevent segmentation fault at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be free functions
auto treat_shape_vectors = [&append](const auto& shape_vector, // the shape_msgs of each type | ||
const auto& shape_poses_vector, // std::vector<const geometry_msgs::Pose> | ||
const std::string& shape_type) { | ||
auto treat_shape_vectors = [&append, this](const auto& shape_vector, // the shape_msgs of each type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd make isShapeValid
a free function you wouldn't need to pass this this pointer
@@ -2040,6 +2048,25 @@ bool PlanningScene::isStateColliding(const std::string& group, bool verbose) | |||
} | |||
} | |||
|
|||
bool PlanningScene::isShapeValid(const shape_msgs::msg::SolidPrimitive& shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you somehow merge these three functions into one, for example as a template? Having functions that just return true is a bit ugly
@@ -390,6 +390,15 @@ bool PositionConstraint::configure(const moveit_msgs::msg::PositionConstraint& p | |||
std::unique_ptr<shapes::Shape> shape(shapes::constructShapeFromMsg(pc.constraint_region.primitives[i])); | |||
if (shape) | |||
{ | |||
for(std::size_t j = 0; i < pc.constraint_region.primitives[i].dimensions.size(); ++j) | |||
{ | |||
if(pc.constraint_region.primitives[i].dimensions[j] <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If ranged-based loops are not possible, you should prefer .at(x)
instead of [x]
for vectors
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
Description
Based on suggestion of @henningkayser in #2244 I continued @sjahr 's work
Checklist