Add single mag encoder zeroing method
This assumes the mag encoder doesn't move more than 1 revolution.
Change-Id: I932f4ea0e6457a4ac3430c35b7bfda7e6eb1b5c4
diff --git a/frc971/control_loops/control_loops.q b/frc971/control_loops/control_loops.q
index bebecd0..44eb262 100644
--- a/frc971/control_loops/control_loops.q
+++ b/frc971/control_loops/control_loops.q
@@ -51,6 +51,16 @@
double pot;
};
+// Represents all of the data for an absolute and relative encoder pair.
+// The units on all of the positions are the same.
+// The relative encoder values are relative to where the encoder was at some
+// arbitrary point in time.
+struct AbsolutePosition {
+ // Current position read from each encoder.
+ double encoder;
+ double absolute_encoder;
+};
+
// The internal state of a zeroing estimator.
struct EstimatorState {
// If true, there has been a fatal error for the estimator.
@@ -82,6 +92,20 @@
};
// The internal state of a zeroing estimator.
+struct AbsoluteEncoderEstimatorState {
+ // If true, there has been a fatal error for the estimator.
+ bool error;
+ // If the joint has seen an index pulse and is zeroed.
+ bool zeroed;
+ // The estimated position of the joint.
+ double position;
+
+ // The estimated absolute position of the encoder. This is filtered, so it
+ // can be easily used when zeroing.
+ double absolute_position;
+};
+
+// The internal state of a zeroing estimator.
struct IndexEstimatorState {
// If true, there has been a fatal error for the estimator.
bool error;