Skip to content

MoveIt Python Library - Add Gripper Interface#2157

Open
peterdavidfagan wants to merge 1 commit intomoveit:mainfrom
peterdavidfagan:add-gripper-interface
Open

MoveIt Python Library - Add Gripper Interface#2157
peterdavidfagan wants to merge 1 commit intomoveit:mainfrom
peterdavidfagan:add-gripper-interface

Conversation

@peterdavidfagan
Copy link
Copy Markdown
Member

@peterdavidfagan peterdavidfagan commented May 8, 2023

Description

This pull request looks to begin addressing a request for a Gripper Interface made by @AndrejOrsula in the following thread. Ideally the API should look as follows with the gripper client added to the library:

# Instantiate gripper client
from moveit.gripper_action_client import GripperClient
robotiq_85_gripper = GripperClient("/robotiq_gripper/gripper_cmd")

def open_gripper():
    robotiq_85_gripper.send_gripper_command(0.0, 0.0)
    
def close_gripper():
    robotiq_85_gripper.send_gripper_command(1.0, 1.0)

# close gripper applying max_effort of 1.0 N.
close_gripper()

Features

  • Support GripperCommand

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
  • Include a screenshot if changing a GUI

@peterdavidfagan peterdavidfagan added the enhancement New feature or request label May 8, 2023
@peterdavidfagan peterdavidfagan self-assigned this May 8, 2023
@peterdavidfagan peterdavidfagan changed the title [WIP] MoveIt Python Library - Add Gripper Interface MoveIt Python Library - Add Gripper Interface May 8, 2023
@peterdavidfagan
Copy link
Copy Markdown
Member Author

peterdavidfagan commented May 8, 2023

@AndrejOrsula your feedback and thoughts on features you would like as part of the Gripper interface are much appreciated. Right now it is a basic action client, this works well for many basic applications IMO.

@codecov
Copy link
Copy Markdown

codecov bot commented May 8, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (89be9a5) 50.50% compared to head (d685866) 50.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2157      +/-   ##
==========================================
- Coverage   50.50%   50.50%   -0.00%     
==========================================
  Files         387      387              
  Lines       31816    31816              
==========================================
- Hits        16065    16064       -1     
- Misses      15751    15752       +1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
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 see that this can be useful for very simple test setups. However, the same action should be supported by MoveIt's gripper controller handle which is supposed to also handle the runtime state of the action call. Would it be too much to ask to bind to the controller interface? And if yes, how can it be improved to streamline usage through the Python bindings?
I bet @MarqRazz also has a few words to say about supporting custom grippers.

@AndrejOrsula
Copy link
Copy Markdown

Hello @peterdavidfagan,

Thank you very much for looking into it!

Yes, I think having a simple-to-use interface for grippers would be quite beneficial. Besides sending commands, it would be great if the same interface also enabled users to query the current state of the gripper. Here are some primary categories that could be discussed (some of these might be beyond the scope of a gripper interface):

  • Support grippers with GripperCommand and FollowJointTrajectory (JointTrajectoryController) interfaces. From what I have seen, many simulated grippers and multi-finger grippers (hands) implement only the FollowJointTrajectory interface or something similar (but not GripperCommand).
  • When sending goals via action requests, support getting feedback and result in a synchronous or asynchronous way.
  • Simplistic open() / close() commands with optional position and max_effort arguments.
    • If a gripper with FollowJointTrajectory interface supports controlling each finger separately, it might be nice to have an interface for that too (e.g. set_target_configuration()).
  • Simplistic is_open / is_closed getters (properties), with the option of also directly getting the JointState of all joints.
    • If a gripper has some additional sensors (e.g. force/tactile), it might be nice to have a way of passing the output of these through the interface.
  • Option to automatically parse joint names, link names (and other necessities) directly from SRDF/URDF based on the MoveGroup of the gripper.

Looking at the current action client in this PR, I am not so sure about the use of a new subprocess for each gripper action. It is probably good enough for most use cases, but I feel like the overhead might be too much for some applications (it could become a bottleneck in some robot learning scenarios). Handling of feedback/results could also become cumbersome. Just my personal opinion, as I have not tested it. What do you think?

I tried two separate interfaces in my previous attempt, but both have some limitations: MoveIt2Gripper (FollowJointTrajectory interface | example) and GripperCommand (GripperCommand interface | example). I used the first one for a simulated gripper inside Gazebo, and the second one to control a real gripper. Both of these use rclpy as the interface for all communication. Do you think there are better alternatives to using rclpy based on your experience with moveit_py (e.g. binding directly to the MoveIt 2 codebase, which could eventually provide some of the functionalities for free)?

@peterdavidfagan
Copy link
Copy Markdown
Member Author

Thanks @henningkayser for the quick feedback on this.

However, the same action should be supported by MoveIt's gripper controller handle which is supposed to also handle the runtime state of the action call. Would it be too much to ask to bind to the controller interface?

I can look to scope this development item this weekend. It makes sense to align the Python library with the existing C++ codebase where possible so I'll look into what is required to bind these.

And if yes, how can it be improved to streamline usage through the Python bindings?

I'll need to take a look at the existing code to answer this properly. Happy to start looking into it this weekend.

@peterdavidfagan
Copy link
Copy Markdown
Member Author

peterdavidfagan commented May 8, 2023

Thanks @AndrejOrsula for the detailed response and valuable points.

Besides sending commands, it would be great if the same interface also enabled users to query the current state of the gripper.

Makes sense.

Support grippers with GripperCommand and FollowJointTrajectory (JointTrajectoryController) interfaces. From what I have seen, many simulated grippers and multi-finger grippers (hands) implement only the FollowJointTrajectory interface or something similar (but not GripperCommand).

