Skip to content

Commit

Permalink
handle SVS enable/enable-in-substates interaction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
garfieldnate committed Jun 26, 2024
1 parent 21fe816 commit e2f57b7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Core/CLI/src/cli_svs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ bool CommandLineInterface::DoSVS(const std::vector<std::string>& 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. ";
}
Expand All @@ -51,6 +59,7 @@ bool CommandLineInterface::DoSVS(const std::vector<std::string>& 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. ";
}
Expand All @@ -65,6 +74,17 @@ bool CommandLineInterface::DoSVS(const std::vector<std::string>& 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. ";
}
}
Expand Down

0 comments on commit e2f57b7

Please sign in to comment.