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

Replace PlanSolution with MotionPlanResponse #1542

Closed
wants to merge 3 commits into from

Conversation

sjahr
Copy link
Contributor

@sjahr sjahr commented Aug 29, 2022

Description

This PR breaks the moveit_cpp API!

Two small additions for PlanningComponent.
Replace PlanSolution with MotionPlanResponse since both contain the same data.

Related PR: moveit2_tutorials#515 should be merged right after this PR to prevent the tutorials from bracking

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-small_moveit_cpp_improvements branch from 4ecb6c2 to b1cac10 Compare August 29, 2022 08:20
@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@5213ceb). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1542   +/-   ##
=======================================
  Coverage        ?   51.08%           
=======================================
  Files           ?      381           
  Lines           ?    31727           
  Branches        ?        0           
=======================================
  Hits            ?    16203           
  Misses          ?    15524           
  Partials        ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sjahr sjahr force-pushed the pr-small_moveit_cpp_improvements branch from 666411d to 3e54058 Compare August 31, 2022 11:46
Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

I'm fine with these changes. Keep in mind that we are planning to simplify this class a lot, as most of it would be better implemented by a state-less MotionPlanRequest builder

moveit_ros/planning/moveit_cpp/src/planning_component.cpp Outdated Show resolved Hide resolved
@sjahr sjahr mentioned this pull request Sep 8, 2022
6 tasks
@sjahr sjahr force-pushed the pr-small_moveit_cpp_improvements branch from 3e54058 to 32fad11 Compare September 18, 2022 19:53
@sjahr sjahr changed the title Add setTrajectoryConstraints() to PlanningComponent and add planning time to PlanningSolution Replace PlanSolution with MotionPlanResponse Sep 19, 2022
double planning_time_;
moveit_msgs::msg::MoveItErrorCodes error_code_;
// Result status of the query
moveit::core::MoveItErrorCode error_code_;
Copy link
Member

Choose a reason for hiding this comment

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

This change is not consistent with MotionPlanDetailedResponse. Whatever you change here should be reflected in the other struct as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add it there as well 👍

Copy link
Contributor Author

@sjahr sjahr Sep 28, 2022

Choose a reason for hiding this comment

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

@henningkayser What do you think about using inheritance

struct MotionPlanDetailedResponse : public MotionPlanResponse
{
  // Make this a free function for both classes
  // void getMessage(moveit_msgs::msg::MotionPlanDetailedResponse& msg) const; 

  std::vector<std::string> description_;
  std::vector<double> processing_time_;
};

or aggregation here?

struct MotionPlanDetailedResponse
{
   void getMessage(moveit_msgs::msg::MotionPlanDetailedResponse& msg) const; 

  MotionPlanResponse response;
  std::vector<std::string> description_;
  std::vector<double> processing_time_;
};

I think both would avoid changing the other if one changes in the future. Or to remove MotionPlanDetailedResponse completely and make processing time and description std::optional

Copy link
Member

Choose a reason for hiding this comment

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

well, this got stale... I think neither option is applicable, the detailed response includes a vector of trajectories.

Copy link
Contributor Author

@sjahr sjahr Oct 25, 2022

Choose a reason for hiding this comment

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

I see, why is it a vector of trajectories anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The message definition states

# Multiple solution paths are reported, each reflecting intermediate steps in the trajectory processing

# The list of reported trajectories

But is that used anywhere/ how is it interpretable when the response is just a vector of unlabeled trajectories?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it's being used anywhere, but my understanding is that the trajectories show you the result for each step in the process. For instance, you should be able to compare the raw planner solution with the smoothed output.

// Enable checking of query success or failure, for example if(response) ...
explicit operator bool() const
{
return bool(error_code_);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is going to work. If error_code_ is negative, like int32 PLANNING_FAILED=-1, it will cast to true.

int32 SUCCESS=1 also casts to true.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return bool(error_code_);
return error_code_ == moveit::core::MoveItErrorCode::SUCCESS;

Copy link
Member

Choose a reason for hiding this comment

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

This is not the error code value. It's using the MoveItErrorCode type which is convertible to bool. See https://github.com/ros-planning/moveit2/blob/main/moveit_core/utils/include/moveit/utils/moveit_error_code.h#L62

Copy link
Member

Choose a reason for hiding this comment

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

I suggested to use the same in your PR. #1605 (comment)

@tylerjw tylerjw force-pushed the pr-small_moveit_cpp_improvements branch from 32fad11 to d351118 Compare November 1, 2022 17:15
@sjahr
Copy link
Contributor Author

sjahr commented Nov 3, 2022

I'll close this PR since it is also included in #1420 and additional addressed reviews are included there

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

3 participants