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

Added ROS2 ActionClient w/ limited functionality #125

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

danmartzla
Copy link

@danmartzla danmartzla commented Jun 30, 2024

Added the roslibpy.ActionClient object to send actions goals to ROS2-based systems.
This implementation has limited capabilities (related to RobotWebTools/rosbridge_suite#909) such as:

  • Goal cancelation is not functional.
  • Goal rejection/acceptance are not being notified to the Action client.

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

  • I added a line to the CHANGELOG.rst file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke check).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Copy link

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

This all looks great to me -- just a few minor formatting things and I think this V1 support will be a great addition. Thank you!

docs/files/ros2-action-client.py Show resolved Hide resolved
docs/files/ros2-action-client.py Outdated Show resolved Hide resolved
CHANGELOG.rst Outdated Show resolved Hide resolved
@danmartzla
Copy link
Author

This all looks great to me -- just a few minor formatting things and I think this V1 support will be a great addition. Thank you!

Hi! I already fixed your suggested minor changes. Thanks.

@sea-bass
Copy link

sea-bass commented Oct 2, 2024

Sorry, but I'm not a maintainer of this repo so I can't actually approve your changes. I was just looking because I implemented the rosbridge side of this work.

@sea-bass
Copy link

sea-bass commented Oct 3, 2024

Sorry @danmartzla, I forgot to mention that I recently landed a small change to the protocol that allows for cleaner action cancellation. It may require a small change since now the action_result message also contains a status field telling you whether the action was successful, canceled, aborted, etc.: RobotWebTools/rosbridge_suite#953

Also @gonzalocasas Would you be able to review this PR?

@danmartzla
Copy link
Author

I've adapted this minor change to work with the latest rosbridge_suite updates.

However, sending a cancelation request from a roslibpy "Action Client" seems not to be working. The "rosbridge_server" debug logs do not report any cancelation request (or any other received message). The JSON message seems to be correct based on the documentation:

https://github.com/danmartzla/roslibpy/blob/bcd403c12f32da1118a6c71d84602a237592bf72/src/roslibpy/core.py#L598-L604

@sea-bass
Copy link

sea-bass commented Jan 6, 2025

It does look right... I wonder if you need the send_action_goals_in_new_thread parameter in the server set to True for this to work?

@danmartzla
Copy link
Author

It does look right... I wonder if you need the send_action_goals_in_new_thread parameter in the server set to True for this to work?

OK. I was totally unaware about this parameter of the "rosbridge_server". I can confirm that it is working well when launching the server this way:
ros2 launch rosbridge_server rosbridge_websocket_launch.xml send_action_goals_in_new_thread:="true"

I'm adding this as a comment in the example code : https://github.com/danmartzla/roslibpy/blob/13ae184e691f3024c15bcc1e6a3f857c89affb65/docs/files/ros2-action-client.py#L41-L42

@sea-bass
Copy link

sea-bass commented Jan 6, 2025

Awesome, great to hear!

There is also an equivalent call_services_in_new_thread which allows multiple service calls to be processed concurrently.

Not necessary for this example, of course, but just noting.

Copy link

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

@gonzalocasas this has been around a while and seems to work well. Please consider merging this great contribution.

@yuriyfedyuk
Copy link

@danmartzla First of all thank you for such great feature. During the testing we faced the same issue that you had, we are not able to cancel action. We use ROS2 humble and we build rosbridge and roslibpy from the latest sources.
Here is how we launch rosbridge server
root@9db9713f3160:/opt/ros_ws# ros2 launch rosbridge_server rosbridge_websocket_launch.xml send_action_goals_in_new_thread:=true [INFO] [launch]: All log files can be found below /root/.ros/log/2025-02-01-19-31-13-527917-9db9713f3160-34804 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [rosbridge_websocket-1]: process started with pid [34805] [INFO] [rosapi_node-2]: process started with pid [34807] [rosbridge_websocket-1] [WARN] [1738438274.037011958] [rosbridge_websocket]: The 'default_call_service_timeout' parameter is currently set to 0.0, which means service calls will block indefinitely if no response is received. Please note that in the Jazzy and later releases, the default value for this parameter will be updated to 5.0 seconds. [rosbridge_websocket-1] [WARN] [1738438274.037679806] [rosbridge_websocket]: The 'call_services_in_new_thread' parameter is currently set to False, which means service calls will block the main thread. Please note that in the Jazzy and later releases, the default value for this parameter will be updated to True. [rosbridge_websocket-1] [INFO] [1738438274.040429291] [rosbridge_websocket]: Rosbridge WebSocket server started on port 9090

@danmartzla @sea-bass Could you please describe your environment? do you use humble or newest version?

@yuriyfedyuk
Copy link

yuriyfedyuk commented Feb 2, 2025 via email

@sea-bass
Copy link

sea-bass commented Feb 3, 2025

@yuriyfedyuk Asking just in case, but is the action server that you're communicating to via rosbridge capable of handling cancellations? If it is not, then sending a cancel message via rosbridge will do nothing.

Have you tried with e.g., this server?
https://github.com/ros2/examples/blob/rolling/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py

@yuriyfedyuk
Copy link

yuriyfedyuk commented Feb 3, 2025 via email

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.

3 participants