blob: 43775414db49a36b7969633719dafe26256d9c17 [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
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800133table RelativeEncoderEstimatorState {
134 // If true, there has been a fatal error for the estimator.
135 error:bool;
136
137 // The estimated position of the joint.
138 position:double;
139}
140
Austin Schuhd82068e2019-01-26 20:05:42 -0800141// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700142table IndexEstimatorState {
Brian Silvermanf37839c2017-02-19 18:07:15 -0800143 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700144 error:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800145 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700146 zeroed:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800147 // The estimated position of the joint. This is just the position relative to
148 // where we started if we're not zeroed yet.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700149 position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800150
151 // The positions of the extreme index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700152 min_index_position:double;
153 max_index_position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800154 // The number of index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700155 index_pulses_seen:int;
156}
Brian Silvermanf37839c2017-02-19 18:07:15 -0800157
Alex Perrycb7da4b2019-08-28 19:35:56 -0700158table HallEffectAndPositionEstimatorState {
Austin Schuh55934032017-03-11 12:45:27 -0800159 // If error.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700160 error:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800161 // If we've found a positive edge while moving backwards and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162 zeroed:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800163 // Encoder angle relative to where we started.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700164 encoder:double;
Austin Schuh55934032017-03-11 12:45:27 -0800165 // The positions of the extreme posedges we've seen.
166 // If we've gotten enough samples where the hall effect is high before can be
167 // certain it is not a false positive.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700168 high_long_enough:bool;
169 offset:double;
170}
Austin Schuh55934032017-03-11 12:45:27 -0800171
Brian Silverman0a7f6062015-01-24 17:41:33 -0500172// A left/right pair of PotAndIndexPositions.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700173table PotAndIndexPair {
174 left:PotAndIndexPosition;
175 right:PotAndIndexPosition;
176}
Brian Silverman17f503e2015-08-02 18:17:18 -0700177
178// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700179table HallEffectStruct {
180 current:bool;
181 posedge_count:int;
182 negedge_count:int;
183 posedge_value:double;
184 negedge_value:double;
185}
Brian Silverman17f503e2015-08-02 18:17:18 -0700186
Austin Schuhf380a3f2017-03-04 22:31:47 -0800187// Records the hall effect sensor and encoder values.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700188table HallEffectAndPosition {
Austin Schuhf380a3f2017-03-04 22:31:47 -0800189 // The current hall effect state.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700190 current:bool;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800191 // The current encoder position.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700192 encoder:double;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800193 // The number of positive and negative edges we've seen on the hall effect
194 // sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700195 posedge_count:int;
196 negedge_count:int;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800197 // The values corresponding to the last hall effect sensor reading.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700198 posedge_value:double;
199 negedge_value:double;
200}
Austin Schuhf380a3f2017-03-04 22:31:47 -0800201
Brian Silverman17f503e2015-08-02 18:17:18 -0700202// Records the positions for a mechanism with edge-capturing sensors on it.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700203table HallEventPositions {
204 current:double;
205 posedge:double;
206 negedge:double;
207}
Brian Silverman17f503e2015-08-02 18:17:18 -0700208
209// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700210table PosedgeOnlyCountedHallEffectStruct {
211 current:bool;
212 posedge_count:int;
213 negedge_count:int;
214 posedge_value:double;
215}
Austin Schuhedbb64f2016-03-19 01:18:09 -0700216
217// Parameters for the motion profiles.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700218table ProfileParameters {
Austin Schuhedbb64f2016-03-19 01:18:09 -0700219 // Maximum velocity for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700220 max_velocity:float;
Austin Schuhedbb64f2016-03-19 01:18:09 -0700221 // Maximum acceleration for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700222 max_acceleration:float;
223}
224
225enum ConstraintType : byte {
226 CONSTRAINT_TYPE_UNDEFINED,
227 LONGITUDINAL_ACCELERATION,
228 LATERAL_ACCELERATION,
229 VOLTAGE,
230 VELOCITY,
231}
Alex Perry731b4602019-02-02 22:13:01 -0800232
233// Definition of a constraint on a trajectory
Alex Perrycb7da4b2019-08-28 19:35:56 -0700234table Constraint {
235 constraint_type:ConstraintType;
236
237 value:float;
238
Alex Perry731b4602019-02-02 22:13:01 -0800239 // start and end distance are only checked for velocity limits.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700240 start_distance:float;
241 end_distance:float;
242}
Alex Perry731b4602019-02-02 22:13:01 -0800243
244// Parameters for computing a trajectory using a chain of splines and
245// constraints.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700246table MultiSpline {
Alex Perry731b4602019-02-02 22:13:01 -0800247 // Number of splines. The spline point arrays will be expected to have
248 // 6 + 5 * (n - 1) points in them. The endpoints are shared between
249 // neighboring splines.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700250 spline_count:byte;
251 // Maximum of 36 spline points (7 splines).
252 spline_x:[float];
253 spline_y:[float];
Alex Perry731b4602019-02-02 22:13:01 -0800254
Alex Perrycb7da4b2019-08-28 19:35:56 -0700255 // Maximum of 6 constraints;
256 constraints:[Constraint];
257}