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::ApproachingObjectState Class Reference

The ApproachingObjectState class implements the Approaching Object state for the Autonomy State Machine. More...

#include <ApproachingObjectState.h>

Inheritance diagram for statemachine::ApproachingObjectState:
Collaboration diagram for statemachine::ApproachingObjectState:

Public Member Functions

 ApproachingObjectState ()
 Construct a new State object.
 
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

int m_nNumDetectionAttempts
 
bool m_bInitialized
 

Detailed Description

The ApproachingObjectState class implements the Approaching 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

◆ ApproachingObjectState()

statemachine::ApproachingObjectState::ApproachingObjectState ( )

Construct a new State object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2024-01-17
59 : State(States::eApproachingObject)
60 {
61 LOG_INFO(logging::g_qConsoleLogger, "Entering State: {}", ToString());
62
63 m_bInitialized = false;
64
65 if (!m_bInitialized)
66 {
67 Start();
68 m_bInitialized = true;
69 }
70 }
void Start() override
This method is called when the state is first started. It is used to initialize the state.
Definition ApproachingObjectState.cpp:30
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
Here is the call graph for this function:

Member Function Documentation

◆ Start()

void statemachine::ApproachingObjectState::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.

31 {
32 // Schedule the next run of the state's logic
33 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Scheduling next run of state logic.");
34
35 m_nNumDetectionAttempts = 0;
36 }
Here is the caller graph for this function:

◆ Exit()

void statemachine::ApproachingObjectState::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.

47 {
48 // Clean up the state before exiting
49 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Exiting state.");
50 }
Here is the caller graph for this function:

◆ Run()

void statemachine::ApproachingObjectState::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.

79 {
80 // TODO: Implement the behavior specific to the Approaching Object state.
81 LOG_DEBUG(logging::g_qSharedLogger, "ApproachingObjectState: Running state-specific behavior.");
82 }

◆ TriggerEvent()

States statemachine::ApproachingObjectState::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.

94 {
95 // Create instance variables.
96 States eNextState = States::eIdle;
97 bool bCompleteStateExit = true;
98
99 switch (eEvent)
100 {
101 case Event::eReachedObject:
102 {
103 // Submit logger message.
104 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Handling ReachedObject event.");
105 // Pop old waypoint out of queue.
106 globals::g_pWaypointHandler->PopNextWaypoint();
107 // Change state.
108 eNextState = States::eIdle;
109 break;
110 }
111 case Event::eStart:
112 {
113 // Submit logger message.
114 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Handling Start event.");
115 // Send multimedia command to update state display.
116 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eAutonomy);
117 break;
118 }
119 case Event::eAbort:
120 {
121 // Submit logger message.
122 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Handling Abort event.");
123 // Send multimedia command to update state display.
124 globals::g_pMultimediaBoard->SendLightingState(MultimediaBoard::MultimediaBoardLightingState::eAutonomy);
125 // Change state.
126 eNextState = States::eIdle;
127 break;
128 }
129 case Event::eObjectUnseen:
130 {
131 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Handling ObjectUnseen event.");
132 eNextState = States::eSearchPattern;
133 break;
134 }
135 case Event::eMarkerSeen:
136 {
137 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Handling Abort event.");
138 eNextState = States::eIdle;
139 break;
140 }
141 default:
142 {
143 LOG_WARNING(logging::g_qSharedLogger, "ApproachingObjectState: Handling unknown event.");
144 eNextState = States::eIdle;
145 break;
146 }
147 }
148
149 if (eNextState != States::eIdle)
150 {
151 LOG_INFO(logging::g_qSharedLogger, "ApproachingObjectState: Transitioning to {} State.", StateToString(eNextState));
152
153 // Exit the current state
154 if (bCompleteStateExit)
155 {
156 Exit();
157 }
158 }
159
160 return eNextState;
161 }
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 ApproachingObjectState.cpp:46
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: