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>
|
| TimeIntervalBasedStuckDetector (double dMaximumStuckCount=3, double dStuckCheckIntervalSeconds=3, double dVelocityThreshold=0.3, double dAngularVelocityThreshold=5.0) |
| Construct a new Stuck Detector object.
|
|
| ~TimeIntervalBasedStuckDetector () |
| Destroy the Stuck Detector object.
|
|
bool | CheckIfStuck (double dCurrentVelocity, double dCurrentAngularVelocity) |
| Checks if the rover meets stuck criteria based in the given parameters.
|
|
|
double | m_dMaximumStuckCount |
|
double | m_dStuckCheckIntervalSeconds |
|
double | m_dVelocityThreshold |
|
double | m_dAngularVelocityThreshold |
|
unsigned int | m_unStuckChecksSoFar |
|
std::chrono::system_clock::time_point | m_tmTimeSinceLastStuckCheck |
|
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
◆ TimeIntervalBasedStuckDetector()
statemachine::TimeIntervalBasedStuckDetector::TimeIntervalBasedStuckDetector |
( |
double |
dMaximumStuckCount = 3 , |
|
|
double |
dStuckCheckIntervalSeconds = 3 , |
|
|
double |
dVelocityThreshold = 0.3 , |
|
|
double |
dAngularVelocityThreshold = 5.0 |
|
) |
| |
|
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. |
dVelocityThreshold | - The minimum linear velocity that is considered still moving. (m/s) |
dAngularVelocityThreshold | - The minimum angular velocity that is considered still rotating. (deg/s) |
- Author
- clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
- Date
- 2024-04-23
76 {
77
78 m_dMaximumStuckCount = dMaximumStuckCount;
79 m_dStuckCheckIntervalSeconds = dStuckCheckIntervalSeconds;
80 m_dVelocityThreshold = dVelocityThreshold;
81 m_dAngularVelocityThreshold = dAngularVelocityThreshold;
82 m_unStuckChecksSoFar = 0;
83 m_tmTimeSinceLastStuckCheck = std::chrono::system_clock::now();
84 }
◆ ~TimeIntervalBasedStuckDetector()
statemachine::TimeIntervalBasedStuckDetector::~TimeIntervalBasedStuckDetector |
( |
| ) |
|
|
inline |
◆ CheckIfStuck()
bool statemachine::TimeIntervalBasedStuckDetector::CheckIfStuck |
( |
double |
dCurrentVelocity, |
|
|
double |
dCurrentAngularVelocity |
|
) |
| |
|
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
106 {
107
108 bool bStuck = false;
109
110
111 std::chrono::system_clock::time_point tmCurrentTime = std::chrono::system_clock::now();
112 double dTimeSinceLastCheck = static_cast<double>(std::chrono::duration_cast<std::chrono::seconds>(tmCurrentTime - m_tmTimeSinceLastStuckCheck).count());
113 if (dTimeSinceLastCheck > m_dStuckCheckIntervalSeconds)
114 {
115
116 m_tmTimeSinceLastStuckCheck = tmCurrentTime;
117
118
119 if (std::abs(dCurrentVelocity) < m_dVelocityThreshold && std::abs(dCurrentAngularVelocity) < m_dAngularVelocityThreshold)
120 {
121 ++m_unStuckChecksSoFar;
122 }
123 else
124 {
125 m_unStuckChecksSoFar = 0;
126 }
127 }
128
129
130 if (m_unStuckChecksSoFar > m_dMaximumStuckCount)
131 {
132
133 m_unStuckChecksSoFar = 0;
134
135 bStuck = true;
136 }
137
138
139 return bStuck;
140 }
The documentation for this class was generated from the following file: