Skip to content

Commit bca01e8

Browse files
committed
rename Status values
Start and End are already used for an entirely different concept, so if anyone ever wants to read this code, we should use new terms instead. Because the source state is the disabled state that *failed* to extend, triggering the whole subtree to be disabled, I went for the new terms DISABLED and DISABLED_FAILED.
1 parent c0100ff commit bca01e8

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

core/include/moveit/task_constructor/storage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class InterfaceState
7979
public:
8080
enum Status
8181
{
82-
ENABLED,
83-
DISABLED_START, // state that was the root cause for disabling due to failure
84-
DISABLED_END // state on the other end of a disabled solution sequence
82+
ENABLED, // state is actively considered during planning
83+
DISABLED, // state is disabled because a required connected state failed
84+
DISABLED_FAILED, // state that failed, causing the whole partial solution to be disabled
8585
};
8686
/** InterfaceStates are ordered according to two values:
8787
* Depth of interlinked trajectory parts and accumulated trajectory costs along that path.

core/src/container.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,24 @@ void SerialContainer::onNewSolution(const SolutionBase& current) {
408408
void SerialContainer::onNewFailure(const Stage& child, const InterfaceState* from, const InterfaceState* to) {
409409
switch (child.pimpl()->interfaceFlags()) {
410410
case GENERATE:
411-
break; // just ignore: the pair of (new) states isn't known to us anyway
411+
// just ignore: the pair of (new) states isn't known to us anyway
412412
// TODO: If child is a container, from and to might have associated solutions already!
413+
break;
413414

414-
case PROPAGATE_FORWARDS: // mark from as dead (backwards)
415-
StagePrivate::setStatus<Interface::BACKWARD>(from, InterfaceState::Status::DISABLED_START);
415+
case PROPAGATE_FORWARDS: // mark from as failed (backwards)
416+
StagePrivate::setStatus<Interface::BACKWARD>(from, InterfaceState::Status::DISABLED_FAILED);
416417
break;
417-
case PROPAGATE_BACKWARDS: // mark to as dead (forwards)
418-
StagePrivate::setStatus<Interface::FORWARD>(to, InterfaceState::Status::DISABLED_START);
418+
case PROPAGATE_BACKWARDS: // mark to as failed (forwards)
419+
StagePrivate::setStatus<Interface::FORWARD>(to, InterfaceState::Status::DISABLED_FAILED);
419420
break;
420421

421422
case CONNECT:
422423
if (const Connecting* conn = dynamic_cast<const Connecting*>(&child)) {
423424
auto cimpl = conn->pimpl();
424425
if (!cimpl->hasPendingOpposites<Interface::FORWARD>(from))
425-
StagePrivate::setStatus<Interface::BACKWARD>(from, InterfaceState::Status::DISABLED_START);
426+
StagePrivate::setStatus<Interface::BACKWARD>(from, InterfaceState::Status::DISABLED_FAILED);
426427
if (!cimpl->hasPendingOpposites<Interface::BACKWARD>(to))
427-
StagePrivate::setStatus<Interface::FORWARD>(to, InterfaceState::Status::DISABLED_START);
428+
StagePrivate::setStatus<Interface::FORWARD>(to, InterfaceState::Status::DISABLED_FAILED);
428429
}
429430
break;
430431
}

core/src/stage.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ void StagePrivate::setStatus(const InterfaceState* s, InterfaceState::Status sta
158158
s->owner()->updatePriority(const_cast<InterfaceState*>(s), InterfaceState::Priority(s->priority(), status));
159159

160160
// To break symmetry between both ends of a partial solution sequence that gets disabled,
161-
// we mark the start state with START and all other states down the tree with END.
162-
// This allows us to re-enable the START side, while not (yet) consider the END side,
163-
// when a new states arrives in a Connecting stage.
164-
// The END side is only re-enabled if the START side actually was connected with a solution.
165-
if (status == InterfaceState::Status::DISABLED_START)
166-
status = InterfaceState::Status::DISABLED_END; // ensure that only the first state is marked as START
161+
// we mark the first state with DISABLED_FAILED and all other states down the tree only with DISABLED.
162+
// This allows us to re-enable the FAILED side, while not (yet) consider the DISABLED states again,
163+
// when new states arrive in a Connecting stage.
164+
// All DISABLED states are only re-enabled if the FAILED state actually gets connected.
165+
if (status == InterfaceState::DISABLED_FAILED)
166+
status = InterfaceState::DISABLED; // only the first state is marked as FAILED
167167

168168
// traverse solution tree
169169
for (const SolutionBase* successor : trajectories<dir>(s))
@@ -729,7 +729,7 @@ ConnectingPrivate::StatePair ConnectingPrivate::make_pair<Interface::FORWARD>(In
729729
template <Interface::Direction other>
730730
void ConnectingPrivate::newState(Interface::iterator it, bool updated) {
731731
if (updated) { // many pairs might be affected: resort
732-
if (it->priority().status() == InterfaceState::Status::DISABLED_END)
732+
if (it->priority().status() == InterfaceState::DISABLED)
733733
// remove all pending pairs involving this state
734734
pending.remove_if([it](const StatePair& p) { return std::get<opposite<other>()>(p) == it; });
735735
else
@@ -738,10 +738,10 @@ void ConnectingPrivate::newState(Interface::iterator it, bool updated) {
738738
assert(it->priority().enabled()); // new solutions are feasible, aren't they?
739739
InterfacePtr other_interface = pullInterface(other);
740740
for (Interface::iterator oit = other_interface->begin(), oend = other_interface->end(); oit != oend; ++oit) {
741-
// Don't re-enable states that are marked DISABLED_END
741+
// Don't re-enable states that are marked DISABLED
742742
if (static_cast<Connecting*>(me_)->compatible(*it, *oit)) {
743-
// re-enable the opposing state oit if its status is DISABLED_START
744-
if (oit->priority().status() == InterfaceState::DISABLED_START)
743+
// re-enable the opposing state oit if its status is DISABLED_FAILED
744+
if (oit->priority().status() == InterfaceState::DISABLED_FAILED)
745745
oit->owner()->updatePriority(&*oit, InterfaceState::Priority(oit->priority(), InterfaceState::ENABLED));
746746
pending.insert(make_pair<other>(it, oit));
747747
}

core/test/test_interface_state.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TEST(InterfaceStatePriority, compare) {
1919
EXPECT_TRUE(Prio(1, 42) < Prio(0, 0));
2020
EXPECT_TRUE(Prio(0, 0) < Prio(0, 42)); // at same depth, higher cost is larger
2121

22-
auto dstart = InterfaceState::DISABLED_START;
22+
auto dstart = InterfaceState::DISABLED_FAILED;
2323
EXPECT_TRUE(Prio(0, 0, dstart) == Prio(0, 0, dstart));
2424
EXPECT_TRUE(Prio(1, 0, dstart) < Prio(0, 0, dstart));
2525
EXPECT_TRUE(Prio(1, 42, dstart) < Prio(0, 0, dstart));
@@ -68,7 +68,7 @@ TEST(Interface, update) {
6868
i.updatePriority(*i.rbegin(), Prio(5, 0.0));
6969
EXPECT_THAT(i.depths(), ::testing::ElementsAreArray({ 5, 3 }));
7070

71-
i.updatePriority(*i.begin(), Prio(6, 0, InterfaceState::DISABLED_START));
71+
i.updatePriority(*i.begin(), Prio(6, 0, InterfaceState::DISABLED_FAILED));
7272
EXPECT_THAT(i.depths(), ::testing::ElementsAreArray({ 3, 6 }));
7373
}
7474

@@ -87,7 +87,7 @@ TEST(StatePairs, compare) {
8787
EXPECT_TRUE(pair(Prio(1, 1), Prio(1, 1)) < pair(Prio(1, 0), Prio(0, 0)));
8888

8989
auto good = InterfaceState::ENABLED;
90-
auto bad = InterfaceState::DISABLED_START;
90+
auto bad = InterfaceState::DISABLED_FAILED;
9191
EXPECT_TRUE(pair(good, good) < pair(good, bad));
9292
EXPECT_TRUE(pair(good, good) < pair(bad, good));
9393
EXPECT_TRUE(pair(bad, good) < pair(good, bad));

0 commit comments

Comments
 (0)