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
StuckState.h
Go to the documentation of this file.
1
11#ifndef STUCK_STATE_H
12#define STUCK_STATE_H
13
14#include "../interfaces/State.hpp"
15#include "../util/GeospatialOperations.hpp"
16
18#include <chrono>
19
21
22
28namespace statemachine
29{
30
37 class StuckState : public State
38 {
39 private:
41 // Declare private enums and structs that are specific to and used withing this class.
43
44 enum class AttemptType
45 {
46 eReverseCurrentHeading,
47 eReverseLeft,
48 eReverseRight,
49 eGiveUp
50 };
51
53 // Declare private member variables.
55 bool m_bInitialized;
56 States m_eTriggeringState; // The state that the rover got stuck in before triggering a stuck event.
57 AttemptType m_eAttemptType; // Current attempt we are on for a given position.
58 geoops::GPSCoordinate m_stOriginalPosition; // Original position where rover was reported stuck.
59 double m_dOriginalHeading; // Original heading the rover was at when reported stuck.
60 bool m_bIsCurrentlyAligning; // Is the rover currently trying to align with a target heading.
61 std::chrono::system_clock::time_point m_tmStuckStartTime; // The timestamp storing when the rover starting stuck state.
62 std::chrono::system_clock::time_point m_tmAlignStartTime; // The timestamp storing when the rover starting realigning.
63
65 // Declare private class methods.
67 bool SamePosition(const geoops::GPSCoordinate& stOriginalPosition, const geoops::GPSCoordinate& stCurrPosition);
68
69 protected:
71 // Declare protected class methods.
73 void Start() override;
74 void Exit() override;
75
76 public:
78 // Declare public class methods.
80 StuckState();
81 void Run() override;
82 States TriggerEvent(Event eEvent) override;
83 };
84} // namespace statemachine
85
86#endif // STUCKSTATE_H
The abstract state class. All states inherit from this class.
Definition State.hpp:115
The StuckState class implements the Stuck state for the Autonomy State Machine.
Definition StuckState.h:38
void Run() override
Run the state machine. Returns the next state.
Definition StuckState.cpp:97
StuckState()
Construct a new State object.
Definition StuckState.cpp:78
void Exit() override
This method is called when the state is exited. It is used to clean up the state.
Definition StuckState.cpp:65
bool SamePosition(const geoops::GPSCoordinate &stOriginalPosition, const geoops::GPSCoordinate &stCurrPosition)
Checks if the rover is approximately in the same position.
Definition StuckState.cpp:364
void Start() override
This method is called when the state is first started. It is used to initialize the state.
Definition StuckState.cpp:33
States TriggerEvent(Event eEvent) override
Trigger an event in the state machine. Returns the next state.
Definition StuckState.cpp:286
Namespace containing all state machine related classes.
Definition State.hpp:23
Event
The events that can be triggered in the state machine.
Definition State.hpp:54
States
The states that the state machine can be in.
Definition State.hpp:31
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:148