12#ifndef STUCK_DETECTION_HPP
13#define STUCK_DETECTION_HPP
49 double m_dMaximumStuckCount;
50 double m_dStuckCheckIntervalSeconds;
51 unsigned int m_unStuckChecksSoFar;
52 std::chrono::system_clock::time_point m_tmTimeSinceLastStuckCheck;
71 m_dMaximumStuckCount = dMaximumStuckCount;
72 m_dStuckCheckIntervalSeconds = dStuckCheckIntervalSeconds;
73 m_unStuckChecksSoFar = 0;
74 m_tmTimeSinceLastStuckCheck = std::chrono::system_clock::now();
96 bool CheckIfStuck(
double dCurrentVelocity,
double dCurrentAngularVelocity,
double dVelocityThreshold = 0.1,
double dAngularVelocityThreshold = 0.1)
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)
107 m_tmTimeSinceLastStuckCheck = tmCurrentTime;
110 if (std::abs(dCurrentVelocity) < dVelocityThreshold && std::abs(dCurrentAngularVelocity) < dAngularVelocityThreshold)
112 ++m_unStuckChecksSoFar;
116 m_unStuckChecksSoFar = 0;
121 if (m_unStuckChecksSoFar > m_dMaximumStuckCount)
124 m_unStuckChecksSoFar = 0;
This class should be instantiated within another state to be used for detection of if the rover is st...
Definition StuckDetection.hpp:43
~TimeIntervalBasedStuckDetector()
Destroy the Stuck Detector object.
Definition StuckDetection.hpp:84
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.
Definition StuckDetection.hpp:96
void ResetStuckChecks()
Reset stuck variables so rover does not go into stuck-state next check of CheckIfStuck.
Definition StuckDetection.hpp:140
TimeIntervalBasedStuckDetector(double dMaximumStuckCount=3, double dStuckCheckIntervalSeconds=3)
Construct a new Stuck Detector object.
Definition StuckDetection.hpp:68
Namespace containing all state machine related classes.
Definition State.hpp:23