Skip to content

Commit b82b70e

Browse files
committed
FallbacksPrivate::nextChild()
... factoring out functionality shared between FallbacksPrivateGenerator and FallbacksPrivatePropagator to switch to next child in nextJob().
1 parent 7af3d8e commit b82b70e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

core/include/moveit/task_constructor/container_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class FallbacksPrivate : public ParallelContainerBasePrivate
257257
// methods common to all variants
258258
void initializeExternalInterfaces() final;
259259
void onNewFailure(const Stage& child, const InterfaceState* from, const InterfaceState* to) override;
260+
void nextChild(); /// << Advance to next child
260261

261262
// virtual methods specific to each variant
262263
/// Advance to the next job, assuming that the current child is exhausted on the current job.

core/src/container.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void ContainerBasePrivate::setStatus(const InterfaceState* s, InterfaceState::St
219219

220220
// if possible (i.e. if state s has an external counterpart), escalate setStatus to external interface
221221
if (parent() && trajectories<dir>(*s).empty()) {
222+
// TODO: This was coded with SerialContainer in mind. Not sure, it works for ParallelContainers
222223
auto external{ internalToExternalMap().find(s) };
223224
if (external != internalToExternalMap().end()) { // do we have an external state?
224225
// only escalate if there is no other *enabled* internal state connected to the same external one
@@ -928,6 +929,11 @@ void FallbacksPrivate::onNewFailure(const Stage& child, const InterfaceState* /*
928929
(void)child;
929930
}
930931

932+
void FallbacksPrivate::nextChild() {
933+
if (std::next(current_) != children().end())
934+
ROS_DEBUG_STREAM_NAMED("Fallbacks", "Child '" << (*current_)->name() << "' failed, trying next one.");
935+
++current_; // advance to next child
936+
}
931937

932938
FallbacksPrivateGenerator::FallbacksPrivateGenerator(FallbacksPrivate&& old)
933939
: FallbacksPrivate(std::move(old)) { reset(); }
@@ -941,11 +947,8 @@ bool FallbacksPrivateGenerator::nextJob() {
941947
return false;
942948
}
943949

944-
do {
945-
if (std::next(current_) != children().end())
946-
ROS_DEBUG_STREAM_NAMED("Fallbacks", "Generator '" << (*current_)->name() << "' failed, trying next one.");
947-
++current_; // advance to next child
948-
} while (current_ != children().end() && !(*current_)->pimpl()->canCompute());
950+
do { nextChild(); }
951+
while (current_ != children().end() && !(*current_)->pimpl()->canCompute());
949952

950953
// return value shall indicate current_->canCompute()
951954
return current_ != children().end();
@@ -979,11 +982,9 @@ bool FallbacksPrivatePropagator::nextJob() {
979982
const auto jobs = pullInterface(dir_);
980983

981984
if (job_ != jobs->end()) { // current job exists, but is exhausted on current child
982-
if (!job_has_solutions_) { // job didn't produce solutions -> feed to next child
983-
if (std::next(current_) != children().end())
984-
ROS_DEBUG_STREAM_NAMED("Fallbacks", "Propagator '" << (*current_)->name() << "' failed, trying next one.");
985-
++current_; // advance to next child
986-
} else
985+
if (!job_has_solutions_) // job didn't produce solutions -> feed to next child
986+
nextChild();
987+
else
987988
current_ = children().end(); // indicate that this job is exhausted on all children
988989
}
989990
job_has_solutions_ = false;

0 commit comments

Comments
 (0)