blob: 37a64200027c8634a366ab17de016c068dd45de1 [file] [log] [blame]
Brian Silvermane0a95462014-02-17 00:41:09 -08001package frc971;
2
Brian Silverman0a7f6062015-01-24 17:41:33 -05003// Represents all of the data for a single potentiometer and indexed encoder
4// pair.
5// The units on all of the positions are the same.
6// All encoder values are relative to where the encoder was at some arbitrary
7// point in time. All potentiometer values are relative to some arbitrary 0
8// position which varies with each robot.
9struct PotAndIndexPosition {
10 // Current position read from the encoder.
11 double encoder;
12 // Current position read from the potentiometer.
13 double pot;
14
15 // Position from the encoder latched at the last index pulse.
16 double latched_encoder;
17 // Position from the potentiometer latched at the last index pulse.
18 double latched_pot;
19
20 // How many index pulses we've seen since startup. Starts at 0.
21 uint32_t index_pulses;
Brian Silvermane0a95462014-02-17 00:41:09 -080022};
Brian Silverman5b433df2014-02-17 11:57:37 -080023
Daniel Pettiab274232015-02-16 19:15:34 -080024// The internal state of a zeroing estimator.
25struct EstimatorState {
26 // If true, there has been a fatal error for the estimator.
27 bool error;
28 // If the joint has seen an index pulse and is zeroed.
29 bool zeroed;
30 // The estimated position of the joint.
31 double position;
32};
33
Brian Silverman0a7f6062015-01-24 17:41:33 -050034// A left/right pair of PotAndIndexPositions.
35struct PotAndIndexPair {
36 PotAndIndexPosition left;
37 PotAndIndexPosition right;
Austin Schuh60c56662014-02-17 14:37:19 -080038};
Brian Silverman17f503e2015-08-02 18:17:18 -070039
40// Records edges captured on a single hall effect sensor.
41struct HallEffectStruct {
42 bool current;
43 int32_t posedge_count;
44 int32_t negedge_count;
Brian Silvermand3efb182015-05-13 23:04:29 -040045 double posedge_value;
46 double negedge_value;
Brian Silverman17f503e2015-08-02 18:17:18 -070047};
48
49// Records the positions for a mechanism with edge-capturing sensors on it.
50struct HallEffectPositions {
51 double current;
52 double posedge;
53 double negedge;
54};
55
56// Records edges captured on a single hall effect sensor.
57struct PosedgeOnlyCountedHallEffectStruct {
58 bool current;
59 int32_t posedge_count;
60 int32_t negedge_count;
61 double posedge_value;
62};