-
Notifications
You must be signed in to change notification settings - Fork 938
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
OMPL Constrained State Space Planning #2273
base: master
Are you sure you want to change the base?
Conversation
The commitsThis branch of a cleaned up version of my original development attempts. (See the v5 in the name :), it took me a while to get it right.) Add new state space 7b84591 This commit adds an extra type of state space, besides the current JointModelStateSpace and PoseModelStateSpace. The state space is called ConstrainedPlanningStateSpace, as in "use this state space for constrained planning". Not to be confused with an ConstrainedPlanningStateSpace overrides the virtual methods to copy states from OMPL to MoveIt and vice-versa. It is necessary because in many places the state space is used to determine how to copy states. (Like this: Add new state validity checker for ompl constrained planning a620442 The state validity checker operates on raw Path constraints are still checked in this new state validity checker as not all states samled by the constrained state space satisfy the constraints, unfortunately. See this comment for more details. Add ompl position constraints model 146e5a2 To integrate OMPL's constrained state space, we need a model of the constraints that inherits from ompl::base::Constraint. In general, this can be any equality constraint. However, many interesting constraints are not equality constraints (==), but inequality constraints (< >). This pull request provides a base class A specialization of the position constraints, called This pull request does not include orientation constraints yet. There are many unresolved issues with them. See the project issue for the full history. Integrate new constrained planner with existing interface 26fffab Add test for planning context manager I split this test in a separate commit because it introduces a rostest dependency in this package. This test is an extended version of #2248. Miscellaneous
As the pull request contains many changes, I think it will be useful to discuss each commits separately. Status list of reviewed commits:
|
The
I suspect this is because kinetic is using a version of OMPL from before this commit. |
4e3396d
to
5ae4b43
Compare
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.
I haven't even gotten halfway through skimming this. Just dropping some typo/style comments.
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
...oveit/ompl_interface/parameterization/joint_space/constrained_planning_state_space_factory.h
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/src/detail/ompl_constraints.cpp
Outdated
Show resolved
Hide resolved
std::size_t num_ori_con = constraints.orientation_constraints.size(); | ||
|
||
// Only positions constraints are actually created below. | ||
// All the other code is just given feedback to the user. |
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.
?
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.
The whole factory method is a template code to support different constraints, but only a single option is actually returns a non-nullptr at the moment (position constraints). All the other cases spit out warnings or errors.
I guess I can remove all the unnecessary template code and only add it when needed, I never though about that.
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.
Oh. "just giving feedback"? I was having trouble parsing the sentence.
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.
I updated the comment and left the rest of the function as is. I feel it is pretty clear with the log messages and allows for easy integration of orientation constraints and a combination of position and orientation constraints in the future.
Now the comment reads:
// The factory method contains template code to support different constraints, but only position constraints are
// currently supported. The other options return a nullptr for now and should not be used.
moveit_planners/ompl/ompl_interface/src/detail/state_validity_checker.cpp
Outdated
Show resolved
Hide resolved
return ompl_state->as<ompl_interface::ConstrainedPlanningStateSpace::StateType>()->values + index; | ||
|
||
// (jeroendm) left in the debug code, because it is not unlikely that issues will arise here when adding new things in | ||
// the future. Use dynamic casting to make our debugging live easier. |
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.
You can also link to a writeup with debugging instructions instead
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.
Good idea, it is a bit ugly to leave this in.
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.
I replaced the long comment with: // Developer tip: replace this with a dynamic_cast for debugging
. As for debugging instructions, I think it will be useful if I write a good description of all these details in a central place somewhere. But I need to come up with a good format and a good place to put it. Maybe the MoveIt concepts page on the website?
19d1ab0
to
ad0aa16
Compare
@felixvd Thank you for the review! I addressed most of the small comments and fixes. I left some comments unresolved as I added a change that does not necessarily reflect you're proposed change but still resolves it in a reasonable way I think. |
I hope I can get back to it soon, I didn't get even get through half! |
Yeah, it's a lot. I still think my original approach to split the pull request into smaller parts was easier to review. But it's difficult to keep everything organized that way. Anyway, I would ignore the test code for now and focus on the functional code. (Although the tests can serve a bit as documentation.) edit but to end on a more encouraging note: my code does not touch much of the existing functionality, so merging this should be very possible! |
Is this problem present also in Moveit2? |
@lorepieri8 Yes. As far as I know, MoveIt2 uses exactly the same OMPL interface code as MoveIt1. |
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.
Looking good, Jeroen! I have made several small suggestions. The only one that might be a bit more work is the one related to refactoring the Bounds class.
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
...t_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/state_validity_checker.h
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/src/model_based_planning_context.cpp
Outdated
Show resolved
Hide resolved
@mamoll thank you for the detailed review! I'll do my best to find some time in the coming weeks to move this forward. |
I created a public Trello board to follow progress on this. Hopefully, this planning helps me to spend the little time I have to work on this effectively. |
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.
I left some comments through this. I didn't test running it as I didn't have time and don't know where to begin to do that. Most of my comments are just C++ stuff that should be easy enough to address. Thank you again for doing this, I look forward to getting this merged and seeing it work.
...rs/ompl/ompl_interface/src/parameterization/joint_space/constrained_planning_state_space.cpp
Show resolved
Hide resolved
...rs/ompl/ompl_interface/src/parameterization/joint_space/constrained_planning_state_space.cpp
Outdated
Show resolved
Hide resolved
...rs/ompl/ompl_interface/src/parameterization/joint_space/constrained_planning_state_space.cpp
Show resolved
Hide resolved
...rs/ompl/ompl_interface/src/parameterization/joint_space/constrained_planning_state_space.cpp
Show resolved
Hide resolved
...ompl_interface/src/parameterization/joint_space/constrained_planning_state_space_factory.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_constrained_state_validity_checker.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.test
Outdated
Show resolved
Hide resolved
I just did the scariest rebase so far :) Now I can continue with addressing the review comments. The biggest chunk left is refactoring the bounds class. Also, there are some smaller things that I can clean up in the tests based on the feedback on my other pull requests that got merged recently. |
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/ompl_constraints.h
Outdated
Show resolved
Hide resolved
Update I am slowly working my way through the review comments and the |
8e314ff
to
d336e43
Compare
@mamoll The bound refactor is done. There is still some less ideal code with many temporary objects: void BaseConstraint::jacobian(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
Eigen::Ref<Eigen::MatrixXd> out) const
{
Eigen::VectorXd constraint_error = calcError(joint_values);
Eigen::VectorXd constraint_derivative = bounds_.derivative(constraint_error);
Eigen::MatrixXd robot_jacobian = calcErrorJacobian(joint_values);
for (std::size_t i{ 0 }; i < bounds_.size(); ++i)
{
out.row(i) = constraint_derivative[i] * robot_jacobian.row(i);
}
} The loop could potentially be replaced with Eigen magic, but I'm not sure it's worth it performance or readability wise. |
I looked a bit at the moveit2 PR, the core functionalities (/ompl_interface*) are just copied with some small modification. I feel like most of the changes are just related to the port to ROS2, changing namespaces. Also clang was run which makes the PR much bigger than this one. The only visible review/modifications/bugfixes are also mostly ROS2 specific, e.g. moveit/moveit2#347 (review). I did not check what was done with the tests and the demos though. What is your opinion @JeroenDM , especially on the tests? Would be nice to have thoughts of @bostoncleek on this also. Were there any bug fixes independent from the ROS2 migration? |
I'm sorry I have so little time and did not really add anything useful in the maintainer meeting. But if @gautz analysis is correct
and given that backporting from moveit2 to moveit1 does not seem hassle-free anyway, I cannot see major disadvantages in merging this PR instead of someone trying to backport the moveit2 one. That is, given that I fix this recent issue that should have been an innocent merge conflict fix. I will look into this tomorrow. |
@JeroenDM could you check the tests and the demos from the MoveIt2 PR to see if there are important things we should backport to this PR? |
@JeroenDM @gautz |
The last idea from MoveIt maintainers was to backport the MoveIt2 PR. Which I did not agree (see previous message):
So remaining ToDos may be:
But my general feeling was that no MoveIt1 maintainer has time to work on this.
|
I believe there is nothing to see "from the inside" of the maintainer group that you can't see in the issues.
It would be great to see this feature working in MoveIt out of the box and I agree that backporting the MoveIt2 PR is not a good idea as multiple people stated it was merged prematurely.
I don't have a concrete use-case for this myself at the moment and it is too involved to look into it on the side. This seems to be the case for other maintainers as well.
Any work towards merging and/or improving these features is very welcome!
|
this was a gsoc project already. thus I do not consider this as a viable candidate unless the scope is significant extended. |
we have this issue in our Fetch robot. Screencast.2022-10-13.20.38.42.mp4 |
e1b0ec1
to
fdc3b1c
Compare
* Replaced boost::algorithm::join with fmt::join * Made changes in CMakeLists.txt to accomodate fmt * Updated package.xml files * removed redundant boost dependencies * Rename variables -> variable --------- Co-authored-by: Sebastian Castro <4603398+sea-bass@users.noreply.github.com> Co-authored-by: Sebastian Jahr <sebastian.jahr@picknik.ai>
Description
In the context of a Google Summer of Code project, I would like to add the constrained planning capabilities of OMPL to the existing interface. Previously, I split up the code in several pull requests. This was not entirely clear and impractical for testing. Hence this new approach, a single pull request that can be reviewed on a per commit basis.
Edit this pull request is quite large, but can be made smaller by first merging these tests separately:
Why
It is one of the projects on the future projects page.
It can solve the long-standing joint flip bug when planning with path constraints. It is especially useful in cases where the constrained region has zero volume in Cartesian space and the
enforce_joint_model_state_space
(rejection sampling) does not work. For example planning with the end-effector constrained to a plane:Or a line:
The current default planner that uses the
PoseModelStateSpace
can solve these problems, but the solution will often contain large jumps in joint space because it plans in Cartesian space. (Especially when adding obstacles in the scene.) This new planner plans in joint space. The example below illustrates the difference.With the default
PoseModelStateSpace
:With OMPL's
ConstrainedStateSpace
:Finally (and maybe most importantly) once this new planning approach is integrated, the possibilities for adding new constraints are endless. It would be really nice if we could pass arbitrary user-defined constraints to OMPL through some C++ interface in the future.
Checklist