Add ability to preempt the task when a stage fails (preempt_on_failure)#723
Add ability to preempt the task when a stage fails (preempt_on_failure)#723DaniGarciaLopez wants to merge 1 commit intomoveit:masterfrom
Conversation
Why don't you simply call |
Because we don't have easy access to the task pointer. Is there a way to get it from the solution? I tried traversing each parent, but the top-level container is not a applicability_filter->addSolutionCallback(
[](const mtc::SolutionBase& solution) {
if (solution.isFailure()) {
const mtc::ContainerBase* container = solution.creator()->parent();
while (container && container->parent())
container = container->parent();
const mtc::Task* task = dynamic_cast<const mtc::Task*>(container);
if (task)
const_cast<mtc::Task*>(task)->preempt();
}
}
); |
|
I was surprised to see this failing. Digging deeper, it turns out that the
|
|
I wasn’t aware of this issue with I agree that passing the task pointer to the lambda would be the best approach, but we don’t have easy access to it. Our stages are packed into Closing this PR. Thanks, Robert! |
In our tasks, we make extensive use of the
PredicateFilterstage to perform certain checks in the scene before other stages are executed. This stage is expected to always succeed for the task to proceed. However, the task currently continues planning and looks for alternative solutions in earlier stages, which unnecessarily prolongs planning time—even though we already know that if this stage fails, the task is not feasible and there is no reason to continue.With this in mind, we propose adding a
preempt_on_failureproperty. If set to true, the stage must always succeed; if the stage fails even once, the task is immediately preempted and planning aborts.We can currently do something similar using
addSolutionCallbackand throwing an exception when any solution fails, but this does not update introspection correctly.Thoughts, @rhaschke?