blob: da2dc0564cf15b6ca5042d3d88ab5ab8393f65c6 [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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080011 encoder:double (id: 0);
Philipp Schraderfd6335e2017-02-04 01:26:40 +000012 // Position from the encoder latched at the last index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080013 latched_encoder:double (id: 1);
Philipp Schraderfd6335e2017-02-04 01:26:40 +000014 // How many index pulses we've seen since startup. Starts at 0.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080015 index_pulses:uint (id: 2);
Alex Perrycb7da4b2019-08-28 19:35:56 -070016}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080026 encoder:double (id: 0);
Brian Silverman0a7f6062015-01-24 17:41:33 -050027 // Current position read from the potentiometer.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080028 pot:double (id: 1);
Brian Silverman0a7f6062015-01-24 17:41:33 -050029
30 // Position from the encoder latched at the last index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080031 latched_encoder:double (id: 2);
Brian Silverman0a7f6062015-01-24 17:41:33 -050032 // Position from the potentiometer latched at the last index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080033 latched_pot:double (id: 3);
Brian Silverman0a7f6062015-01-24 17:41:33 -050034
35 // How many index pulses we've seen since startup. Starts at 0.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080036 index_pulses:uint (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -070037}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080047 encoder:double (id: 0);
48 absolute_encoder:double (id: 1);
Diana Vandenbergabb3d192017-01-28 16:19:43 -080049
50 // Current position read from the potentiometer.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080051 pot:double (id: 2);
Alex Perrycb7da4b2019-08-28 19:35:56 -070052}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080060 encoder:double (id: 0);
61 absolute_encoder:double (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -070062}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080073 encoder:double (id: 0);
74 absolute_encoder:double (id: 1);
Ravago Jones988b0382020-10-10 15:33:40 -070075
76 // Current position read from the single turn absolute encoder.
77 // This can not turn more than one rotation.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080078 single_turn_absolute_encoder:double (id: 2);
Ravago Jones988b0382020-10-10 15:33:40 -070079}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080086 encoder:double (id: 0);
Tyler Chatow3c47f3c2020-01-29 20:45:23 -080087}
88
Ravago Jones726deb02021-05-29 14:36:43 -070089// An enum to represent the different types of errors
90// a zeroing estimator could have.
91enum ZeroingError : short {
92 OFFSET_MOVED_TOO_FAR,
93 LOST_ABSOLUTE_ENCODER
94}
95
Daniel Pettiab274232015-02-16 19:15:34 -080096// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070097table EstimatorState {
Daniel Pettiab274232015-02-16 19:15:34 -080098 // If true, there has been a fatal error for the estimator.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080099 error:bool (id: 0);
Daniel Pettiab274232015-02-16 19:15:34 -0800100 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800101 zeroed:bool (id: 1);
Daniel Pettiab274232015-02-16 19:15:34 -0800102 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800103 position:double (id: 2);
Austin Schuhbe133ed2016-03-11 21:23:34 -0800104
105 // The estimated position not using the index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800106 pot_position:double (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700107}
Daniel Pettiab274232015-02-16 19:15:34 -0800108
Austin Schuh5f01f152017-02-11 21:34:08 -0800109// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700110table PotAndAbsoluteEncoderEstimatorState {
Austin Schuh5f01f152017-02-11 21:34:08 -0800111 // If true, there has been a fatal error for the estimator.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800112 error:bool (id: 0);
Austin Schuh5f01f152017-02-11 21:34:08 -0800113 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800114 zeroed:bool (id: 1);
Austin Schuh5f01f152017-02-11 21:34:08 -0800115 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800116 position:double (id: 2);
Austin Schuh5f01f152017-02-11 21:34:08 -0800117
118 // The estimated position not using the index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800119 pot_position:double (id: 3);
Austin Schuh0e1c2c62017-02-21 02:03:25 -0800120
121 // The estimated absolute position of the encoder. This is filtered, so it
122 // can be easily used when zeroing.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800123 absolute_position:double (id: 4);
Ravago Jones726deb02021-05-29 14:36:43 -0700124
125 // If errored, this contains the causes for the error.
126 errors: [ZeroingError] (id: 5);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700127}
Austin Schuh5f01f152017-02-11 21:34:08 -0800128
Brian Silvermanf37839c2017-02-19 18:07:15 -0800129// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700130table AbsoluteEncoderEstimatorState {
Austin Schuhd82068e2019-01-26 20:05:42 -0800131 // If true, there has been a fatal error for the estimator.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800132 error:bool (id: 0);
Austin Schuhd82068e2019-01-26 20:05:42 -0800133 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800134 zeroed:bool (id: 1);
Austin Schuhd82068e2019-01-26 20:05:42 -0800135 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800136 position:double (id: 2);
Austin Schuhd82068e2019-01-26 20:05:42 -0800137
138 // The estimated absolute position of the encoder. This is filtered, so it
139 // can be easily used when zeroing.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800140 absolute_position:double (id: 3);
Ravago Jones726deb02021-05-29 14:36:43 -0700141
142 // If errored, this contains the causes for the error.
143 errors: [ZeroingError] (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700144}
Austin Schuhd82068e2019-01-26 20:05:42 -0800145
Ravago Jonesea6464c2020-10-10 15:40:46 -0700146// The internal state of a zeroing estimator.
147table AbsoluteAndAbsoluteEncoderEstimatorState {
148 // If true, there has been a fatal error for the estimator.
149 error:bool (id: 0);
150 // If the joint has seen an index pulse and is zeroed.
151 zeroed:bool (id: 1);
152 // The estimated position of the joint.
153 position:double (id: 2);
154
155 // The estimated absolute position of the encoder. This is filtered, so it
156 // can be easily used when zeroing.
157 absolute_position:double (id: 3);
158
159 // Estimated absolute position of the single turn absolute encoder.
160 single_turn_absolute_position:double (id: 4);
Ravago Jones726deb02021-05-29 14:36:43 -0700161
162 // If errored, this contains the causes for the error.
163 errors: [ZeroingError] (id: 5);
Ravago Jonesea6464c2020-10-10 15:40:46 -0700164}
165
Ravago Jones726deb02021-05-29 14:36:43 -0700166
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800167table RelativeEncoderEstimatorState {
168 // If true, there has been a fatal error for the estimator.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800169 error:bool (id: 0);
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800170
171 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800172 position:double (id: 1);
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800173}
174
Austin Schuhd82068e2019-01-26 20:05:42 -0800175// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700176table IndexEstimatorState {
Brian Silvermanf37839c2017-02-19 18:07:15 -0800177 // If true, there has been a fatal error for the estimator.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800178 error:bool (id: 0);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800179 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800180 zeroed:bool (id: 1);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800181 // The estimated position of the joint. This is just the position relative to
182 // where we started if we're not zeroed yet.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800183 position:double (id: 2);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800184
185 // The positions of the extreme index pulses we've seen.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800186 min_index_position:double (id: 3);
187 max_index_position:double (id: 4);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800188 // The number of index pulses we've seen.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800189 index_pulses_seen:int (id: 5);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700190}
Brian Silvermanf37839c2017-02-19 18:07:15 -0800191
Alex Perrycb7da4b2019-08-28 19:35:56 -0700192table HallEffectAndPositionEstimatorState {
Austin Schuh55934032017-03-11 12:45:27 -0800193 // If error.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800194 error:bool (id: 0);
Austin Schuh55934032017-03-11 12:45:27 -0800195 // If we've found a positive edge while moving backwards and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800196 zeroed:bool (id: 1);
Austin Schuh55934032017-03-11 12:45:27 -0800197 // Encoder angle relative to where we started.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800198 encoder:double (id: 2);
Austin Schuh55934032017-03-11 12:45:27 -0800199 // The positions of the extreme posedges we've seen.
200 // If we've gotten enough samples where the hall effect is high before can be
201 // certain it is not a false positive.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800202 high_long_enough:bool (id: 3);
203 offset:double (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700204}
Austin Schuh55934032017-03-11 12:45:27 -0800205
Brian Silverman0a7f6062015-01-24 17:41:33 -0500206// A left/right pair of PotAndIndexPositions.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700207table PotAndIndexPair {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800208 left:PotAndIndexPosition (id: 0);
209 right:PotAndIndexPosition (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700210}
Brian Silverman17f503e2015-08-02 18:17:18 -0700211
212// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700213table HallEffectStruct {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800214 current:bool (id: 0);
215 posedge_count:int (id: 1);
216 negedge_count:int (id: 2);
217 posedge_value:double (id: 3);
218 negedge_value:double (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700219}
Brian Silverman17f503e2015-08-02 18:17:18 -0700220
Austin Schuhf380a3f2017-03-04 22:31:47 -0800221// Records the hall effect sensor and encoder values.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700222table HallEffectAndPosition {
Austin Schuhf380a3f2017-03-04 22:31:47 -0800223 // The current hall effect state.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800224 current:bool (id: 0);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800225 // The current encoder position.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800226 encoder:double (id: 1);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800227 // The number of positive and negative edges we've seen on the hall effect
228 // sensor.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800229 posedge_count:int (id: 2);
230 negedge_count:int (id: 3);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800231 // The values corresponding to the last hall effect sensor reading.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800232 posedge_value:double (id: 4);
233 negedge_value:double (id: 5);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700234}
Austin Schuhf380a3f2017-03-04 22:31:47 -0800235
Brian Silverman17f503e2015-08-02 18:17:18 -0700236// Records the positions for a mechanism with edge-capturing sensors on it.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700237table HallEventPositions {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800238 current:double (id: 0);
239 posedge:double (id: 1);
240 negedge:double (id: 2);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700241}
Brian Silverman17f503e2015-08-02 18:17:18 -0700242
243// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700244table PosedgeOnlyCountedHallEffectStruct {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800245 current:bool (id: 0);
246 posedge_count:int (id: 1);
247 negedge_count:int (id: 2);
248 posedge_value:double (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700249}
Austin Schuhedbb64f2016-03-19 01:18:09 -0700250
251// Parameters for the motion profiles.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700252table ProfileParameters {
Austin Schuhedbb64f2016-03-19 01:18:09 -0700253 // Maximum velocity for the profile.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800254 max_velocity:float (id: 0);
Austin Schuhedbb64f2016-03-19 01:18:09 -0700255 // Maximum acceleration for the profile.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800256 max_acceleration:float (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700257}
258
259enum ConstraintType : byte {
260 CONSTRAINT_TYPE_UNDEFINED,
261 LONGITUDINAL_ACCELERATION,
262 LATERAL_ACCELERATION,
263 VOLTAGE,
264 VELOCITY,
265}
Alex Perry731b4602019-02-02 22:13:01 -0800266
267// Definition of a constraint on a trajectory
Alex Perrycb7da4b2019-08-28 19:35:56 -0700268table Constraint {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800269 constraint_type:ConstraintType (id: 0);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700270
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800271 value:float (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700272
Alex Perry731b4602019-02-02 22:13:01 -0800273 // start and end distance are only checked for velocity limits.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800274 start_distance:float (id: 2);
275 end_distance:float (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700276}
Alex Perry731b4602019-02-02 22:13:01 -0800277
278// Parameters for computing a trajectory using a chain of splines and
279// constraints.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700280table MultiSpline {
Alex Perry731b4602019-02-02 22:13:01 -0800281 // Number of splines. The spline point arrays will be expected to have
282 // 6 + 5 * (n - 1) points in them. The endpoints are shared between
283 // neighboring splines.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800284 spline_count:byte (id: 0);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700285 // Maximum of 36 spline points (7 splines).
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800286 spline_x:[float] (id: 1);
287 spline_y:[float] (id: 2);
Alex Perry731b4602019-02-02 22:13:01 -0800288
Alex Perrycb7da4b2019-08-28 19:35:56 -0700289 // Maximum of 6 constraints;
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800290 constraints:[Constraint] (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700291}