Add SetGoal action and make the SetGoal service blocking - #20
Add SetGoal action and make the SetGoal service blocking#20VitezGabriela wants to merge 8 commits into
Conversation
…ion at same time and add reentrant service callback
| while True: | ||
| if not goal_handle.is_active: | ||
| result.success = False | ||
| result.message = f"Goal '{goal_name}' was preempted." |
There was a problem hiding this comment.
On shutdown. Do you prefer it removed?
There was a problem hiding this comment.
But then I am not sure if this is the correct comment. Can we on shutdown call "cancel" on the current goal if such is running/exits? Would be cool to have only one execution interruption path we can reuse.
There was a problem hiding this comment.
I merged into one block, so shutdown and cancel take the same path. We couldn't literally call cancel on shutdown, because by then the goal handle is already gone and canceled() does nothing.
I also added a fix because on shutdown the wait loop of action never stopped, so the node was never properly destroyed, it just hung and had to be killed manually. The blocking service did the same thing. Fixed it by adding a shutting down flag and adding it to destroy node.
|
@copilot resolve the merge conflicts in this pull request |
|
@destogl Should i rename the service and action to have a private namespace? |
yes please :) Also run the pre-commit again, I have updated linters just today. |
Summary
SetGoalROS 2 action interface andRosSetGoalActionServer.ForemanErrorStatemessage for action feedback/result error reporting.SetGoalservice blocking by waiting on Foreman's engine snapshot until the requested goal is reached, fails, or is preempted.set_goalexecution lock so action and service requests cannot overwrite each other while one goal is active.Behavior Change
Previously,
SetGoalservice returned success when the goal request was accepted.With this change, both interfaces now report completion only once Foreman reaches the requested goal:
at_goal = true.at_goal = true.If another
set_goalrequest is already active through either the service or the action, the new request is rejected with:Motivation
The old
SetGoalservice could only report whether Foreman accepted a requested goal. It returned before Foreman's transition loop had finished switching controllers and components, so clients had no Foreman-level ROS signal for when the requested state was actually reached.This could create a race for clients that need the target controller to be active immediately after requesting a goal. For example, MoveIt could send a trajectory after
SetGoalreturned success while the joint trajectory controller was still inactive, causing the trajectory goal to be rejected.The action solves this for action clients, while the blocking service keeps compatibility for existing service clients.
Testing
colcon build --packages-up-to foreman colcon test --packages-up-to foreman colcon test-result --verboseResult:
59 tests, 0 errors, 0 failures, 0 skipped