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

Add utility functions to Python PSI #2532

Merged
merged 5 commits into from
Mar 2, 2021

Conversation

felixvd
Copy link
Contributor

@felixvd felixvd commented Feb 28, 2021

I found a few very basic functions that I had added in the past, but apparently forgot to push upstream. The ApplyPlanningScene function seems to have been implemented already in wrap_python_planning_scene_interface.cpp but not exposed in the Python class, so I added that as well.

The interface seems not very useful without these functions and I'd like to use them in a different project where we don't build MoveIt from source, so it would be great if these found their way into the binaries.

This should be ported back to Melodic, possibly even Kinetic.

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

@codecov
Copy link

codecov bot commented Feb 28, 2021

Codecov Report

Merging #2532 (84ece7c) into master (34b2356) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2532      +/-   ##
==========================================
+ Coverage   60.24%   60.25%   +0.02%     
==========================================
  Files         351      351              
  Lines       26473    26473              
==========================================
+ Hits        15945    15949       +4     
+ Misses      10528    10524       -4     
Impacted Files Coverage Δ
...nning_scene_monitor/src/planning_scene_monitor.cpp 67.84% <0.00%> (-0.31%) ⬇️
.../ompl_interface/src/detail/constrained_sampler.cpp 60.00% <0.00%> (+17.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34b2356...ea1e3ed. Read the comment docs.

@@ -55,10 +55,13 @@


class PlanningSceneInterface(object):
""" Simple interface to making updates to a planning scene """
"""
Python interface for a planning scene.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this provide an interface to modifying a PlanningScene or to modifying the PlanningScene curated by the PlanningSceneMonitor? (Not sure if the first one even exists in Python)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, it's the latter. A Python interface for the PlanningSceneInterface, not the PlanningScene.

There are no Python bindings for the PlanningScene, although there is one for the RobotState. There has been discussion in #900 and I should probably raise the issue again.

"""
Applies the planning scene message.
"""
return self._psi.apply_planning_scene(conversions.msg_to_string(planning_scene_message))
Copy link
Contributor

@v4hn v4hn Mar 1, 2021

Choose a reason for hiding this comment

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

I don't think we should add these methods.

__submit will already use the service iff the PSI object is instantiated as synchronous.

There is no merit in depending on the C++ implementation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__submit is not user-facing, so users of this class can't publish their own CollisionObject.

I also don't see the problem with depending on the C++ implementation.

I can implement apply_collision_object and apply_attached_collision_object with a call to __submit, but a pure Python API doesn't seem like it will be maintained, so adding C++ bindings with familiar names seems better.

Copy link
Contributor

Choose a reason for hiding this comment

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

__submit is not user-facing, so users of this class can't publish their own CollisionObject.

That's true, but that's why you added the add_object method that uses __submit (just like almost every other method in this class)!
So you basically add a second way to do the same thing if you also expose the C++ apply* methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. Right. These commits are so old that I forgot that I did that. I just knew that they worked and we've been using them.

I'm not sure what I think about 1) the naming being different from C++ for no reason and 2) maintaining a pure Python API instead of bindings as described in #900, but I can leave out the C++ methods for now.

Are you good with apply_collision_object and apply_attached_collision_object calling __submit?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what I think about 1) the naming being different from C++ for no reason and

neither am I, but that's what we got. The idea back then was to avoid breaking the whole class, but still support the update service for all existing methods. The only proper way to have a 1-to-1 mapping with the C++ classes would be to create an entirely new package for it. It's an interesting idea, but quite some work too. :-)

Are you good with apply_collision_object and apply_attached_collision_object calling __submit?

No, because if synchronous == False, these methods would use the topic interfaces then!
With the current design we should not have the add vs apply distinction we have in C++.

Copy link
Contributor Author

@felixvd felixvd Mar 1, 2021

Choose a reason for hiding this comment

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

Also true.

Alright, I took applyCollisionObject out. applyPlanningScene was there already though, it just wasn't exposed in Python. Surely that was an oversight?

Yes, more Python bindings would be great. Someone from #900 should start adding PlanningScene (not PSI) bindings for WMD.

@felixvd
Copy link
Contributor Author

felixvd commented Mar 1, 2021

Looks like this CI failure is unrelated:

anyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

@v4hn
Copy link
Contributor

v4hn commented Mar 1, 2021 via email

@felixvd felixvd closed this Mar 2, 2021
@felixvd felixvd reopened this Mar 2, 2021
@v4hn v4hn merged commit d18173b into moveit:master Mar 2, 2021
@felixvd felixvd deleted the add-functions-to-python-psi branch March 2, 2021 10:28
@tylerjw tylerjw mentioned this pull request Apr 9, 2021
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request Apr 29, 2021
@tylerjw tylerjw mentioned this pull request Apr 29, 2021
tylerjw pushed a commit to tylerjw/moveit that referenced this pull request May 3, 2021
tylerjw pushed a commit that referenced this pull request May 3, 2021
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