blob: 05a660b71fa5e0cbddd39a6b5a7283d75c257059 [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
Diana Vandenbergabb3d192017-01-28 16:19:43 -080024// Represents all of the data for a single potentiometer with an absolute and
25// relative encoder pair.
26// The units on all of the positions are the same.
27// The relative encoder values are relative to where the encoder was at some
28// arbitrary point in time. All potentiometer values are relative to some
29// arbitrary 0 position which varies with each robot.
30struct PotAndAbsolutePosition {
31 // Current position read from each encoder.
32 double relative_encoder;
33 double absolute_encoder;
34
35 // Current position read from the potentiometer.
36 double pot;
37};
38
Daniel Pettiab274232015-02-16 19:15:34 -080039// The internal state of a zeroing estimator.
40struct EstimatorState {
41 // If true, there has been a fatal error for the estimator.
42 bool error;
43 // If the joint has seen an index pulse and is zeroed.
44 bool zeroed;
45 // The estimated position of the joint.
46 double position;
Austin Schuhbe133ed2016-03-11 21:23:34 -080047
48 // The estimated position not using the index pulse.
49 double pot_position;
Daniel Pettiab274232015-02-16 19:15:34 -080050};
51
Brian Silverman0a7f6062015-01-24 17:41:33 -050052// A left/right pair of PotAndIndexPositions.
53struct PotAndIndexPair {
54 PotAndIndexPosition left;
55 PotAndIndexPosition right;
Austin Schuh60c56662014-02-17 14:37:19 -080056};
Brian Silverman17f503e2015-08-02 18:17:18 -070057
58// Records edges captured on a single hall effect sensor.
59struct HallEffectStruct {
60 bool current;
61 int32_t posedge_count;
62 int32_t negedge_count;
Brian Silvermand3efb182015-05-13 23:04:29 -040063 double posedge_value;
64 double negedge_value;
Brian Silverman17f503e2015-08-02 18:17:18 -070065};
66
67// Records the positions for a mechanism with edge-capturing sensors on it.
68struct HallEffectPositions {
69 double current;
70 double posedge;
71 double negedge;
72};
73
74// Records edges captured on a single hall effect sensor.
75struct PosedgeOnlyCountedHallEffectStruct {
76 bool current;
77 int32_t posedge_count;
78 int32_t negedge_count;
79 double posedge_value;
80};
Austin Schuhedbb64f2016-03-19 01:18:09 -070081
82// Parameters for the motion profiles.
83struct ProfileParameters {
84 // Maximum velocity for the profile.
85 float max_velocity;
86 // Maximum acceleration for the profile.
87 float max_acceleration;
88};