blob: 4f1e8882394a7832326886719e762236e23a1998 [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
Daniel Pettiab274232015-02-16 19:15:34 -080064// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070065table EstimatorState {
Daniel Pettiab274232015-02-16 19:15:34 -080066 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070067 error:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080068 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070069 zeroed:bool;
Daniel Pettiab274232015-02-16 19:15:34 -080070 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -070071 position:double;
Austin Schuhbe133ed2016-03-11 21:23:34 -080072
73 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070074 pot_position:double;
75}
Daniel Pettiab274232015-02-16 19:15:34 -080076
Austin Schuh5f01f152017-02-11 21:34:08 -080077// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070078table PotAndAbsoluteEncoderEstimatorState {
Austin Schuh5f01f152017-02-11 21:34:08 -080079 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070080 error:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -080081 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070082 zeroed:bool;
Austin Schuh5f01f152017-02-11 21:34:08 -080083 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -070084 position:double;
Austin Schuh5f01f152017-02-11 21:34:08 -080085
86 // The estimated position not using the index pulse.
Alex Perrycb7da4b2019-08-28 19:35:56 -070087 pot_position:double;
Austin Schuh0e1c2c62017-02-21 02:03:25 -080088
89 // The estimated absolute position of the encoder. This is filtered, so it
90 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -070091 absolute_position:double;
92}
Austin Schuh5f01f152017-02-11 21:34:08 -080093
Brian Silvermanf37839c2017-02-19 18:07:15 -080094// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070095table AbsoluteEncoderEstimatorState {
Austin Schuhd82068e2019-01-26 20:05:42 -080096 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -070097 error:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -080098 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -070099 zeroed:bool;
Austin Schuhd82068e2019-01-26 20:05:42 -0800100 // The estimated position of the joint.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700101 position:double;
Austin Schuhd82068e2019-01-26 20:05:42 -0800102
103 // The estimated absolute position of the encoder. This is filtered, so it
104 // can be easily used when zeroing.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700105 absolute_position:double;
106}
Austin Schuhd82068e2019-01-26 20:05:42 -0800107
108// The internal state of a zeroing estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700109table IndexEstimatorState {
Brian Silvermanf37839c2017-02-19 18:07:15 -0800110 // If true, there has been a fatal error for the estimator.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700111 error:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800112 // If the joint has seen an index pulse and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700113 zeroed:bool;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800114 // The estimated position of the joint. This is just the position relative to
115 // where we started if we're not zeroed yet.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700116 position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800117
118 // The positions of the extreme index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700119 min_index_position:double;
120 max_index_position:double;
Brian Silvermanf37839c2017-02-19 18:07:15 -0800121 // The number of index pulses we've seen.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700122 index_pulses_seen:int;
123}
Brian Silvermanf37839c2017-02-19 18:07:15 -0800124
Alex Perrycb7da4b2019-08-28 19:35:56 -0700125table HallEffectAndPositionEstimatorState {
Austin Schuh55934032017-03-11 12:45:27 -0800126 // If error.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700127 error:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800128 // If we've found a positive edge while moving backwards and is zeroed.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700129 zeroed:bool;
Austin Schuh55934032017-03-11 12:45:27 -0800130 // Encoder angle relative to where we started.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700131 encoder:double;
Austin Schuh55934032017-03-11 12:45:27 -0800132 // The positions of the extreme posedges we've seen.
133 // If we've gotten enough samples where the hall effect is high before can be
134 // certain it is not a false positive.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700135 high_long_enough:bool;
136 offset:double;
137}
Austin Schuh55934032017-03-11 12:45:27 -0800138
Brian Silverman0a7f6062015-01-24 17:41:33 -0500139// A left/right pair of PotAndIndexPositions.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700140table PotAndIndexPair {
141 left:PotAndIndexPosition;
142 right:PotAndIndexPosition;
143}
Brian Silverman17f503e2015-08-02 18:17:18 -0700144
145// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700146table HallEffectStruct {
147 current:bool;
148 posedge_count:int;
149 negedge_count:int;
150 posedge_value:double;
151 negedge_value:double;
152}
Brian Silverman17f503e2015-08-02 18:17:18 -0700153
Austin Schuhf380a3f2017-03-04 22:31:47 -0800154// Records the hall effect sensor and encoder values.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700155table HallEffectAndPosition {
Austin Schuhf380a3f2017-03-04 22:31:47 -0800156 // The current hall effect state.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700157 current:bool;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800158 // The current encoder position.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700159 encoder:double;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800160 // The number of positive and negative edges we've seen on the hall effect
161 // sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700162 posedge_count:int;
163 negedge_count:int;
Austin Schuhf380a3f2017-03-04 22:31:47 -0800164 // The values corresponding to the last hall effect sensor reading.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700165 posedge_value:double;
166 negedge_value:double;
167}
Austin Schuhf380a3f2017-03-04 22:31:47 -0800168
Brian Silverman17f503e2015-08-02 18:17:18 -0700169// Records the positions for a mechanism with edge-capturing sensors on it.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700170table HallEventPositions {
171 current:double;
172 posedge:double;
173 negedge:double;
174}
Brian Silverman17f503e2015-08-02 18:17:18 -0700175
176// Records edges captured on a single hall effect sensor.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700177table PosedgeOnlyCountedHallEffectStruct {
178 current:bool;
179 posedge_count:int;
180 negedge_count:int;
181 posedge_value:double;
182}
Austin Schuhedbb64f2016-03-19 01:18:09 -0700183
184// Parameters for the motion profiles.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700185table ProfileParameters {
Austin Schuhedbb64f2016-03-19 01:18:09 -0700186 // Maximum velocity for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700187 max_velocity:float;
Austin Schuhedbb64f2016-03-19 01:18:09 -0700188 // Maximum acceleration for the profile.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700189 max_acceleration:float;
190}
191
192enum ConstraintType : byte {
193 CONSTRAINT_TYPE_UNDEFINED,
194 LONGITUDINAL_ACCELERATION,
195 LATERAL_ACCELERATION,
196 VOLTAGE,
197 VELOCITY,
198}
Alex Perry731b4602019-02-02 22:13:01 -0800199
200// Definition of a constraint on a trajectory
Alex Perrycb7da4b2019-08-28 19:35:56 -0700201table Constraint {
202 constraint_type:ConstraintType;
203
204 value:float;
205
Alex Perry731b4602019-02-02 22:13:01 -0800206 // start and end distance are only checked for velocity limits.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700207 start_distance:float;
208 end_distance:float;
209}
Alex Perry731b4602019-02-02 22:13:01 -0800210
211// Parameters for computing a trajectory using a chain of splines and
212// constraints.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700213table MultiSpline {
Alex Perry731b4602019-02-02 22:13:01 -0800214 // Number of splines. The spline point arrays will be expected to have
215 // 6 + 5 * (n - 1) points in them. The endpoints are shared between
216 // neighboring splines.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700217 spline_count:byte;
218 // Maximum of 36 spline points (7 splines).
219 spline_x:[float];
220 spline_y:[float];
Alex Perry731b4602019-02-02 22:13:01 -0800221
Alex Perrycb7da4b2019-08-28 19:35:56 -0700222 // Maximum of 6 constraints;
223 constraints:[Constraint];
224}