diff --git a/core/include/moveit/task_constructor/container_p.h b/core/include/moveit/task_constructor/container_p.h index fceb106f..48af8526 100644 --- a/core/include/moveit/task_constructor/container_p.h +++ b/core/include/moveit/task_constructor/container_p.h @@ -104,13 +104,13 @@ protected: // if the interface is unknown: in this case greedily assume a push interface. // If, during pruneInterface() later, we notice that it's not needed, prune there. inline void setChildsPushBackwardInterface(Stage& child) { - bool allowed = (child.pimpl()->requiredInterface() & WRITES_PREV_END) || - (child.pimpl()->requiredInterface() == UNKNOWN); + InterfaceFlags required = child.pimpl()->requiredInterface(); + bool allowed = (required & WRITES_PREV_END) || (required == UNKNOWN); child.pimpl()->setPrevEnds(allowed ? pending_backward_ : InterfacePtr()); } inline void setChildsPushForwardInterface(Stage& child) { - bool allowed = (child.pimpl()->requiredInterface() & WRITES_NEXT_START) || - (child.pimpl()->requiredInterface() == UNKNOWN); + InterfaceFlags required = child.pimpl()->requiredInterface(); + bool allowed = (required & WRITES_NEXT_START) || (required == UNKNOWN); child.pimpl()->setNextStarts(allowed ? pending_forward_ : InterfacePtr()); } diff --git a/core/src/container.cpp b/core/src/container.cpp index ab22a57a..a680ef28 100644 --- a/core/src/container.cpp +++ b/core/src/container.cpp @@ -399,8 +399,8 @@ InterfaceFlags SerialContainerPrivate::requiredInterface() const { if (children().empty()) return UNKNOWN; - return (children().front()->pimpl()->requiredInterface() & INPUT_IF_MASK) - | (children().back()->pimpl()->requiredInterface() & OUTPUT_IF_MASK); + return (children().front()->pimpl()->interfaceFlags() & INPUT_IF_MASK) + | (children().back()->pimpl()->interfaceFlags() & OUTPUT_IF_MASK); } // connect cur stage to its predecessor and successor by setting the push interface pointers diff --git a/core/test/test_container.cpp b/core/test/test_container.cpp index 2ea6e6a3..71ced529 100644 --- a/core/test/test_container.cpp +++ b/core/test/test_container.cpp @@ -117,7 +117,6 @@ protected: } void reset(bool start=true, bool end=true) { container.reset(); - container.clear(); ContainerBasePrivate *impl = container.pimpl(); impl->setNextStarts(InterfacePtr()); impl->setPrevEnds(InterfacePtr()); @@ -214,11 +213,13 @@ TEST_F(SerialTest, insertion_order) { #define EXPECT_INIT_FAILURE(start, end, ...) {\ SCOPED_TRACE("validateInit({" #__VA_ARGS__ "})"); \ + container.clear(); \ validateInit(start, end, {__VA_ARGS__}, true); \ } #define EXPECT_INIT_SUCCESS(start, end, ...) {\ SCOPED_TRACE("validateInit({" #__VA_ARGS__ "})"); \ + container.clear(); \ validateInit(start, end, {__VA_ARGS__}, false); \ } @@ -343,6 +344,13 @@ TEST_F(SerialTest, interface_detection) { EXPECT_EQ(container.pimpl()->interfaceFlags(), UNKNOWN); } +TEST_F(SerialTest, nested_interface_detection) { + auto inner = std::make_unique("inner"); + append(*inner, {GEN, ANY}); + container.insert(std::move(inner)); + validateInit(true, true, {ANY}, false); +} + class ParallelTest : public InitTest { };