blob: 243e2cb18fd144700d1e3ae0e2996b05576bd449 [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
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080092 error:bool (id: 0);
Daniel Pettiab274232015-02-16 19:15:34 -080093 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080094 zeroed:bool (id: 1);
Daniel Pettiab274232015-02-16 19:15:34 -080095 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080096 position:double (id: 2);
Austin Schuhbe133ed2016-03-11 21:23:34 -080097
98 // The estimated position not using the index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080099 pot_position:double (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700100}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800105 error:bool (id: 0);
Austin Schuh5f01f152017-02-11 21:34:08 -0800106 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800107 zeroed:bool (id: 1);
Austin Schuh5f01f152017-02-11 21:34:08 -0800108 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800109 position:double (id: 2);
Austin Schuh5f01f152017-02-11 21:34:08 -0800110
111 // The estimated position not using the index pulse.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800112 pot_position:double (id: 3);
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800116 absolute_position:double (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700117}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800122 error:bool (id: 0);
Austin Schuhd82068e2019-01-26 20:05:42 -0800123 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800124 zeroed:bool (id: 1);
Austin Schuhd82068e2019-01-26 20:05:42 -0800125 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800126 position:double (id: 2);
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800130 absolute_position:double (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700131}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800152 error:bool (id: 0);
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800153
154 // The estimated position of the joint.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800155 position:double (id: 1);
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800156}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800161 error:bool (id: 0);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800162 // If the joint has seen an index pulse and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800163 zeroed:bool (id: 1);
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800166 position:double (id: 2);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800167
168 // The positions of the extreme index pulses we've seen.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800169 min_index_position:double (id: 3);
170 max_index_position:double (id: 4);
Brian Silvermanf37839c2017-02-19 18:07:15 -0800171 // The number of index pulses we've seen.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800172 index_pulses_seen:int (id: 5);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700173}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800177 error:bool (id: 0);
Austin Schuh55934032017-03-11 12:45:27 -0800178 // If we've found a positive edge while moving backwards and is zeroed.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800179 zeroed:bool (id: 1);
Austin Schuh55934032017-03-11 12:45:27 -0800180 // Encoder angle relative to where we started.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800181 encoder:double (id: 2);
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800185 high_long_enough:bool (id: 3);
186 offset:double (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700187}
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 {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800191 left:PotAndIndexPosition (id: 0);
192 right:PotAndIndexPosition (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700193}
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 {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800197 current:bool (id: 0);
198 posedge_count:int (id: 1);
199 negedge_count:int (id: 2);
200 posedge_value:double (id: 3);
201 negedge_value:double (id: 4);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700202}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800207 current:bool (id: 0);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800208 // The current encoder position.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800209 encoder:double (id: 1);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800210 // The number of positive and negative edges we've seen on the hall effect
211 // sensor.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800212 posedge_count:int (id: 2);
213 negedge_count:int (id: 3);
Austin Schuhf380a3f2017-03-04 22:31:47 -0800214 // The values corresponding to the last hall effect sensor reading.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800215 posedge_value:double (id: 4);
216 negedge_value:double (id: 5);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700217}
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 {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800221 current:double (id: 0);
222 posedge:double (id: 1);
223 negedge:double (id: 2);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700224}
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 {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800228 current:bool (id: 0);
229 posedge_count:int (id: 1);
230 negedge_count:int (id: 2);
231 posedge_value:double (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700232}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800237 max_velocity:float (id: 0);
Austin Schuhedbb64f2016-03-19 01:18:09 -0700238 // Maximum acceleration for the profile.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800239 max_acceleration:float (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700240}
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 {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800252 constraint_type:ConstraintType (id: 0);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700253
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800254 value:float (id: 1);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700255
Alex Perry731b4602019-02-02 22:13:01 -0800256 // start and end distance are only checked for velocity limits.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800257 start_distance:float (id: 2);
258 end_distance:float (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700259}
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.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800267 spline_count:byte (id: 0);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700268 // Maximum of 36 spline points (7 splines).
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800269 spline_x:[float] (id: 1);
270 spline_y:[float] (id: 2);
Alex Perry731b4602019-02-02 22:13:01 -0800271
Alex Perrycb7da4b2019-08-28 19:35:56 -0700272 // Maximum of 6 constraints;
Ravago Jonesfb6a7a52020-11-14 13:47:46 -0800273 constraints:[Constraint] (id: 3);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700274}