44 #include <g2o/stuff/misc.h> 57 measurement.
v = twist.linear.x;
58 measurement.
omega = twist.angular.z;
60 if (measurement.
v > 0 && v_max>0)
61 measurement.
v /= v_max;
62 else if (measurement.
v < 0 && v_backwards_max > 0)
63 measurement.
v /= v_backwards_max;
66 measurement.
omega /= omega_max;
92 double n = (double)
buffer_.size();
97 int omega_zero_crossings = 0;
98 for (
int i=0; i < n; ++i)
101 omega_mean +=
buffer_[i].omega;
103 ++omega_zero_crossings;
108 if (std::abs(v_mean) < v_eps && std::abs(omega_mean) < omega_eps && omega_zero_crossings>1 )
bool detect(double v_eps, double omega_eps)
Detect if the robot got stucked based on the current buffer content.
void update(const geometry_msgs::Twist &twist, double v_max, double v_backwards_max, double omega_max, double v_eps, double omega_eps)
Add a new twist measurement to the internal buffer and compute a new decision.
boost::circular_buffer< VelMeasurement > buffer_
Circular buffer to store the last measurements.
void clear()
Clear the current internal state.
bool oscillating_
Current state: true if robot is oscillating.
bool isOscillating() const
Check if the robot got stucked.