-
Notifications
You must be signed in to change notification settings - Fork 41
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
ROS 2 action clients don't receive cancellation response #310
Comments
After some investigation I suspect the following: Looking at the source code and the In the end, it's impossible to know which callback observes that the flag is set to In my opinion, the action servers of |
Thanks for raising this! It might be that it seems the action callbacks always do a ... so I think it's just checking whether the robot's action completed or was canceled. I'll look into this when I have the chance. |
Correct. And it does this currently. The cancel callbacks should tell the robot to cancel its running action, but the return status of that action is checked in the actual execution. So the issue seems to be that we accept cancellation, but then don't confirm that the goal was actually canceled by setting the right status in the result. |
That's what I thought as well, but according to the action design document it's totally fine to succeed when canceling. However, it would be nice if this was accounted for ^^
Hmm, but what about this line inside I'm not used to |
Yes, what happens is that this library's core is not based on ROS, so all actions return an So in the case that an action is canceled, the navigation action still completes, but returns an pyrobosim/pyrobosim/pyrobosim/navigation/execution.py Lines 134 to 139 in 1d35694
So we need to check the return status of the execution result here:
goal_handle.succeed() vs. goal_handle.canceled() .
|
Yes, that is correct. But I still don't understand, how pyrobosim/pyrobosim/pyrobosim/core/robot.py Lines 943 to 958 in 1d35694
works. It seems to me that this function blocks until the cancellation is complete i.e. the execution result is available. And blocking inside the cancel callback = bad like we agreed before, so what am I missing here. |
Oh yes, you are right about that part. Hmm... I guess we could always call that function in a thread and immediately return the cancel callback, but I wonder if there's a better resolution. |
Well I'd suggest using the execute callback for that and introducing a while loop that does the actual work. That's how I always do it with while robot.executing_action:
if cancel:
cancel()
else:
execute() But that would require refactoring |
So I just tried this: https://github.com/sea-bass/pyrobosim/pull/311/files Even though I put some log statements, and I can confirm that the It seems to follow https://github.com/ros2/examples/blob/rolling/rclpy/actions/minimal_action_server/examples_rclpy_minimal_action_server/server_single_goal.py Any ideas? |
Oh, another fun update. If I run that ROS 2 example, I also get the same "Exception when canceling goal: None"
... so maybe this is an |
Oof.. it also seems to me that it should work. Just note, that there should probably also be some more logic that also determines when a cancel request should be rejected similar to this pyrobosim/pyrobosim/pyrobosim/core/robot.py Lines 944 to 947 in 1d35694
|
Good idea -- 55293eb |
Small update: I just cloned your pull request #311 and my application (the real one, not the CLI) now works correctly. My client is now able to successfully receive the response to the cancel request and conclude the cancellation on its side. The actual problem was in fact that pyrobosim/pyrobosim_ros/pyrobosim_ros/ros_interface.py Lines 436 to 440 in 1d35694
to this pyrobosim/pyrobosim_ros/pyrobosim_ros/ros_interface.py Lines 439 to 443 in 60c73cb
did the trick! However, the other change is also needed to correctly respond to the cancellation request on the client side! pyrobosim/pyrobosim_ros/pyrobosim_ros/ros_interface.py Lines 423 to 427 in 60c73cb
Two birds with one stone! Thanks for your time! I guess there is still an issue with rclpy or ros2cli but let's see... PS: Great work with pyrobosim! It's awesome to have a lightweight platform for behavior prototyping and demonstration. I'm currently integrating this project in one of my repo's to allow users to quickly validate their programs and I'm really happy to have come across pyrobosim. So it would be awesome if you could merge this soon :) |
Just merged. Thanks again for bringing this up. I also look forward to seeing what you end up doing on your repo. If you have any usage examples to share, you can add them to https://github.com/sea-bass/pyrobosim/blob/main/docs/source/index.rst#usage-examples And generally, let me know as anything else comes up. |
I'll keep you updated. Will probably release a first version next month |
The
WorldROSWrapper
exposes actions and services to the ROS 2 network and makes it possible to request actions or query services. In the case of ROS 2 actions I've found, that the individualrclpy.action.ActionServer
instances might not be implemented correctly, since action clients are not able to receive a response for a cancellation request.How to reproduce
Start the GUI and the default word running
pyrobosim_ros/examples/demo.py
Send a simple
Navigate
action request. This is can be done using the terminalros2 action send_goal /execute_action pyrobosim_msgs/action/ExecuteTaskAction "{action: {type: navigate, robot: robot, target_location: bathroom}}"
Send a cancellation request by interrupting the terminal process pressing
Ctrl+C
Expected output
Usually, the program would print something like this if the cancellation request was sent and the corresponding response received correctly:
Actual output
Instead, I receive an error message immediately after I requested to cancel with
Ctrl+C
.Refer to ros2cli/ros2action for more information about the methods that are called during a
ros2 action send_goal
command.The text was updated successfully, but these errors were encountered: