mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
add hook to ParallelContainerBase to customize state propagation
This commit is contained in:
parent
79869b856c
commit
f32e747645
@ -227,10 +227,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void validateInterfaces(const StagePrivate& child, InterfaceFlags& external, bool first = false) const;
|
void validateInterfaces(const StagePrivate& child, InterfaceFlags& external, bool first = false) const;
|
||||||
|
|
||||||
private:
|
|
||||||
/// callback for new externally received states
|
/// callback for new externally received states
|
||||||
template <typename Interface::Direction>
|
template <typename Interface::Direction>
|
||||||
void onNewExternalState(Interface::iterator external, bool updated);
|
void propagateStateToChildren(Interface::iterator external, bool updated);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// override for custom behavior on received interface states
|
||||||
|
virtual void initializeExternalInterfaces(InterfaceFlags expected);
|
||||||
};
|
};
|
||||||
PIMPL_FUNCTIONS(ParallelContainerBase)
|
PIMPL_FUNCTIONS(ParallelContainerBase)
|
||||||
|
|
||||||
|
|||||||
@ -678,17 +678,21 @@ void ParallelContainerBasePrivate::resolveInterface(InterfaceFlags expected) {
|
|||||||
if (exceptions)
|
if (exceptions)
|
||||||
throw exceptions;
|
throw exceptions;
|
||||||
|
|
||||||
|
initializeExternalInterfaces(expected);
|
||||||
|
|
||||||
|
required_interface_ = expected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ParallelContainerBasePrivate::initializeExternalInterfaces(InterfaceFlags expected) {
|
||||||
// States received by the container need to be copied to all children's pull interfaces.
|
// States received by the container need to be copied to all children's pull interfaces.
|
||||||
if (expected & READS_START)
|
if (expected & READS_START)
|
||||||
starts().reset(new Interface([this](Interface::iterator external, bool updated) {
|
starts().reset(new Interface([this](Interface::iterator external, bool updated) {
|
||||||
this->onNewExternalState<Interface::FORWARD>(external, updated);
|
this->propagateStateToChildren<Interface::FORWARD>(external, updated);
|
||||||
}));
|
}));
|
||||||
if (expected & READS_END)
|
if (expected & READS_END)
|
||||||
ends().reset(new Interface([this](Interface::iterator external, bool updated) {
|
ends().reset(new Interface([this](Interface::iterator external, bool updated) {
|
||||||
this->onNewExternalState<Interface::BACKWARD>(external, updated);
|
this->propagateStateToChildren<Interface::BACKWARD>(external, updated);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
required_interface_ = expected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelContainerBasePrivate::validateInterfaces(const StagePrivate& child, InterfaceFlags& external,
|
void ParallelContainerBasePrivate::validateInterfaces(const StagePrivate& child, InterfaceFlags& external,
|
||||||
@ -723,7 +727,7 @@ void ParallelContainerBasePrivate::validateConnectivity() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <Interface::Direction dir>
|
template <Interface::Direction dir>
|
||||||
void ParallelContainerBasePrivate::onNewExternalState(Interface::iterator external, bool updated) {
|
void ParallelContainerBasePrivate::propagateStateToChildren(Interface::iterator external, bool updated) {
|
||||||
for (const Stage::pointer& stage : children())
|
for (const Stage::pointer& stage : children())
|
||||||
copyState<dir>(external, stage->pimpl()->pullInterface(dir), updated);
|
copyState<dir>(external, stage->pimpl()->pullInterface(dir), updated);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user