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 |
| plan = RobotTrajectory() | ||
| plan.deserialize(self._g.compute_plan()) | ||
| return plan | ||
| return (error_code.val == MoveItErrorCodes.SUCCESS, |
There was a problem hiding this comment.
Please update the doc string of this function to reflect the new return value.
There was a problem hiding this comment.
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.
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.
| error_code = MoveItErrorCodes() | ||
| error_code.deserialize(error_code_msg) | ||
| plan = RobotTrajectory() | ||
| plan.deserialize(self._g.compute_plan()) |
There was a problem hiding this comment.
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.
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.
Please do so. Am I correct, that these names are internal only?
There was a problem hiding this comment.
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
rhaschke
left a comment
There was a problem hiding this comment.
I do have some final comments. Generally this looks good to me.
| """ Set a random joint configuration target """ | ||
| self._g.set_random_target() | ||
|
|
||
| def get_named_targets(self): |
There was a problem hiding this comment.
I don't see a reason to remove this. I think it's by mistake.
There was a problem hiding this comment.
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.
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
| &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.
Please note this API change in MIGRATION.md.
| # 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.
Execution should follow the plan-result assertions, shouldn't it?
| 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.
Change order of checking planning result and execution here as well.
There was a problem hiding this comment.
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.
| return asyncExecute(plan) == MoveItErrorCode::SUCCESS; | ||
| } | ||
|
|
||
| const char* getPlannerIdCStr() const |
There was a problem hiding this comment.
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.
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.
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? |
|
+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 |
rhaschke
left a comment
There was a problem hiding this comment.
Sorry, small nitpick in the wording of the migration note.
Co-Authored-By: bmagyar <bence.magyar.robotics@gmail.com>
|
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