For this point, my current thought process was that the FollowJointTrajectory interface is exposed through planning groups with the necessary ros2 controls configuration. For instance with the existing library one could define a planning group for the entire manipulator or the hand alone. Do you see this as too cumbersome and am I missing something?

When sending goals via action requests, support getting feedback and result in a synchronous or asynchronous way.

Thanks for this I agree, this should be supported.

Simplistic open() / close() commands with optional position and max_effort arguments.
If a gripper with FollowJointTrajectory interface supports controlling each finger separately, it might be nice to have an interface for that too (e.g. set_target_configuration()).
Simplistic is_open / is_closed getters (properties), with the option of also directly getting the JointState of all joints.
If a gripper has some additional sensors (e.g. force/tactile), it might be nice to have a way of passing the output of these through the interface.

I planned to make the open/close gripper methods, members of the GripperClient class for convenience. It would be nice to have the other methods you listed as well.

I tried two separate interfaces in my previous attempt

Thanks for sharing these.

Do you think there are better alternatives to using rclpy based on your experience with moveit_py (e.g. binding directly to the MoveIt 2 codebase, which could eventually provide some of the functionalities for free)?

In this case of the new Python library, I believe there are performance benefits to leveraging the C++ library directly.

@AndrejOrsula
Copy link
Copy Markdown

Support grippers with GripperCommand and FollowJointTrajectory (JointTrajectoryController) interfaces. From what I have seen, many simulated grippers and multi-finger grippers (hands) implement only the FollowJointTrajectory interface or something similar (but not GripperCommand).

For this point, my current thought process was that the FollowJointTrajectory interface is exposed through planning groups with the necessary ros2 controls configuration. For instance with the existing library one could define a planning group for the entire manipulator or the hand alone. Do you see this as too cumbersome and am I missing something?

That makes sense @peterdavidfagan, and it is certainly usable that way. Both open() and close() commands could be just motions to named targets. But I wonder if it might be beneficial to have such a gripper-specific wrapper around FollowJointTrajectory (while being compatible with the GripperCommand interface). 🤔

@sea-bass
Copy link
Copy Markdown
Contributor

sea-bass commented May 9, 2023

I'm skeptical about the decision to use subprocess to call out to the ROS 2 CLI when you could just write a Python node that creates an action client and abstracts it away, e.g. this. Is there a specific reason you decided to go this route?

@peterdavidfagan
Copy link
Copy Markdown
Member Author

peterdavidfagan commented May 9, 2023

Is there a specific reason you decided to go this route?

Hi @sea-bass,

This was an quick but unclean solution for interfacing with available action for the GripperCommand, it was working fine for my use case so I didn't go much further (Note: under the hood it uses rclpy to create a node to interface with the available action). I did start by implementing an action client in Python but was encountering issues when running it from within a notebook.

This approach is far from perfect, I wanted to open the discussion around this and then consider adding it to my task list to develop the gripper interface for the Python library.

@MarqRazz
Copy link
Copy Markdown
Contributor

MarqRazz commented May 9, 2023

I agree with @sea-bass using the CLI here does not make sense. Why would the user not just make an action client? Its only a few lines of code and then they have lots more flexibility to support the features like @AndrejOrsula requested.

If you want to make a GripperActionClient class that helps speed up integration/standardize how users interact with the GripperActionController then I think ros2_controllers/gripper_controllers would be a better home for this code.

@peterdavidfagan
Copy link
Copy Markdown
Member Author

If you want to make a GripperActionClient class that helps speed up integration/standardize how users interact with the GripperActionController then I think ros2_controllers/gripper_controllers would be a better home for this code.

Thanks @MarqRazz, and this makes sense.

If I do write such a class in ros2_controllers/gripper_controllers, for the Python bindings do you think it makes sense to start writing a separate Python binding library for ROS 2 control? I think it may be useful for replicating some of the functionalities of libraries like https://facebookresearch.github.io/fairo/polymetis/overview.html as it is closer to the control stack.

@MarqRazz
Copy link
Copy Markdown
Contributor

Yes I think Python bindings to the hardware_interface would be super useful! We have had a few customers ask how they can integrate their robot interface written in Python to ros2_control.

If you are considering adding these features I would highly recommend attending one of the ros2_control maintainer meetings and running it past them before you get started.

@peterdavidfagan
Copy link
Copy Markdown
Member Author

peterdavidfagan commented May 10, 2023

Thanks @MarqRazz, I'll look to follow up with this approach once I have finished the work I am doing on grasp pose estimation.

@henningkayser
Copy link
Copy Markdown
Member

We already have a gripper action with this controller plugin coming from here. If it's really about the same action interface, we should not duplicate functionality, but rather think about making it easier to access it. (I know that MoveIt's controller interfaces are not ideal, but this would be a good opportunity to think about how to improve them)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 3, 2023

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added the stale label Jul 3, 2023
@github-actions github-actions bot removed the stale label Aug 16, 2023
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 2, 2023

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added the stale label Oct 2, 2023
@github-actions github-actions bot removed the stale label Feb 27, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 6, 2024

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added the stale label Dec 6, 2024
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.50%. Comparing base (89be9a5) to head (d685866).
Report is 440 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2157      +/-   ##
==========================================
- Coverage   50.50%   50.50%   -0.00%     
==========================================
  Files         387      387              
  Lines       31816    31816              
==========================================
- Hits        16065    16064       -1     
- Misses      15751    15752       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot removed the stale label Dec 10, 2024
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added the stale label Jan 29, 2025
@github-actions github-actions bot removed the stale label Feb 17, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2025

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

@github-actions github-actions bot added stale and removed stale labels Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants