From e2f57b73adebe5ebc36254e9c8460b312ffbbf4d Mon Sep 17 00:00:00 2001 From: Nathan Glenn Date: Wed, 26 Jun 2024 13:18:10 -0500 Subject: [PATCH] handle SVS enable/enable-in-substates interaction When enabling, if enabled in substates then we create SVS states for all states; otherwise just for the top state. When enabling in substates, we create new SVS states for all substates. See #475. --- Core/CLI/src/cli_svs.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Core/CLI/src/cli_svs.cpp b/Core/CLI/src/cli_svs.cpp index a428862714..84bd3aef32 100644 --- a/Core/CLI/src/cli_svs.cpp +++ b/Core/CLI/src/cli_svs.cpp @@ -31,9 +31,17 @@ bool CommandLineInterface::DoSVS(const std::vector& args) else { thisAgent->svs->set_enabled(true); - for (Symbol* lState = thisAgent->top_goal; lState; lState = lState->id->lower_goal) + if (thisAgent->svs->is_enabled_in_substates()) { - thisAgent->svs->state_creation_callback(lState); + // add SVS state for top state and all substates + for (Symbol* lState = thisAgent->top_goal; lState; lState = lState->id->lower_goal) + { + thisAgent->svs->state_creation_callback(lState); + } + } else + { + // add SVS state for top state only + thisAgent->svs->state_creation_callback(thisAgent->top_goal); } m_Result << "Spatial Visual System enabled. "; } @@ -51,6 +59,7 @@ bool CommandLineInterface::DoSVS(const std::vector& args) m_Result << "Cannot disable Spatial Visual System while in a substate. "; return false; } + // Note that this leaves ^svs on the top state thisAgent->svs->set_enabled(false); m_Result << "Spatial Visual System disabled. "; } @@ -65,6 +74,17 @@ bool CommandLineInterface::DoSVS(const std::vector& args) else { thisAgent->svs->set_enabled_in_substates(true); + if (thisAgent->svs->is_enabled()) + { + // add SVS state for all substates + for (Symbol* lState = thisAgent->top_goal; lState; lState = lState->id->lower_goal) + { + if (lState != thisAgent->top_goal) + { + thisAgent->svs->state_creation_callback(lState); + } + } + } m_Result << "Spatial Visual System enabled in substates. "; } }