Skip to content

Commit e339623

Browse files
committed
resolve PruningMultiForward test
Every InterfaceState along the partial solution has to be disabled for pruning, not just the ends that are currently relevant.
1 parent f8f8859 commit e339623

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

core/include/moveit/task_constructor/storage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class InterfaceState
7676
{
7777
friend class SolutionBase; // addIncoming() / addOutgoing() should be called only by SolutionBase
7878
friend class Interface; // allow Interface to set owner_ and priority_
79+
friend class StagePrivate;
80+
7981
public:
8082
enum Status
8183
{

core/src/stage.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,23 @@ void StagePrivate::setStatus(const InterfaceState* s, InterfaceState::Status sta
153153
if (s->priority().status() == status)
154154
return; // nothing changing
155155

156-
// actually enable/disable the state
157-
if (s->owner())
156+
// if we should disable the state, only do so when there is no enabled alternative path
157+
if (status == InterfaceState::DISABLED) {
158+
auto solution_is_enabled = [](auto&& solution) {
159+
return state<opposite<dir>()>(*solution)->priority().enabled();
160+
};
161+
const auto& alternatives = trajectories<opposite<dir>()>(*s);
162+
auto alternative_path = std::find_if(alternatives.cbegin(), alternatives.cend(), solution_is_enabled);
163+
if (alternative_path != alternatives.cend())
164+
return;
165+
}
166+
167+
if (s->owner()) {
168+
// actually enable/disable the state
158169
s->owner()->updatePriority(const_cast<InterfaceState*>(s), InterfaceState::Priority(s->priority(), status));
170+
} else {
171+
const_cast<InterfaceState*>(s)->priority_ = InterfaceState::Priority(s->priority(), status);
172+
}
159173

160174
// To break symmetry between both ends of a partial solution sequence that gets disabled,
161175
// we mark the first state with DISABLED_FAILED and all other states down the tree only with DISABLED.

0 commit comments

Comments
 (0)