Pot + absolute encoder zeroing class
This class takes a pot, absolute encoder, and relative encoder and uses
them to compute the offset. It doesn't yet detect errors or wait until
stopped.
Change-Id: I74bc2031132974d9f3e2e6ddf93b954384a6ce2c
diff --git a/frc971/control_loops/control_loops.q b/frc971/control_loops/control_loops.q
index f13d82b..f3d224b 100644
--- a/frc971/control_loops/control_loops.q
+++ b/frc971/control_loops/control_loops.q
@@ -44,7 +44,7 @@
// arbitrary 0 position which varies with each robot.
struct PotAndAbsolutePosition {
// Current position read from each encoder.
- double relative_encoder;
+ double encoder;
double absolute_encoder;
// Current position read from the potentiometer.
@@ -64,6 +64,19 @@
double pot_position;
};
+// The internal state of a zeroing estimator.
+struct AbsoluteEstimatorState {
+ // 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 position not using the index pulse.
+ double pot_position;
+};
+
// A left/right pair of PotAndIndexPositions.
struct PotAndIndexPair {
PotAndIndexPosition left;