Class state_tracker

Inheritance Relationships

Derived Types

Class Documentation

class state_tracker

Utility class for tracking when a robot enters/exits a state of some kind (e.g., collision avoidance), and the time spent in that state. Not limited to FSM states. Used to have the logic to track state enter and exit in a single place.

Subclassed by cosm::spatial::interference_tracker, cosm::spatial::nest_zone_tracker

Public Functions

inline explicit state_tracker(const csubsystem::sensing_subsystem *const sensing)
state_tracker(const state_tracker&) = delete
virtual ~state_tracker(void) = default
bool entered_state(void) const
bool exited_state(void) const
bool in_state(void) const
state_tracker &operator=(const state_tracker&) = delete
rtypes::timestep state_duration(void) const
void state_enter(void)

Handle all logic for entering the state; classes should only have to call this function whenever the condition for triggering entry into the state is detected. If the robot is already in the state, nothing happens.

rtypes::timestep state_entry_time(void) const
void state_exit(void)

Handle all logic for exiting the state; classes should only have to call this function whenever the trigger conditions for being in the state no longer exist/the condition for leaving the state is triggered.

rmath::vector3z state_loc3D(void) const

Get the robot’s location. Useful for capturing loction on state entry/exit.

void state_reset(void)

Resets the state tracker to “not in state” regardless of what state it is currently in.