Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
statemachine::VerifyingObjectState Class Reference

The VerifyingObjectState class implements the Verifying Object state for the Autonomy State Machine. More...

#include <VerifyingObjectState.h>

Inheritance diagram for statemachine::VerifyingObjectState:
Collaboration diagram for statemachine::VerifyingObjectState:

Public Member Functions

 VerifyingObjectState ()
 Accessor for the State private member. Returns the state as a string.
 
void Run () override
 Run the state machine. Returns the next state.
 
States TriggerEvent (Event eEvent) override
 Trigger an event in the state machine. Returns the next state.
 
- Public Member Functions inherited from statemachine::State
 State (States eState)
 Construct a new State object.
 
virtual ~State ()=default
 Destroy the State object.
 
States GetState () const
 Accessor for the State private member.
 
virtual std::string ToString () const
 Accessor for the State private member. Returns the state as a string.
 
virtual bool operator== (const State &other) const
 Checks to see if the current state is equal to the passed state.
 
virtual bool operator!= (const State &other) const
 Checks to see if the current state is not equal to the passed state.
 

Protected Member Functions

void Start () override
 This method is called when the state is first started. It is used to initialize the state.
 
void Exit () override
 This method is called when the state is exited. It is used to clean up the state.
 

Private Attributes

std::vector< int > m_vObjectIDs
 
int m_nMaxObjectIDs
 
bool m_bInitialized
 

Detailed Description

The VerifyingObjectState class implements the Verifying Object state for the Autonomy State Machine.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Constructor & Destructor Documentation

◆ VerifyingObjectState()

statemachine::VerifyingObjectState::VerifyingObjectState ( )

Accessor for the State private member. Returns the state as a string.

Returns
std::string - The current state as a string.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17
65 : State(States::eVerifyingObject)
66 {
67 LOG_INFO(logging::g_qConsoleLogger, "Entering State: {}", ToString());
68
69 m_bInitialized = false;
70
71 if (!m_bInitialized)
72 {
73 Start();
74 m_bInitialized = true;
75 }
76 }
virtual std::string ToString() const
Accessor for the State private member. Returns the state as a string.
Definition State.hpp:207
State(States eState)
Construct a new State object.
Definition State.hpp:150
void Start() override
This method is called when the state is first started. It is used to initialize the state.
Definition VerifyingObjectState.cpp:31
Here is the call graph for this function:

Member Function Documentation

◆ Start()

void statemachine::VerifyingObjectState::Start ( )
overrideprotectedvirtual

This method is called when the state is first started. It is used to initialize the state.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Reimplemented from statemachine::State.

32 {
33 // Schedule the next run of the state's logic
34 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Scheduling next run of state logic.");
35
36 m_nMaxObjectIDs = 50;
37
38 m_vObjectIDs.reserve(m_nMaxObjectIDs);
39 }
Here is the caller graph for this function:

◆ Exit()

void statemachine::VerifyingObjectState::Exit ( )
overrideprotectedvirtual

This method is called when the state is exited. It is used to clean up the state.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Reimplemented from statemachine::State.

50 {
51 // Clean up the state before exiting
52 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Exiting state.");
53
54 m_vObjectIDs.clear();
55 }
Here is the caller graph for this function:

◆ Run()

void statemachine::VerifyingObjectState::Run ( )
overridevirtual

Run the state machine. Returns the next state.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Implements statemachine::State.

85 {
86 // TODO: Implement the behavior specific to the VerifyingObject state
87 LOG_DEBUG(logging::g_qSharedLogger, "VerifyingObjectState: Running state-specific behavior.");
88 }

◆ TriggerEvent()

States statemachine::VerifyingObjectState::TriggerEvent ( Event  eEvent)
overridevirtual

Trigger an event in the state machine. Returns the next state.

Parameters
eEvent- The event to trigger.
Returns
std::shared_ptr<State> - The next state.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17

Implements statemachine::State.

100 {
101 // Create instance variables.
102 States eNextState = States::eVerifyingObject;
103 bool bCompleteStateExit = true;
104
105 switch (eEvent)
106 {
107 case Event::eStart:
108 {
109 // Submit logger message.
110 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Handling Start event.");
111 // Send multimedia command to update state display.
112 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eAutonomy);
113 break;
114 }
115 case Event::eVerifyingComplete:
116 {
117 // Submit logger message.
118 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Handling Verifying Complete event.");
119 // Send multimedia command to update state display.
120 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eReachedGoal);
121 // Pop old waypoint out of queue.
122 globals::g_pWaypointHandler->PopNextWaypoint();
123 // Change state.
124 eNextState = States::eIdle;
125 break;
126 }
127 case Event::eAbort:
128 {
129 // Submit logger message.
130 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Handling Abort event.");
131 // Send multimedia command to update state display.
132 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eAutonomy);
133 // Change state.
134 eNextState = States::eIdle;
135 break;
136 }
137 default:
138 {
139 LOG_WARNING(logging::g_qSharedLogger, "VerifyingObjectState: Handling unknown event.");
140 eNextState = States::eIdle;
141 break;
142 }
143 }
144
145 if (eNextState != States::eVerifyingObject)
146 {
147 LOG_INFO(logging::g_qSharedLogger, "VerifyingObjectState: Transitioning to {} State.", StateToString(eNextState));
148
149 // Exit the current state
150 if (bCompleteStateExit)
151 {
152 Exit();
153 }
154 }
155
156 return eNextState;
157 }
void SendLightingState(MultimediaBoardLightingState eState)
Sends a predetermined color pattern to board.
Definition MultimediaBoard.cpp:55
geoops::Waypoint PopNextWaypoint()
Removes and returns the next waypoint at the front of the list.
Definition WaypointHandler.cpp:499
void Exit() override
This method is called when the state is exited. It is used to clean up the state.
Definition VerifyingObjectState.cpp:49
std::string StateToString(States eState)
Converts a state object to a string.
Definition State.hpp:89
States
The states that the state machine can be in.
Definition State.hpp:31
Here is the call graph for this function:

The documentation for this class was generated from the following files: