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

Cleanup planning request adapter interface #2266

Merged

Conversation

sjahr
Copy link
Contributor

@sjahr sjahr commented Jul 13, 2023

Description

Cleans up the planning_request_adapter code and updates param handling to use generate_paramters_library.

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

@sjahr sjahr force-pushed the pr-refactor_planning_request_adapter_interface branch from 38ce711 to ad9ccdc Compare July 13, 2023 16:03
@sjahr sjahr requested a review from henningkayser July 13, 2023 16:32
@codecov
Copy link

codecov bot commented Jul 13, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (cdf7a98) 50.50% compared to head (e1e8360) 50.50%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2266   +/-   ##
=======================================
  Coverage   50.50%   50.50%           
=======================================
  Files         386      386           
  Lines       31732    31732           
=======================================
  Hits        16022    16022           
  Misses      15710    15710           

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

@sjahr sjahr force-pushed the pr-refactor_planning_request_adapter_interface branch from c48bbd6 to e47a152 Compare July 14, 2023 16:35
@sjahr sjahr marked this pull request as ready for review July 14, 2023 16:35
@sjahr sjahr force-pushed the pr-refactor_planning_request_adapter_interface branch from e47a152 to 25531e9 Compare July 18, 2023 08:52
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com>
@sjahr
Copy link
Contributor Author

sjahr commented Jul 18, 2023

@sea-bass Thank you!

moveit_ros/planning/introspection/CMakeLists.txt Outdated Show resolved Hide resolved
const planning_scene::PlanningSceneConstPtr& planning_scene,
const planning_interface::MotionPlanRequest& req,
planning_interface::MotionPlanResponse& res,
std::vector<std::size_t>& added_path_index = EMPTY_PATH_INDEX_VECTOR) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern of passing the default std::vector<std::size_t>& added_path_index = EMPTY_PATH_INDEX_VECTOR isn't making sense to me. It is an out-parameter? If the user doesn't pass their own, does it not mutate the global EMPTY_PATH_INDEX_VECTOR, which surely is not the intent?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also note that clang-tidy CI is complaining about the naming of this and failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My intend with this was to remove these functions:

bool PlanningRequestAdapterChain::adaptAndPlan(const planning_interface::PlannerManagerPtr& planner,
                                               const planning_scene::PlanningSceneConstPtr& planning_scene,
                                               const planning_interface::MotionPlanRequest& req,
                                               planning_interface::MotionPlanResponse& res) const
{
  std::vector<std::size_t> empty_added_path_index;
  return adaptAndPlan(planner, planning_scene, req, res, empty_added_path_index);
}

As far as I understand there are no optional references, so like before we just write the path indices to a memory location we never read and dump them that way. Maybe another possible implementation would be to change this interface to use a pointer but that would be a bigger change. Do you have a smarter idea of how to do this?

Copy link
Member

Choose a reason for hiding this comment

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

can't you just use std::vector<std::size_t>& added_path_index = {}?

Copy link
Contributor

Choose a reason for hiding this comment

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

@henningkayser C++ won't let you assign a default reference like that.

@sjahr I guess this pattern will technically work as long as adaptAndPlan makes sure to clear the "empty" vector before it starts every time. Otherwise it's a memory leak!

Copy link
Member

@henningkayser henningkayser Jul 27, 2023

Choose a reason for hiding this comment

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

oh of course not... content-wise, this parameter would fit into the MotionPlanResponse as well, or at least the detailed response. I wouldn't sweat it too much since we should take another close look at this interface anyway.

@sjahr sjahr requested a review from kylc July 25, 2023 19:29
Copy link
Contributor

@kylc kylc left a comment

Choose a reason for hiding this comment

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

Approved pending 1 remaining comment above.

@sjahr sjahr merged commit 830ceda into moveit:main Jul 27, 2023
8 checks passed
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.

4 participants