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

[JTC]: Abort goal on deactivate #1517

Merged

Conversation

urfeex
Copy link
Contributor

@urfeex urfeex commented Feb 3, 2025

Currently, when deactivating the JTC once a trajectory is being executed leads to the following problems:

I narrowed that down to the RealtimeServerGoalHandle calling gh_->canceled which is supposed to be called only, once the goal is already cancelling according to its documentation. The transition doesn't succeed and hence that message gets repeated in every cycle of the non-realtime-thread, and the action never terminates.

I've added a test for that event in this PR and a possible solution: Calling setAborted instead of setCanceled in the JTC when it is being deactivated does work. I also think, this is a valid feedback to the user, as the goal isn't preempted by the user but it is aborted due to the controller going down.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Thanks for this fix.
But the test is failing in every CI job, does it succeed locally?

setCanceled() is also called in preempt_active_goal(), should we also change it there?

@urfeex
Copy link
Contributor Author

urfeex commented Feb 3, 2025

Thanks for this fix. But the test is failing in every CI job, does it succeed locally?

Yes, they were succeeding locally, I will have a look.

setCanceled() is also called in preempt_active_goal(), should we also change it there?

That seems reasonable, I will check that.

Checking for the command_interface's values should be sufficient
@urfeex
Copy link
Contributor Author

urfeex commented Feb 3, 2025

setCanceled() is also called in preempt_active_goal(), should we also change it there?

Things seem to be a bit more complicated there.

From my understanding, we call preempt_active_goal() when a new goal is accepted. Inside there, we use setCanceled() to set request the target state canceled. This would be handled by the next timer callback for runNonRealtime() but this is never happening, as in the same action callback we reset the controller's timer.

If I add a manual call to runNonRealtime() as part of preempt_active_goal(), I get the expected output.

Trajectory replacement seems to be working fine and as expected, however the overwritten trajectory doesn't return until the overwriting trajectory finished. Then, it reports CANCELED. I noticed, that the succeed event is the first from the runNonRealtime() function that gets triggered, which is why this probably triggers the old action being canceled in the underlying (non-realtime) action-server.

For the time being I would suggest to restrict this PR to the deactivate problem, as this is related to UniversalRobots/Universal_Robots_ROS2_Driver#1250 and we create an issue for the replacement separately.

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

Attention: Patch coverage is 86.48649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.26%. Comparing base (694d6f1) to head (201386a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ectory_controller/test/test_trajectory_actions.cpp 86.11% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1517      +/-   ##
==========================================
+ Coverage   84.19%   84.26%   +0.06%     
==========================================
  Files         123      123              
  Lines       11322    11359      +37     
  Branches      956      962       +6     
==========================================
+ Hits         9533     9572      +39     
+ Misses       1473     1470       -3     
- Partials      316      317       +1     
Flag Coverage Δ
unittests 84.26% <86.48%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ory_controller/src/joint_trajectory_controller.cpp 84.89% <100.00%> (+1.00%) ⬆️
...ectory_controller/test/test_trajectory_actions.cpp 97.10% <86.11%> (-0.67%) ⬇️

... and 3 files with indirect coverage changes

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

Another reference https://design.ros2.org/articles/actions.html

  • ABORTED - The goal was terminated by the action server without an external request.
  • CANCELED - The goal was canceled after an external request from an action client.

indeed, abort is what we need.

Can you please open an issue regarding the preemption?

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

LGTM as well.
Thanks for adding a proper test :)

@christophfroehlich christophfroehlich merged commit 28845e6 into ros-controls:master Feb 4, 2025
23 of 24 checks passed
@christophfroehlich christophfroehlich added the backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. label Feb 4, 2025
mergify bot pushed a commit that referenced this pull request Feb 4, 2025
@urfeex urfeex deleted the jtc_abort_goal_on_deactivate branch February 4, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants