blob: a95d407cc5b41bad85f6beb2cea0ddc1a4f1968d [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
Tyler Chatow3c47f3c2020-01-29 20:45:23 -080064// Represents all of the data for a single encoder.
65// The relative encoder values are relative to where the encoder was at some
66// arbitrary point in time.
67table RelativePosition {
68 // Current position read from the encoder.
69 encoder:double;
70}
71
Daniel Pettiab274232015-02-16 19:15:34 -080072// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070073table EstimatorState {
Daniel Pettiab274232015-02-16 19:15:34 -080074 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070075 error:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080076 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070077 zeroed:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080078 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -070079 position:double;
Austin Schuhbe133ed2016-03-11 21:23:34 -080080
81 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070082 pot_position:double;
83}
Daniel Pettiab274232015-02-16 19:15:34 -080084
Austin Schuh5f01f152017-02-11 21:34:08 -080085// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070086table PotAndAbsoluteEncoderEstimatorState {
Austin Schuh5f01f152017-02-11 21:34:08 -080087 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070088 error:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -080089 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070090 zeroed:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -080091 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -070092 position:double;
Austin Schuh5f01f152017-02-11 21:34:08 -080093
94 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070095 pot_position:double;
Austin Schuh0e1c2c62017-02-21 02:03:25 -080096
97 // The estimated absolute position of the encoder. This is filtered, so it
98 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -070099 absolute_position:double;
100}
Austin Schuh5f01f152017-02-11 21:34:08 -0800101
Brian Silvermanf37839c2017-02-19 18:07:15 -0800102// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700103table AbsoluteEncoderEstimatorState {
Austin Schuhd82068e2019-01-26 20:05:42 -0800104 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700105 error:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -0800106 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700107 zeroed:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -0800108 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700109 position:double;
Austin Schuhd82068e2019-01-26 20:05:42 -0800110
111 // The estimated absolute position of the encoder. This is filtered, so it
112 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700113 absolute_position:double;
114}
Austin Schuhd82068e2019-01-26 20:05:42 -0800115
Tyler Chatow3c47f3c2020-01-29 20:45:23 -0800116table RelativeEncoderEstimatorState {
117 // If true, there has been a fatal error for the estimator.
118 error:bool;
119
120 // The estimated position of the joint.
121 position:double;
122}
123
Austin Schuhd82068e2019-01-26 20:05:42 -0800124// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700125table IndexEstimatorState {
Brian Silvermanf37839c2017-02-19 18:07:15 -0800126 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700127 error:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800128 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700129 zeroed:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800130 // The estimated position of the joint. This is just the position relative to
131 // where we started if we're not zeroed yet.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700132 position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800133
134 // The positions of the extreme index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700135 min_index_position:double;
136 max_index_position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800137 // The number of index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700138 index_pulses_seen:int;
139}
Brian Silvermanf37839c2017-02-19 18:07:15 -0800140
Alex Perrycb7da4b2019-08-28 19:35:56 -0700141table HallEffectAndPositionEstimatorState {
Austin Schuh55934032017-03-11 12:45:27 -0800142 // If error.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700143 error:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800144 // If we've found a positive edge while moving backwards and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700145 zeroed:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800146 // Encoder angle relative to where we started.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700147 encoder:double;
Austin Schuh55934032017-03-11 12:45:27 -0800148 // The positions of the extreme posedges we've seen.
149 // If we've gotten enough samples where the hall effect is high before can be
150 // certain it is not a false positive.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700151 high_long_enough:bool;
152 offset:double;
153}
Austin Schuh55934032017-03-11 12:45:27 -0800154
Brian Silverman0a7f6062015-01-24 17:41:33 -0500155// A left/right pair of PotAndIndexPositions.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700156table PotAndIndexPair {
157 left:PotAndIndexPosition;
158 right:PotAndIndexPosition;
159}
Brian Silverman17f503e2015-08-02 18:17:18 -0700160
161// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162table HallEffectStruct {
163 current:bool;
164 posedge_count:int;
165 negedge_count:int;
166 posedge_value:double;
167 negedge_value:double;
168}
Brian Silverman17f503e2015-08-02 18:17:18 -0700169
Austin Schuhf380a3f2017-03-04 22:31:47 -0800170// Records the hall effect sensor and encoder values.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700171table HallEffectAndPosition {
Austin Schuhf380a3f2017-03-04 22:31:47 -0800172 // The current hall effect state.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700173 current:bool;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800174 // The current encoder position.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700175 encoder:double;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800176 // The number of positive and negative edges we've seen on the hall effect
177 // sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700178 posedge_count:int;
179 negedge_count:int;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800180 // The values corresponding to the last hall effect sensor reading.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700181 posedge_value:double;
182 negedge_value:double;
183}
Austin Schuhf380a3f2017-03-04 22:31:47 -0800184
Brian Silverman17f503e2015-08-02 18:17:18 -0700185// Records the positions for a mechanism with edge-capturing sensors on it.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700186table HallEventPositions {
187 current:double;
188 posedge:double;
189 negedge:double;
190}
Brian Silverman17f503e2015-08-02 18:17:18 -0700191
192// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700193table PosedgeOnlyCountedHallEffectStruct {
194 current:bool;
195 posedge_count:int;
196 negedge_count:int;
197 posedge_value:double;
198}
Austin Schuhedbb64f2016-03-19 01:18:09 -0700199
200// Parameters for the motion profiles.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700201table ProfileParameters {
Austin Schuhedbb64f2016-03-19 01:18:09 -0700202 // Maximum velocity for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700203 max_velocity:float;
Austin Schuhedbb64f2016-03-19 01:18:09 -0700204 // Maximum acceleration for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700205 max_acceleration:float;
206}
207
208enum ConstraintType : byte {
209 CONSTRAINT_TYPE_UNDEFINED,
210 LONGITUDINAL_ACCELERATION,
211 LATERAL_ACCELERATION,
212 VOLTAGE,
213 VELOCITY,
214}
Alex Perry731b4602019-02-02 22:13:01 -0800215
216// Definition of a constraint on a trajectory
Alex Perrycb7da4b2019-08-28 19:35:56 -0700217table Constraint {
218 constraint_type:ConstraintType;
219
220 value:float;
221
Alex Perry731b4602019-02-02 22:13:01 -0800222 // start and end distance are only checked for velocity limits.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700223 start_distance:float;
224 end_distance:float;
225}
Alex Perry731b4602019-02-02 22:13:01 -0800226
227// Parameters for computing a trajectory using a chain of splines and
228// constraints.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700229table MultiSpline {
Alex Perry731b4602019-02-02 22:13:01 -0800230 // Number of splines. The spline point arrays will be expected to have
231 // 6 + 5 * (n - 1) points in them. The endpoints are shared between
232 // neighboring splines.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700233 spline_count:byte;
234 // Maximum of 36 spline points (7 splines).
235 spline_x:[float];
236 spline_y:[float];
Alex Perry731b4602019-02-02 22:13:01 -0800237
Alex Perrycb7da4b2019-08-28 19:35:56 -0700238 // Maximum of 6 constraints;
239 constraints:[Constraint];
240}