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

This class should be instantiated within another state to be used for detection of if the rover is stuck. Stuck detection is solely based off of a check interval on the current velocity and rotation. If the velocity and rotation are non-moving for more then a maximum interval count, we are considered stuck. More...

#include <StuckDetection.hpp>

Public Member Functions

 TimeIntervalBasedStuckDetector (double dMaximumStuckCount=3, double dStuckCheckIntervalSeconds=3)
 Construct a new Stuck Detector object.
 
 ~TimeIntervalBasedStuckDetector ()
 Destroy the Stuck Detector object.
 
bool CheckIfStuck (double dCurrentVelocity, double dCurrentAngularVelocity, double dVelocityThreshold=0.1, double dAngularVelocityThreshold=0.1)
 Checks if the rover meets stuck criteria based in the given parameters.
 
void ResetStuckChecks ()
 Reset stuck variables so rover does not go into stuck-state next check of CheckIfStuck.
 

Private Attributes

double m_dMaximumStuckCount
 
double m_dStuckCheckIntervalSeconds
 
unsigned int m_unStuckChecksSoFar
 
std::chrono::system_clock::time_point m_tmTimeSinceLastStuckCheck
 

Detailed Description

This class should be instantiated within another state to be used for detection of if the rover is stuck. Stuck detection is solely based off of a check interval on the current velocity and rotation. If the velocity and rotation are non-moving for more then a maximum interval count, we are considered stuck.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-23

Constructor & Destructor Documentation

◆ TimeIntervalBasedStuckDetector()

statemachine::TimeIntervalBasedStuckDetector::TimeIntervalBasedStuckDetector ( double  dMaximumStuckCount = 3,
double  dStuckCheckIntervalSeconds = 3 
)
inline

Construct a new Stuck Detector object.

Parameters
dMaximumStuckCount- The maximum number of times the rover can be not moving upon check interval before it is considered stuck.
dStuckCheckIntervalSeconds- The interval in seconds that the function should check the current rover velocity and angular movement.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-23
69 {
70 // Initialize member variables.
71 m_dMaximumStuckCount = dMaximumStuckCount;
72 m_dStuckCheckIntervalSeconds = dStuckCheckIntervalSeconds;
73 m_unStuckChecksSoFar = 0;
74 m_tmTimeSinceLastStuckCheck = std::chrono::system_clock::now();
75 }

◆ ~TimeIntervalBasedStuckDetector()

statemachine::TimeIntervalBasedStuckDetector::~TimeIntervalBasedStuckDetector ( )
inline

Destroy the Stuck Detector object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-23
84{}

Member Function Documentation

◆ CheckIfStuck()

bool statemachine::TimeIntervalBasedStuckDetector::CheckIfStuck ( double  dCurrentVelocity,
double  dCurrentAngularVelocity,
double  dVelocityThreshold = 0.1,
double  dAngularVelocityThreshold = 0.1 
)
inline

Checks if the rover meets stuck criteria based in the given parameters.

Returns
true - The rover is stuck.
false - The is not stuck.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om), Jason Pittman (jspen.nosp@m.cerp.nosp@m.ittma.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-23
97 {
98 // Create instance variables.
99 bool bStuck = false;
100
101 // Time since we last checked if the rover is stuck.
102 std::chrono::system_clock::time_point tmCurrentTime = std::chrono::system_clock::now();
103 double dTimeSinceLastCheck = std::chrono::duration_cast<std::chrono::milliseconds>(tmCurrentTime - m_tmTimeSinceLastStuckCheck).count() / 1000.0;
104 if (dTimeSinceLastCheck > m_dStuckCheckIntervalSeconds)
105 {
106 // Update time since last check to now.
107 m_tmTimeSinceLastStuckCheck = tmCurrentTime;
108
109 // Check if the rover is rotating or moving linearly.
110 if (std::abs(dCurrentVelocity) < dVelocityThreshold && std::abs(dCurrentAngularVelocity) < dAngularVelocityThreshold)
111 {
112 ++m_unStuckChecksSoFar;
113 }
114 else
115 {
116 m_unStuckChecksSoFar = 0;
117 }
118 }
119
120 // Check if we met stuck criteria.
121 if (m_unStuckChecksSoFar > m_dMaximumStuckCount)
122 {
123 // Reset stuck checks.
124 m_unStuckChecksSoFar = 0;
125 // Set stuck toggle.
126 bStuck = true;
127 }
128
129 // Return if stuck or not.
130 return bStuck;
131 }
Here is the caller graph for this function:

◆ ResetStuckChecks()

void statemachine::TimeIntervalBasedStuckDetector::ResetStuckChecks ( )
inline

Reset stuck variables so rover does not go into stuck-state next check of CheckIfStuck.

Author
Sam Nolte (samno.nosp@m.lte0.nosp@m.302@g.nosp@m.mail.nosp@m..com)
Date
2026-04-17
140{ m_unStuckChecksSoFar = 0; }

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