blob: 4d87587d7576a50e8668931c83abf86aacd033bb [file] [log] [blame]
Brian Silvermane0a95462014-02-17 00:41:09 -08001package frc971;
2
Philipp Schraderfd6335e2017-02-04 01:26:40 +00003// Represents all of the data for a single indexed encoder. In other words,
4// just a relative encoder with an index pulse.
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 IndexPosition {
10 // Current position read from the encoder.
11 double encoder;
12 // Position from the encoder latched at the last index pulse.
13 double latched_encoder;
14 // How many index pulses we've seen since startup. Starts at 0.
15 uint32_t index_pulses;
16};
17
Brian Silverman0a7f6062015-01-24 17:41:33 -050018// Represents all of the data for a single potentiometer and indexed encoder
19// pair.
20// The units on all of the positions are the same.
21// All encoder values are relative to where the encoder was at some arbitrary
22// point in time. All potentiometer values are relative to some arbitrary 0
23// position which varies with each robot.
24struct PotAndIndexPosition {
25 // Current position read from the encoder.
26 double encoder;
27 // Current position read from the potentiometer.
28 double pot;
29
30 // Position from the encoder latched at the last index pulse.
31 double latched_encoder;
32 // Position from the potentiometer latched at the last index pulse.
33 double latched_pot;
34
35 // How many index pulses we've seen since startup. Starts at 0.
36 uint32_t index_pulses;
Brian Silvermane0a95462014-02-17 00:41:09 -080037};
Brian Silverman5b433df2014-02-17 11:57:37 -080038
Diana Vandenbergabb3d192017-01-28 16:19:43 -080039// Represents all of the data for a single potentiometer with an absolute and
40// relative encoder pair.
41// The units on all of the positions are the same.
42// The relative encoder values are relative to where the encoder was at some
43// arbitrary point in time. All potentiometer values are relative to some
44// arbitrary 0 position which varies with each robot.
45struct PotAndAbsolutePosition {
46 // Current position read from each encoder.
Austin Schuh5f01f152017-02-11 21:34:08 -080047 double encoder;
Diana Vandenbergabb3d192017-01-28 16:19:43 -080048 double absolute_encoder;
49
50 // Current position read from the potentiometer.
51 double pot;
52};
53
Daniel Pettiab274232015-02-16 19:15:34 -080054// The internal state of a zeroing estimator.
55struct EstimatorState {
56 // If true, there has been a fatal error for the estimator.
57 bool error;
58 // If the joint has seen an index pulse and is zeroed.
59 bool zeroed;
60 // The estimated position of the joint.
61 double position;
Austin Schuhbe133ed2016-03-11 21:23:34 -080062
63 // The estimated position not using the index pulse.
64 double pot_position;
Daniel Pettiab274232015-02-16 19:15:34 -080065};
66
Austin Schuh5f01f152017-02-11 21:34:08 -080067// The internal state of a zeroing estimator.
68struct AbsoluteEstimatorState {
69 // If true, there has been a fatal error for the estimator.
70 bool error;
71 // If the joint has seen an index pulse and is zeroed.
72 bool zeroed;
73 // The estimated position of the joint.
74 double position;
75
76 // The estimated position not using the index pulse.
77 double pot_position;
Austin Schuh0e1c2c62017-02-21 02:03:25 -080078
79 // The estimated absolute position of the encoder. This is filtered, so it
80 // can be easily used when zeroing.
81 double absolute_position;
Austin Schuh5f01f152017-02-11 21:34:08 -080082};
83
Brian Silvermanf37839c2017-02-19 18:07:15 -080084// The internal state of a zeroing estimator.
85struct IndexEstimatorState {
86 // If true, there has been a fatal error for the estimator.
87 bool error;
88 // If the joint has seen an index pulse and is zeroed.
89 bool zeroed;
90 // The estimated position of the joint. This is just the position relative to
91 // where we started if we're not zeroed yet.
92 double position;
93
94 // The positions of the extreme index pulses we've seen.
95 double min_index_position;
96 double max_index_position;
97 // The number of index pulses we've seen.
98 int32_t index_pulses_seen;
99};
100
Brian Silverman0a7f6062015-01-24 17:41:33 -0500101// A left/right pair of PotAndIndexPositions.
102struct PotAndIndexPair {
103 PotAndIndexPosition left;
104 PotAndIndexPosition right;
Austin Schuh60c56662014-02-17 14:37:19 -0800105};
Brian Silverman17f503e2015-08-02 18:17:18 -0700106
107// Records edges captured on a single hall effect sensor.
108struct HallEffectStruct {
109 bool current;
110 int32_t posedge_count;
111 int32_t negedge_count;
Brian Silvermand3efb182015-05-13 23:04:29 -0400112 double posedge_value;
113 double negedge_value;
Brian Silverman17f503e2015-08-02 18:17:18 -0700114};
115
116// Records the positions for a mechanism with edge-capturing sensors on it.
117struct HallEffectPositions {
118 double current;
119 double posedge;
120 double negedge;
121};
122
123// Records edges captured on a single hall effect sensor.
124struct PosedgeOnlyCountedHallEffectStruct {
125 bool current;
126 int32_t posedge_count;
127 int32_t negedge_count;
128 double posedge_value;
129};
Austin Schuhedbb64f2016-03-19 01:18:09 -0700130
131// Parameters for the motion profiles.
132struct ProfileParameters {
133 // Maximum velocity for the profile.
134 float max_velocity;
135 // Maximum acceleration for the profile.
136 float max_acceleration;
137};