Now detecting reset using the sensor_generation queue.
diff --git a/aos/common/control_loop/ControlLoop.h b/aos/common/control_loop/ControlLoop.h
index e48d259..c9e3381 100644
--- a/aos/common/control_loop/ControlLoop.h
+++ b/aos/common/control_loop/ControlLoop.h
@@ -60,8 +60,10 @@
// Maximum age of driver station packets before the loop will be disabled.
static const int kDSPacketTimeoutMs = 500;
- ControlLoop(T *control_loop) : control_loop_(control_loop) {}
-
+ ControlLoop(T *control_loop)
+ : control_loop_(control_loop),
+ reset_(true),
+ has_sensor_reset_counters_(false) {}
// Create some convenient typedefs to reference the Goal, Position, Status,
// and Output structures.
typedef typename std::remove_reference<
@@ -81,6 +83,14 @@
// motors. Calls Zero to clear all the state.
void ZeroOutputs();
+ // Returns true if the device reading the sensors reset and potentially lost
+ // track of encoder counts. Calling this read method clears the flag.
+ bool reset() {
+ bool ans = reset_;
+ reset_ = false;
+ return ans;
+ }
+
// Sets the output to zero.
// Over-ride if a value of zero is not "off" for this subsystem.
virtual void Zero(OutputType *output) { output->Zero(); }
@@ -131,6 +141,11 @@
// Pointer to the queue group
T *control_loop_;
+ bool reset_;
+ bool has_sensor_reset_counters_;
+ int32_t reader_pid_;
+ uint32_t cape_resets_;
+
typedef ::aos::util::SimpleLogInterval SimpleLogInterval;
static constexpr ::aos::time::Time kStaleLogInterval =
::aos::time::Time::InSeconds(0.1);