-
Notifications
You must be signed in to change notification settings - Fork 953
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
moveit_commander.MoveGroupInterface plan() to better align with C++ MoveGroup::plan() #790
moveit_commander.MoveGroupInterface plan() to better align with C++ MoveGroup::plan() #790
Conversation
|
4900174
to
e70ecd1
Compare
I updated my comment above to account for your changes. |
Didn't we just remove the bool casting from MoveItErrorCodes recently? |
We removed implicit bool casts. In that case we had to tell users to change
With this PR we would have to tell them to change |
The current Python API only returns a |
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 generally approve this. I don't share the concerns of @v4hn who asked to introduce a bool cast. This is not neccessary in python, where you simply write
err, trajectory, time = plan()
plan = RobotTrajectory() | ||
plan.deserialize(self._g.compute_plan()) | ||
return plan | ||
return (error_code.val == MoveItErrorCodes.SUCCESS, |
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.
Please update the doc string of this function to reflect the new return value.
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.
Done!
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.
While I like the idea to match the C++ interface, this change essentially changes API of the plan()
function in Python.
Do we want to accept this for Melodic as well? Or should this be limited to the master branch? Please also add a note to MIGRATION.md
.
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 received the very same comment from a year ago where it was proposed to only add it to Lunar, not Kinetic.
I think it's ok to put this on melodic too.
plan = RobotTrajectory() | ||
plan.deserialize(self._g.compute_plan()) |
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.
compute_plan()
isn't used anywhere else. Why do you introduce a new function plan()
/ planPython
in the wrapper? Wouldn't it make sense to replace or deprecate the old function?
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'm using plan
to reflect the MoveGroupInterface
better.
MoveItErrorCode plan(Plan& plan)
I can remove compute_plan
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.
Please do so. Am I correct, that these names are internal only?
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.
So internal, some of them - including compute_plan()
- only exist as a string in the wrapping rules.
@bmagyar Please fix clang-format issues. |
71e0569
to
534a473
Compare
Sorry about the rebase, got a conflict with #788 I had to resolve. |
We have failing tests now. Is that due to the rebase? |
What a pleasant surprise! |
Hm. If |
It is internal only. This test may look familiar to you :) Implementing a unit test of a C++ class through it's Python-wrapper is risky, especially if the wrapping is done on non-standard ways like MoveIt does it. Normally Python wrapping of functions should keep the name and not allow for custom ones to be declared ( |
I've added checking on the error codes too. Unfortunately it's a bit ugly now since these tests are using the raw C++ to Python interface I had to use |
Feel free to modify the test to use the python-only interface. Obviously I was not aware of this interface, when writing the tests... |
Fair enough. It's actually I take back my comments though 👍. |
@bmagyar Do you still plan to adapt the unittest to use the recommended API, not requiring manual deserialization? |
Yes! I am planning to do that next weekend. |
@bmagyar Do you think you could finish this PR and target it to the new master branch? |
@rhaschke yes I can bundle that into this one. I hope it's ok if I only get to this on the weekend |
423e873
to
b809736
Compare
I think this is ready to be merged. @rhaschke I am not getting test failures locally with these changes. I went back to see what we discussed exactly about those tests and I have to say that I think I've changed my mind since then. I think there is justification for any sort of coverage no matter which side of a binding it is. There is a TODO issue I'd like to add to follow this PR up. We should merge the two Python test implementations, |
I'm lost. Could you please add links for the mentioned "back" reference(s).
Could you also provide a (source code) link to this TODO. Or is the paragraph in #790 (comment) describing the todo, i.e. merging |
Sorry for the brevity of that. I was referring to this comments, more specifically to this test. While using
Yes, I meant merging those two files to be added to a TODO. I'm not a big fan of in-code todo-s in general, we have an issue tracker for that :) |
b809736
to
a771fba
Compare
c182fb1
to
6763854
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 do have some final comments. Generally this looks good to me.
@@ -316,10 +317,6 @@ def set_random_target(self): | |||
""" Set a random joint configuration target """ | |||
self._g.set_random_target() | |||
|
|||
def get_named_targets(self): |
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 don't see a reason to remove this. I think it's by mistake.
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.
Correct, I had added it back (in a new commit, the MR should be squashed anyways
plan = RobotTrajectory() | ||
plan.deserialize(self._g.compute_plan()) | ||
return plan | ||
return (error_code.val == MoveItErrorCodes.SUCCESS, |
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.
While I like the idea to match the C++ interface, this change essentially changes API of the plan()
function in Python.
Do we want to accept this for Melodic as well? Or should this be limited to the master branch? Please also add a note to MIGRATION.md
.
moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp
Outdated
Show resolved
Hide resolved
@@ -642,7 +648,7 @@ static void wrap_move_group_interface() | |||
&MoveGroupInterfaceWrapper::setMaxAccelerationScalingFactor); | |||
MoveGroupInterfaceClass.def("set_planner_id", &MoveGroupInterfaceWrapper::setPlannerId); | |||
MoveGroupInterfaceClass.def("set_num_planning_attempts", &MoveGroupInterfaceWrapper::setNumPlanningAttempts); | |||
MoveGroupInterfaceClass.def("compute_plan", &MoveGroupInterfaceWrapper::getPlanPython); |
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.
Please note this API change in MIGRATION.md
.
@@ -53,8 +62,11 @@ def test_validation(self): | |||
self.assertFalse(self.group.execute(plan2)) | |||
|
|||
# newly planned trajectory should execute again | |||
plan3 = self.plan(current) | |||
error_code3, plan3, time = self.plan(current) | |||
self.assertTrue(self.group.execute(plan3)) |
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.
Execution should follow the plan-result assertions, shouldn't it?
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.
done
error_code1, plan, time = self.plan(target) | ||
error_code = MoveItErrorCodes() | ||
error_code.deserialize(error_code1) | ||
if self.group.execute(plan) and (error_code.val == MoveItErrorCodes.SUCCESS): |
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.
Change order of checking planning result and execution here as well.
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.
Looks good to me! This should get squash merged once the changes requested by @rhaschke are addressed.
Do we want to accept this for Melodic as well? Or should this be limited to the master branch?
I think it's fine keeping it in the master
branch only since it changes the API while the added feature is not too critical.
@@ -425,9 +425,9 @@ class MoveGroupInterfaceWrapper : protected py_bindings_tools::ROScppInitializer | |||
return asyncExecute(plan) == MoveItErrorCode::SUCCESS; | |||
} | |||
|
|||
const char* getPlannerIdCStr() const |
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.
Oops. This became an infinite recursive function call now. Where is this function (or the previous getPlannerIdCStr
) used at all?
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 think we tried to fix something that git already did, or perhaps it was on an outdated diff. This conversation seems to be on an outdated diff as well... :/
The current diff shows me adding this function which is absolutely not intended. Big of a jump from a PR intended for Kinetic a year ago :)
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 github diff view seems to be cached and I discovered a refresh button on the top... That may be the trick. I've added a new commit to remove the function, compilation seems fine, let's see travis with the tests.
@rhaschke good to go? |
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.
LGTM, but: While the two of us argued for merging this into master only, @bmagyar votes for Melodic.
This needs to be decided and MIGRATION.md adapted correspondingly.
+1 to not changing melodic beyond bug fixes. |
7f7a920
to
2d708f1
Compare
…time, error_code] Update test of C++ MoveGroupInterface through Python wrappers Adjust unit test
2d708f1
to
f7855cf
Compare
That makes it 3 vs 1 for not going to Melodic, it's decided then :) I've rebased the branch to resolve the conflict, dropped the migration notes for Melodic and pre-squashed the commits, all ready for merging as soon as the CI turns green. |
@bmagyar, please re-add the MIGRATION notes, but below section Noetic. |
updated |
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.
Sorry, small nitpick in the wording of the migration note.
Co-Authored-By: bmagyar <[email protected]>
That took a while, thanks for sticking around! 💪 |
Description
The
MoveGroupInterface.plan()
was out of line in its behaviour from the C++ class: now it returns a tuple of 4 as such:(success flag : boolean, trajectory message : RobotTrajectory, planning time : float, error code : MoveitErrorCodes)
.Up to now, users of this function could only tell if a
plan()
call was successful by processing the trajectory message (some planners return trajectories regardless of a failed plan!).It would be nice to add some tests too.
Checklist