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

Constraints Library Refactor #1428

Merged

Conversation

BryceStevenWilley
Copy link
Contributor

@BryceStevenWilley BryceStevenWilley commented Apr 8, 2019

Continuation of #897 in smaller bits, starting with the constraint library.

In order to make an OMPL plugin framework, the ModelBasedPlanningContext (MBPC) has to be able to be initialized by a plugin (i.e. we can no longer directly pass it the OMPL state space, simple setup, etc.), meaning that the leaky interface between the MBPC and the OMPLPlannerManager needs to be cleaned up, starting with the constraints library.

This change moves the constraints library internal to the MBPC, so it can separately load the constraint library and add its interpolation function to the OMPL state space being used.

Additionally, this removes an unused OMPL service, as mentioned here.

Much of the documentation/tutorial updates will happen later, as there are still many changes to come including:

  • Moving the rest of the OMPL initialization to the MBPC
  • Making an OMPLPlanningContext abstract class and making separate ModelBased, JointBased, and PoseBased planning contexts.
  • Adding the actual pluginlib loading

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Testing: @v4hn I can't quite figure out how to generate constraints to test this change; would you mind trying this PR to make sure it doesn't break anything for you?
  • Should this be cherry-picked to https://github.com/ros-planning/moveit2? Or should we wait for all of the OMPL plugin-related changes to be in ROS 1 before moving over?

@BryceStevenWilley BryceStevenWilley changed the title WIP: Constraints Library Refactor. Constraints Library Refactor. Apr 9, 2019
@BryceStevenWilley BryceStevenWilley changed the title Constraints Library Refactor. Constraints Library Refactor Apr 9, 2019
@BryceStevenWilley BryceStevenWilley marked this pull request as ready for review April 9, 2019 02:11
@BryceStevenWilley
Copy link
Contributor Author

Fun fact: the new draft PR feature (https://help.github.com/en/articles/about-pull-requests#draft-pull-requests) apparently doesn't trigger Travis or notify CODEOWNERS when it's marked as ready. Sorry about that.

@BryceStevenWilley
Copy link
Contributor Author

Friendly ping (not sure if email notifications got sent out at all) @davetcoleman @v4hn

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 tested this with the current panda setup and a simple orientation constraint (gripper downwards).
Normal planning seems to work fine in general. I noticed that sometimes plans are also generated if the start state does not satisfy the constraints. Looking at the changes I'm not sure if this is a new issue.
Also constructing constraints does not work for me. Even after filling the MotionPlanRequest parameters (inside generate_state_database.cpp) the ConstraintsLibrary always crashes with a segfault.

@BryceStevenWilley
Copy link
Contributor Author

Thanks for the feedback @henningkayser. How did you go about trying to generate the Constraints library? I didn't see it documented anywhere, and haven't had the time to dive into what format the constraints parameter to generate_state_database.cpp needs to be to test things.

Copy link
Contributor

@v4hn v4hn left a comment

Choose a reason for hiding this comment

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

Given your goal to isolate the MBPC structure, this seems reasonable.
At least it is somewhat cleaner than the previous implementation. :-)

I didn't see it documented anywhere, and haven't had the time to dive into what format the constraints parameter to generate_state_database.cpp needs to be to test things.

Yes, that's my fault. :-/
I did not manage to write the tutorial (until now?) due to time constraints.
Dave scolded me for that before...
There are rather verbose commit messages though with a full example. :)
783cf74 3fc0789

I can't approve this because I did not have the time to test it.
I hope you and @henningkayser get around to fix this up in the close future.

ompl_interface.getConstraintsLibrary().addConstraintApproximation(params.constraints, params.planning_group,
scene, params.construction_opts);
context->getConstraintsLibrary()->addConstraintApproximation(params.constraints, params.planning_group, scene,
params.construction_opts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifying the constraints, planning group and scene here again feels weird when the context could/should already know them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair, but I can't see another way to pass those along to the constraints library without some weird state being used behind the scenes.

@BryceStevenWilley
Copy link
Contributor Author

@v4hn Thanks for pointing out the commit messages! Those are just enough, I had just never thought to look there. :)

Copy link
Member

@davetcoleman davetcoleman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!!

@davetcoleman
Copy link
Member

@ommmid has been creating a new PlanningContext plugin for TrajOpt + MoveIt, and would make a good reviewer for this PR.

@davetcoleman davetcoleman requested a review from ommmid July 3, 2019 00:19
@davetcoleman
Copy link
Member

ping @BryceStevenWilley could you address my requested changes?

@BryceStevenWilley
Copy link
Contributor Author

Thanks for the ping Dave, this has been on my plate for a while, but I think I can address your comments by this weekend.

@BryceStevenWilley
Copy link
Contributor Author

Don't have access to a machine that can build MoveIt right now, will probably need another few days to test.

@BryceStevenWilley
Copy link
Contributor Author

Sorry for the wait, finally had time to test and finish up the generate state database script. Also added some of @v4hn's comments from commits into actual launch files and in code comments.

@davetcoleman
Copy link
Member

@henningkayser could you give this a second review?

fyi @mamoll

@BryceStevenWilley BryceStevenWilley added the awaits 2nd review one maintainer approved this request label Sep 16, 2019

const PlanningContextManager& context_manager_;
ModelBasedPlanningContext* context_;
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that context_ can't be const, but why can't it be a reference rather than a raw pointer? Why not use a shared_ptr if a reference is not possible?

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 believe because we are now constructing the constraints library from inside the ModelBasedPlanningContext, with a call to this (a9e91ab#diff-d949b241fc2b4781b617fdb53844ece5R85). Since this is naturally a raw pointer, I just kept it like that, and am a little hesitant to try to convert this to a reference or a shared pointer.

@mamoll mamoll self-requested a review November 20, 2019 18:07
@BryceStevenWilley BryceStevenWilley removed the awaits 2nd review one maintainer approved this request label Nov 20, 2019
@BryceStevenWilley
Copy link
Contributor Author

Passing Travis, and 2 reviews, in it goes!

@BryceStevenWilley BryceStevenWilley merged commit cd202ab into moveit:master Nov 20, 2019
@BryceStevenWilley BryceStevenWilley deleted the ompl_plugin_interface branch November 20, 2019 20:39
@mlautman
Copy link
Contributor

I believe this PR introduced regressions.

Loading a constraint database now results in

ros.moveit_core.planning_request_adapter: Exception caught executing *final* adapter 'Fix Start State Path Constraints': Character [-] at element [10] is not valid in Graph Resource Name [/home/mike-picknik/.../cadb].  Valid characters are a-z, A-Z, 0-9, / and _.

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.

6 participants