This following example shows how to share a variable between two states. In the Navigate state the “angle_value” variable is set using the template method “setData”. Later, in the ExecuteToolState, it retrieves (gets) the value using the template method “getGlobalSMData”.
struct Navigate : SmaccState<Navigate, SimpleStateMachine> { public: using SmaccState::SmaccState; void onEntry() { double angle = M_PI; this->setGlobalSMData("angle_value", angle); } }; struct ExecuteToolState : SmaccState<ExecuteToolState, SimpleStateMachine> { using SmaccState::SmaccState; void onEntry() { int angle; this->getGlobalSMData("angle_value", angle); } };