From 35560d897d911d3c0bf9de57fcd14b4e2373bdf8 Mon Sep 17 00:00:00 2001 From: v4hn Date: Mon, 20 Sep 2021 16:13:57 +0200 Subject: [PATCH] DISABLED -> PRUNED This makes the semantics much clearer as states can only be disabled by pruning. --- core/include/moveit/task_constructor/container_p.h | 2 +- core/include/moveit/task_constructor/storage.h | 3 ++- core/src/container.cpp | 10 +++++----- core/src/stage.cpp | 2 +- core/src/storage.cpp | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/include/moveit/task_constructor/container_p.h b/core/include/moveit/task_constructor/container_p.h index 88ea239a..3b58d0da 100644 --- a/core/include/moveit/task_constructor/container_p.h +++ b/core/include/moveit/task_constructor/container_p.h @@ -148,7 +148,7 @@ protected: child->setNextStarts(allowed ? pending_forward_ : InterfacePtr()); } - /// Set ENABLED / DISABLED status of the solution tree starting from s into given direction + /// Set ENABLED / PRUNED status of the solution tree starting from s into given direction template void setStatus(const InterfaceState* s, InterfaceState::Status status); diff --git a/core/include/moveit/task_constructor/storage.h b/core/include/moveit/task_constructor/storage.h index f115dff6..2d3397bb 100644 --- a/core/include/moveit/task_constructor/storage.h +++ b/core/include/moveit/task_constructor/storage.h @@ -82,7 +82,7 @@ public: enum Status { ENABLED, // state is actively considered during planning - DISABLED, // state is disabled because a required connected state failed + PRUNED, // state is disabled because a required connected state failed FAILED, // state that failed, causing the whole partial solution to be disabled }; /** InterfaceStates are ordered according to two values: @@ -101,6 +101,7 @@ public: inline Status status() const { return std::get<0>(*this); } inline bool enabled() const { return std::get<0>(*this) == ENABLED; } inline bool failed() const { return std::get<0>(*this) == FAILED; } + inline bool pruned() const { return std::get<0>(*this) == PRUNED; } inline unsigned int depth() const { return std::get<1>(*this); } inline double cost() const { return std::get<2>(*this); } diff --git a/core/src/container.cpp b/core/src/container.cpp index 52016014..2377a4c3 100644 --- a/core/src/container.cpp +++ b/core/src/container.cpp @@ -144,7 +144,7 @@ void ContainerBasePrivate::setStatus(const InterfaceState* s, InterfaceState::St return; // nothing changing // if we should disable the state, only do so when there is no enabled alternative path - if (status == InterfaceState::DISABLED) { + if (status == InterfaceState::PRUNED) { auto solution_is_enabled = [](auto&& solution) { return state()>(*solution)->priority().enabled(); }; @@ -177,13 +177,13 @@ void ContainerBasePrivate::setStatus(const InterfaceState* s, InterfaceState::St } // To break symmetry between both ends of a partial solution sequence that gets disabled, - // we mark the first state with FAILED and all other states down the tree only with DISABLED. - // This allows us to re-enable the FAILED side, while not (yet) consider the DISABLED states again, + // we mark the first state with FAILED and all other states down the tree only with PRUNED. + // This allows us to re-enable the FAILED side, while not (yet) consider the PRUNED states again, // when new states arrive in a Connecting stage. - // All DISABLED states are only re-enabled if the FAILED state actually gets connected. + // All PRUNED states are only re-enabled if the FAILED state actually gets connected. // For details, see: https://github.com/ros-planning/moveit_task_constructor/pull/221 if (status == InterfaceState::Status::FAILED) - status = InterfaceState::Status::DISABLED; // only the first state is marked as FAILED + status = InterfaceState::Status::PRUNED; // only the first state is marked as FAILED // traverse solution tree for (const SolutionBase* successor : trajectories(*s)) diff --git a/core/src/stage.cpp b/core/src/stage.cpp index cdda0835..2eaf6a43 100644 --- a/core/src/stage.cpp +++ b/core/src/stage.cpp @@ -712,7 +712,7 @@ ConnectingPrivate::StatePair ConnectingPrivate::make_pair(In template void ConnectingPrivate::newState(Interface::iterator it, bool updated) { if (updated) { // many pairs might be affected: resort - if (it->priority().status() == InterfaceState::DISABLED) + if (it->priority().pruned()) // remove all pending pairs involving this state pending.remove_if([it](const StatePair& p) { return std::get()>(p) == it; }); else diff --git a/core/src/storage.cpp b/core/src/storage.cpp index 372e66a1..a98ffd3c 100644 --- a/core/src/storage.cpp +++ b/core/src/storage.cpp @@ -148,7 +148,7 @@ std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& prio) // maps InterfaceState::Status values to output (color-changing) prefix static const char* prefix[] = { "\033[32me:", // ENABLED - green - "\033[33md:", // DISABLED - yellow + "\033[33md:", // PRUNED - yellow "\033[31mf:", // FAILED - red }; static const char* color_reset = "\033[m";