blob: f5100855bd61249534fe96f384edfc3ed96899cc [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001namespace frc971;
Brian Silvermane0a95462014-02-17 00:41:09 -08002
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.
Alex Perrycb7da4b2019-08-28 19:35:56 -07009table IndexPosition {
Philipp Schraderfd6335e2017-02-04 01:26:40 +000010 // Current position read from the encoder.
Alex Perrycb7da4b2019-08-28 19:35:56 -070011 encoder:double;
Philipp Schraderfd6335e2017-02-04 01:26:40 +000012 // Position from the encoder latched at the last index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070013 latched_encoder:double;
Philipp Schraderfd6335e2017-02-04 01:26:40 +000014 // How many index pulses we've seen since startup. Starts at 0.
Alex Perrycb7da4b2019-08-28 19:35:56 -070015 index_pulses:uint;
16}
Philipp Schraderfd6335e2017-02-04 01:26:40 +000017
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.
Alex Perrycb7da4b2019-08-28 19:35:56 -070024table PotAndIndexPosition {
Brian Silverman0a7f6062015-01-24 17:41:33 -050025 // Current position read from the encoder.
Alex Perrycb7da4b2019-08-28 19:35:56 -070026 encoder:double;
Brian Silverman0a7f6062015-01-24 17:41:33 -050027 // Current position read from the potentiometer.
Alex Perrycb7da4b2019-08-28 19:35:56 -070028 pot:double;
Brian Silverman0a7f6062015-01-24 17:41:33 -050029
30 // Position from the encoder latched at the last index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070031 latched_encoder:double;
Brian Silverman0a7f6062015-01-24 17:41:33 -050032 // Position from the potentiometer latched at the last index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070033 latched_pot:double;
Brian Silverman0a7f6062015-01-24 17:41:33 -050034
35 // How many index pulses we've seen since startup. Starts at 0.
Alex Perrycb7da4b2019-08-28 19:35:56 -070036 index_pulses:uint;
37}
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.
Alex Perrycb7da4b2019-08-28 19:35:56 -070045table PotAndAbsolutePosition {
Diana Vandenbergabb3d192017-01-28 16:19:43 -080046 // Current position read from each encoder.
Alex Perrycb7da4b2019-08-28 19:35:56 -070047 encoder:double;
48 absolute_encoder:double;
Diana Vandenbergabb3d192017-01-28 16:19:43 -080049
50 // Current position read from the potentiometer.
Alex Perrycb7da4b2019-08-28 19:35:56 -070051 pot:double;
52}
Diana Vandenbergabb3d192017-01-28 16:19:43 -080053
Austin Schuhd82068e2019-01-26 20:05:42 -080054// Represents all of the data for an absolute and relative encoder pair.
55// The units on all of the positions are the same.
56// The relative encoder values are relative to where the encoder was at some
57// arbitrary point in time.
Alex Perrycb7da4b2019-08-28 19:35:56 -070058table AbsolutePosition {
Austin Schuhd82068e2019-01-26 20:05:42 -080059 // Current position read from each encoder.
Alex Perrycb7da4b2019-08-28 19:35:56 -070060 encoder:double;
61 absolute_encoder:double;
62}
Austin Schuhd82068e2019-01-26 20:05:42 -080063
Ravago Jones988b0382020-10-10 15:33:40 -070064// Represents all of the data for an absolute and relative encoder pair,
65// along with an absolute encoder.
66// They operate similarly to a pot and absolute encoder, but another absolute
67// encoder is used in place of the potentiometer.
68// The units on all of the positions are the same.
69// The relative encoder values are relative to where the encoder was at some
70// arbitrary point in time.
71table AbsoluteAndAbsolutePosition {
72 // Current position read from each encoder.
73 encoder:double;
74 absolute_encoder:double;
75
76 // Current position read from the single turn absolute encoder.
77 // This can not turn more than one rotation.
78 single_turn_absolute_encoder:double;
79}
80
Tyler Chatow3c47f3c2020-01-29 20:45:23 -080081// Represents all of the data for a single encoder.
82// The relative encoder values are relative to where the encoder was at some
83// arbitrary point in time.
84table RelativePosition {
85 // Current position read from the encoder.
86 encoder:double;
87}
88
Daniel Pettiab274232015-02-16 19:15:34 -080089// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070090table EstimatorState {
Daniel Pettiab274232015-02-16 19:15:34 -080091 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070092 error:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080093 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070094 zeroed:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080095 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -070096 position:double;
Austin Schuhbe133ed2016-03-11 21:23:34 -080097
98 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070099 pot_position:double;
100}
Daniel Pettiab274232015-02-16 19:15:34 -0800101
Austin Schuh5f01f152017-02-11 21:34:08 -0800102// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700103table PotAndAbsoluteEncoderEstimatorState {
Austin Schuh5f01f152017-02-11 21:34:08 -0800104 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700105 error:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -0800106 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700107 zeroed:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -0800108 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700109 position:double;
Austin Schuh5f01f152017-02-11 21:34:08 -0800110
111 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700112 pot_position:double;
Austin Schuh0e1c2c62017-02-21 02:03:25 -0800113
114 // The estimated absolute position of the encoder. This is filtered, so it
115 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700116 absolute_position:double;
117}
Austin Schuh5f01f152017-02-11 21:34:08 -0800118
Brian Silvermanf37839c2017-02-19 18:07:15 -0800119// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700120table AbsoluteEncoderEstimatorState {
Austin Schuhd82068e2019-01-26 20:05:42 -0800121 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700122 error:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -0800123 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700124 zeroed:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -0800125 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700126 position:double;
Austin Schuhd82068e2019-01-26 20:05:42 -0800127
128 // The estimated absolute position of the encoder. This is filtered, so it
129 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700130 absolute_position:double;
131}
Austin Schuhd82068e2019-01-26 20:05:42 -0800132
Ravago Jonesea6464c2020-10-10 15:40:46 -0700133// The internal state of a zeroing estimator.
134table AbsoluteAndAbsoluteEncoderEstimatorState {
135 // If true, there has been a fatal error for the estimator.
136 error:bool (id: 0);
137 // If the joint has seen an index pulse and is zeroed.
138 zeroed:bool (id: 1);
139 // The estimated position of the joint.
140 position:double (id: 2);
141
142 // The estimated absolute position of the encoder. This is filtered, so it
143 // can be easily used when zeroing.
144 absolute_position:double (id: 3);
145
146 // Estimated absolute position of the single turn absolute encoder.
147 single_turn_absolute_position:double (id: 4);
148}
149
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800150table RelativeEncoderEstimatorState {
151 // If true, there has been a fatal error for the estimator.
152 error:bool;
153
154 // The estimated position of the joint.
155 position:double;
156}
157
Austin Schuhd82068e2019-01-26 20:05:42 -0800158// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700159table IndexEstimatorState {
Brian Silvermanf37839c2017-02-19 18:07:15 -0800160 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700161 error:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800162 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700163 zeroed:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800164 // The estimated position of the joint. This is just the position relative to
165 // where we started if we're not zeroed yet.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700166 position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800167
168 // The positions of the extreme index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700169 min_index_position:double;
170 max_index_position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800171 // The number of index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700172 index_pulses_seen:int;
173}
Brian Silvermanf37839c2017-02-19 18:07:15 -0800174
Alex Perrycb7da4b2019-08-28 19:35:56 -0700175table HallEffectAndPositionEstimatorState {
Austin Schuh55934032017-03-11 12:45:27 -0800176 // If error.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700177 error:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800178 // If we've found a positive edge while moving backwards and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700179 zeroed:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800180 // Encoder angle relative to where we started.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700181 encoder:double;
Austin Schuh55934032017-03-11 12:45:27 -0800182 // The positions of the extreme posedges we've seen.
183 // If we've gotten enough samples where the hall effect is high before can be
184 // certain it is not a false positive.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700185 high_long_enough:bool;
186 offset:double;
187}
Austin Schuh55934032017-03-11 12:45:27 -0800188
Brian Silverman0a7f6062015-01-24 17:41:33 -0500189// A left/right pair of PotAndIndexPositions.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700190table PotAndIndexPair {
191 left:PotAndIndexPosition;
192 right:PotAndIndexPosition;
193}
Brian Silverman17f503e2015-08-02 18:17:18 -0700194
195// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196table HallEffectStruct {
197 current:bool;
198 posedge_count:int;
199 negedge_count:int;
200 posedge_value:double;
201 negedge_value:double;
202}
Brian Silverman17f503e2015-08-02 18:17:18 -0700203
Austin Schuhf380a3f2017-03-04 22:31:47 -0800204// Records the hall effect sensor and encoder values.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700205table HallEffectAndPosition {
Austin Schuhf380a3f2017-03-04 22:31:47 -0800206 // The current hall effect state.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700207 current:bool;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800208 // The current encoder position.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700209 encoder:double;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800210 // The number of positive and negative edges we've seen on the hall effect
211 // sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700212 posedge_count:int;
213 negedge_count:int;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800214 // The values corresponding to the last hall effect sensor reading.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700215 posedge_value:double;
216 negedge_value:double;
217}
Austin Schuhf380a3f2017-03-04 22:31:47 -0800218
Brian Silverman17f503e2015-08-02 18:17:18 -0700219// Records the positions for a mechanism with edge-capturing sensors on it.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700220table HallEventPositions {
221 current:double;
222 posedge:double;
223 negedge:double;
224}
Brian Silverman17f503e2015-08-02 18:17:18 -0700225
226// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700227table PosedgeOnlyCountedHallEffectStruct {
228 current:bool;
229 posedge_count:int;
230 negedge_count:int;
231 posedge_value:double;
232}
Austin Schuhedbb64f2016-03-19 01:18:09 -0700233
234// Parameters for the motion profiles.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700235table ProfileParameters {
Austin Schuhedbb64f2016-03-19 01:18:09 -0700236 // Maximum velocity for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700237 max_velocity:float;
Austin Schuhedbb64f2016-03-19 01:18:09 -0700238 // Maximum acceleration for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700239 max_acceleration:float;
240}
241
242enum ConstraintType : byte {
243 CONSTRAINT_TYPE_UNDEFINED,
244 LONGITUDINAL_ACCELERATION,
245 LATERAL_ACCELERATION,
246 VOLTAGE,
247 VELOCITY,
248}
Alex Perry731b4602019-02-02 22:13:01 -0800249
250// Definition of a constraint on a trajectory
Alex Perrycb7da4b2019-08-28 19:35:56 -0700251table Constraint {
252 constraint_type:ConstraintType;
253
254 value:float;
255
Alex Perry731b4602019-02-02 22:13:01 -0800256 // start and end distance are only checked for velocity limits.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700257 start_distance:float;
258 end_distance:float;
259}
Alex Perry731b4602019-02-02 22:13:01 -0800260
261// Parameters for computing a trajectory using a chain of splines and
262// constraints.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700263table MultiSpline {
Alex Perry731b4602019-02-02 22:13:01 -0800264 // Number of splines. The spline point arrays will be expected to have
265 // 6 + 5 * (n - 1) points in them. The endpoints are shared between
266 // neighboring splines.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700267 spline_count:byte;
268 // Maximum of 36 spline points (7 splines).
269 spline_x:[float];
270 spline_y:[float];
Alex Perry731b4602019-02-02 22:13:01 -0800271
Alex Perrycb7da4b2019-08-28 19:35:56 -0700272 // Maximum of 6 constraints;
273 constraints:[Constraint];
274}