Skip to content

Commit d2918f1

Browse files
authored
Pruning: Relax too strong assertion: PRUNED => !ARMED (#340)
2 parents 9026ac8 + 096c671 commit d2918f1

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

core/include/moveit/task_constructor/storage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ class Interface : public ordered<InterfaceState*>
248248

249249
std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& prio);
250250
std::ostream& operator<<(std::ostream& os, const Interface& interface);
251+
std::ostream& operator<<(std::ostream& os, Interface::Direction);
251252

252253
/// Find index of the iterator in the container. Counting starts at 1. Zero corresponds to not found.
253254
template <typename T>

core/src/stage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,15 @@ ConnectingPrivate::StatePair ConnectingPrivate::make_pair<Interface::FORWARD>(In
737737
return StatePair(second, first);
738738
}
739739

740-
// TODO: bool updated -> uint_8 updated (bitfield of PRIORITY | STATUS)
741740
template <Interface::Direction dir>
742741
void ConnectingPrivate::newState(Interface::iterator it, Interface::UpdateFlags updated) {
743742
auto parent_pimpl = parent()->pimpl();
743+
// disable current interface to break loop (jumping back and forth between both interfaces)
744+
// this will be checked by notifyEnabled() below
744745
Interface::DisableNotify disable_source_interface(*pullInterface<dir>());
745746
if (updated) {
746747
if (updated.testFlag(Interface::STATUS) && // only perform these costly operations if needed
747-
pullInterface<opposite<dir>()>()->notifyEnabled()) // suppress recursive loop
748+
pullInterface<opposite<dir>()>()->notifyEnabled()) // suppressing recursive loop?
748749
{
749750
// If status has changed, propagate the update to the opposite side
750751
auto status = it->priority().status();
@@ -799,16 +800,15 @@ void ConnectingPrivate::newState(Interface::iterator it, Interface::UpdateFlags
799800
#if 0
800801
auto& os = std::cerr;
801802
for (auto d : { Interface::FORWARD, Interface::BACKWARD }) {
802-
bool fw = (d == Interface::FORWARD);
803-
if (fw)
803+
if (d == Interface::FORWARD)
804804
os << " " << std::setw(10) << std::left << this->name();
805805
else
806806
os << std::setw(12) << std::right << "";
807807
if (dir != d)
808808
os << (updated ? " !" : " +");
809809
else
810810
os << " ";
811-
os << (fw ? "↓ " : "↑ ") << this->pullInterface(d) << ": " << *this->pullInterface(d) << std::endl;
811+
os << d << " " << this->pullInterface(d) << ": " << *this->pullInterface(d) << std::endl;
812812
}
813813
os << std::setw(15) << " ";
814814
printPendingPairs(os) << std::endl;

core/src/storage.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ bool InterfaceState::Priority::operator<(const InterfaceState::Priority& other)
8383
}
8484

8585
void InterfaceState::updatePriority(const InterfaceState::Priority& priority) {
86-
// Never overwrite ARMED with PRUNED: PRUNED => !ARMED
87-
assert(priority.status() != InterfaceState::Status::PRUNED || priority_.status() != InterfaceState::Status::ARMED);
86+
// Never overwrite ARMED with PRUNED
87+
if (priority.status() == InterfaceState::Status::PRUNED && priority_.status() == InterfaceState::Status::ARMED)
88+
return;
8889

8990
if (owner()) {
9091
owner()->updatePriority(this, priority);
@@ -178,6 +179,10 @@ std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& prio)
178179
<< InterfaceState::STATUS_COLOR[3];
179180
return os;
180181
}
182+
std::ostream& operator<<(std::ostream& os, Interface::Direction dir) {
183+
os << (dir == Interface::FORWARD ? "" : "");
184+
return os;
185+
}
181186

182187
void SolutionBase::setCreator(Stage* creator) {
183188
assert(creator_ == nullptr || creator_ == creator); // creator must only set once

core/test/test_pruning.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,17 @@ TEST_F(Pruning, PropagateFromParallelContainerMultiplePaths) {
193193
// the failure in one branch of Alternatives must not prune computing back
194194
EXPECT_EQ(back->runs_, 1u);
195195
}
196+
197+
TEST_F(Pruning, TwoConnects) {
198+
add(t, new GeneratorMockup({ 0 }));
199+
add(t, new ForwardMockup({ INF }));
200+
add(t, new ConnectMockup());
201+
202+
add(t, new GeneratorMockup());
203+
add(t, new ConnectMockup());
204+
205+
add(t, new GeneratorMockup());
206+
add(t, new ForwardMockup());
207+
208+
EXPECT_FALSE(t.plan());
209+
}

0 commit comments

Comments
 (0)