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

Add assertion mechanism If shape is invalid #2340

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

berkealgul
Copy link

Description

Based on suggestion of @henningkayser in #2244 I continued @sjahr 's work

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
Contributor

@sjahr sjahr left a 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)
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link

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.

@github-actions github-actions bot added the stale Inactive issues and PRs are marked as stale and may be closed automatically. label Nov 16, 2023
@github-actions github-actions bot removed the stale Inactive issues and PRs are marked as stale and may be closed automatically. label Dec 3, 2024
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.

2 participants