mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
fix derivation of propagation direction from connect stage
This commit is contained in:
parent
aee2525382
commit
cf54024379
@ -480,23 +480,31 @@ void SerialContainerPrivate::pruneInterfaces(container_type::const_iterator firs
|
|||||||
// determine accepted interface from available push interfaces
|
// determine accepted interface from available push interfaces
|
||||||
InterfaceFlags accepted;
|
InterfaceFlags accepted;
|
||||||
|
|
||||||
// if previous stage pushes forward, we accept forward propagation
|
// if first stage ...
|
||||||
if (first != children().begin()) {
|
if (first != children().begin()) {
|
||||||
auto prev = first; --prev; // pointer to previous stage
|
auto prev = first; --prev; // pointer to previous stage
|
||||||
|
// ... pushes forward, we accept forward propagation
|
||||||
if ((*prev)->pimpl()->requiredInterface() & WRITES_NEXT_START)
|
if ((*prev)->pimpl()->requiredInterface() & WRITES_NEXT_START)
|
||||||
accepted |= WRITES_NEXT_START;
|
accepted |= PROPAGATE_FORWARDS;
|
||||||
|
// ... pulls backward, we accept backward propagation
|
||||||
|
if ((*prev)->pimpl()->requiredInterface() & READS_END)
|
||||||
|
accepted |= PROPAGATE_BACKWARDS;
|
||||||
} // else: for first child we cannot determine the interface yet
|
} // else: for first child we cannot determine the interface yet
|
||||||
|
|
||||||
// if end stage pushes backward, we accept backward propagation
|
// if end stage ...
|
||||||
if (end != children().end()) {
|
if (end != children().end()) {
|
||||||
|
// ... pushes backward, we accept backward propagation
|
||||||
if ((*end)->pimpl()->requiredInterface() & WRITES_PREV_END)
|
if ((*end)->pimpl()->requiredInterface() & WRITES_PREV_END)
|
||||||
accepted |= WRITES_PREV_END;
|
accepted |= PROPAGATE_BACKWARDS;
|
||||||
|
// ... pulls forward, we accept forward propagation
|
||||||
|
if ((*end)->pimpl()->requiredInterface() & READS_START)
|
||||||
|
accepted |= PROPAGATE_FORWARDS;
|
||||||
} // else: for last child we cannot determine the interface yet
|
} // else: for last child we cannot determine the interface yet
|
||||||
|
|
||||||
// nothing to do if:
|
// nothing to do if:
|
||||||
// - accepted == 0: interface still unknown
|
// - accepted == 0: interface still unknown
|
||||||
// - accepted == PROPAGATE_FORWARDS | PROPAGATE_BACKWARDS: no change
|
// - accepted == PROPAGATE_FORWARDS | PROPAGATE_BACKWARDS: no change
|
||||||
if (accepted != 0 && accepted != InterfaceFlags({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS}))
|
if (accepted != UNKNOWN && accepted != InterfaceFlags({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS}))
|
||||||
pruneInterfaces(first, end, accepted);
|
pruneInterfaces(first, end, accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,13 +517,13 @@ void SerialContainerPrivate::pruneInterfaces(container_type::const_iterator firs
|
|||||||
for (auto it = first; it != end; ++it) {
|
for (auto it = first; it != end; ++it) {
|
||||||
StagePrivate* impl = (*it)->pimpl();
|
StagePrivate* impl = (*it)->pimpl();
|
||||||
// range should only contain stages with unknown required interface
|
// range should only contain stages with unknown required interface
|
||||||
assert(impl->requiredInterface() == PropagatingEitherWay::AUTO);
|
assert(impl->requiredInterface() == UNKNOWN);
|
||||||
|
|
||||||
// remove push interfaces
|
// remove push interfaces
|
||||||
if (!(accepted & WRITES_PREV_END))
|
if (!(accepted & PROPAGATE_BACKWARDS))
|
||||||
impl->setPrevEnds(InterfacePtr());
|
impl->setPrevEnds(InterfacePtr());
|
||||||
|
|
||||||
if (!(accepted & WRITES_NEXT_START))
|
if (!(accepted & PROPAGATE_FORWARDS))
|
||||||
impl->setNextStarts(InterfacePtr());
|
impl->setNextStarts(InterfacePtr());
|
||||||
}
|
}
|
||||||
// 2nd sweep: recursively prune children
|
// 2nd sweep: recursively prune children
|
||||||
|
|||||||
@ -292,6 +292,26 @@ TEST_F(SerialTest, interface_detection) {
|
|||||||
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags(PROPAGATE_FORWARDS));
|
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags(PROPAGATE_FORWARDS));
|
||||||
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
|
||||||
|
|
||||||
|
EXPECT_INIT_SUCCESS(true, true, GEN, ANY);
|
||||||
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
|
||||||
|
|
||||||
|
EXPECT_INIT_SUCCESS(true, true, ANY, GEN);
|
||||||
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
|
||||||
|
|
||||||
|
// derive propagation direction from inner connector
|
||||||
|
EXPECT_INIT_SUCCESS(false, false, ANY, CONN, ANY); // -> -- <-
|
||||||
|
it = serial.pimpl()->children().begin();
|
||||||
|
EXPECT_EQ( (*it)->pimpl()->interfaceFlags(), InterfaceFlags(PROPAGATE_FORWARDS));
|
||||||
|
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags(CONNECT));
|
||||||
|
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags(PROPAGATE_BACKWARDS));
|
||||||
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(CONNECT));
|
||||||
|
|
||||||
|
EXPECT_INIT_SUCCESS(false, false, CONN, ANY);
|
||||||
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(CONNECT));
|
||||||
|
|
||||||
|
EXPECT_INIT_SUCCESS(false, false, ANY, CONN);
|
||||||
|
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(CONNECT));
|
||||||
|
|
||||||
// derive propagation direction from outer interface
|
// derive propagation direction from outer interface
|
||||||
EXPECT_INIT_SUCCESS(false, true, ANY, ANY); // -> ->
|
EXPECT_INIT_SUCCESS(false, true, ANY, ANY); // -> ->
|
||||||
it = serial.pimpl()->children().begin();
|
it = serial.pimpl()->children().begin();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user