Closed corot closed 3 years ago
We're doing very similar things in our cancel loop. Wait for a flag to become true (know that the robot has stopped).
I'll evaluate!
i have to verify but my suspicion is that we have there a spurious wakeup. IHMO the right solution would be to check inside the waitForStateUpdate function if the state_ variable has the desired value. The problem is that the AbstractExecutionBase has no access the the state var - so we would need to pass a predicate function to the waitForStateUpdate
i have to verify but my suspicion is that we have there a spurious wakeup. IHMO the right solution would be to check inside the waitForStateUpdate function if the state_ variable has the desired value. The problem is that the AbstractExecutionBase has no access the the state var - so we would need to pass a predicate function to the waitForStateUpdate
Do you mean, in this PR branch? mmm.... not sure what do you mean; can you provide more details? Btw, did you try the script?
@corot I couldn't reproduce the issue despite trying really hard. But from what i understand the issue is that we first set the goal as aborted in controler_action.cpp lines 285
execution.cancel();
controller_active = false;
fillExePathResult(mbf_msgs::ExePathResult::OSCILLATION, "Oscillation detected!", result);
goal_handle.setAborted(result, result.message);
but the in_use
flag is still true, so we try to update the current goal controller_action.cpp lines 90
mbf_msgs::ExePathResult result;
fillExePathResult(mbf_msgs::ExePathResult::CANCELED, "Goal preempted by a new plan", result);
concurrency_slots_[slot].goal_handle.setCanceled(result, result.message);
blocking the cancel call is only a "approximate" solution, since the what really matters is the in_use
flag (set in abstract_action_base.hpp, line 144). I've created a branch which might help: https://github.com/magazino/move_base_flex/tree/dima/fix_exec_path
Would be nice if you can try it out
blocking the cancel call is only a "approximate" solution, since the what really matters is the
in_use
flag (set in abstract_action_base.hpp, line 144). I've created a branch which might help: https://github.com/magazino/move_base_flex/tree/dima/fix_exec_path Would be nice if you can try it out
Seems to me that you are catching a different issue... So your problem is that, after we stop the controller due to oscillation detected, the goal gets preempted by a new path, even if it was already aborted?
But the in_use
flag is set to false after cancel (see https://github.com/magazino/move_base_flex/blob/master/mbf_abstract_nav/include/mbf_abstract_nav/abstract_action_base.hpp#L144). Can you make a script to reproduce the problem? And what are the effects? crash? warns? errors?
Hey @Timple, did you have time to tinker with this fix?
Thanks for the ping. I bumped it upward on my todo list.
I just realised I was mis-interpreting this PR. We're actually blocking the controller_->cancel()
call and expect the control cycles to continue.
But the controller_->cancel()
call is unchanged in the PR. So our implementation is of no concern I guess.
We have seen the To transition to a cancelled state, ...
and this PR, from the looks of it, does seem to tackle this. So I'm happy to monitor any occurrences of this issue again after merging.
Thanks for the ping. I bumped it upward on my todo list.
I just realised I was mis-interpreting this PR. We're actually blocking the
controller_->cancel()
call and expect the control cycles to continue.But the
controller_->cancel()
call is unchanged in the PR. So our implementation is of no concern I guess.Right; only effect you will notice is that execution cancel can take up to 500 milliseconds in addition to the time your controller takes to stop. But if you are handling the cancellation properly, it won't wait more than now.
We have seen the
To transition to a cancelled state, ...
and this PR, from the looks of it, does seem to tackle this. So I'm happy to monitor any occurrences of this issue again after merging.
If you get the error because of calling exe_path again right after a failure, yes, this should fix it. Great if you can give it a try before merging!
We do handle the cancel correctly, so no problems there.
Your branch works like a charm in all our unit tests where we use mbf :+1: I won't be able to reproduce the issue it solves. It's been a while since I've seen it.
use the following script to reproduce:
Would be nice to add this as a testcase :slightly_smiling_face:
This fixes the sometimes appearing
To transition to a cancelled state, the goal must be in a pending, recalling, active, or preempting state, it is currently in state: 4
I have noticed that it happens when we call exe_path right after it fails, e.g. when running a very fast recovery behavior in between. The reason seems to be that we set the goal as aborted and exit the control loop, but the execution is still active:
If you send another goal to exe_path immediately, MBF prints the error shown above and doesn't execute the new goal. use the following script to reproduce:
Steps
@Timple, would be great if you can try this, as you where toying with gentle controller canceling