Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 1 | namespace frc971; |
Brian Silverman | e0a9546 | 2014-02-17 00:41:09 -0800 | [diff] [blame] | 2 | |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 3 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 9 | table IndexPosition { |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 10 | // Current position read from the encoder. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 11 | encoder:double; |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 12 | // Position from the encoder latched at the last index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 13 | latched_encoder:double; |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 14 | // How many index pulses we've seen since startup. Starts at 0. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 15 | index_pulses:uint; |
| 16 | } |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 17 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 18 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 24 | table PotAndIndexPosition { |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 25 | // Current position read from the encoder. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 26 | encoder:double; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 27 | // Current position read from the potentiometer. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 28 | pot:double; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 29 | |
| 30 | // Position from the encoder latched at the last index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 31 | latched_encoder:double; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 32 | // Position from the potentiometer latched at the last index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 33 | latched_pot:double; |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 34 | |
| 35 | // How many index pulses we've seen since startup. Starts at 0. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 36 | index_pulses:uint; |
| 37 | } |
Brian Silverman | 5b433df | 2014-02-17 11:57:37 -0800 | [diff] [blame] | 38 | |
Diana Vandenberg | abb3d19 | 2017-01-28 16:19:43 -0800 | [diff] [blame] | 39 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 45 | table PotAndAbsolutePosition { |
Diana Vandenberg | abb3d19 | 2017-01-28 16:19:43 -0800 | [diff] [blame] | 46 | // Current position read from each encoder. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 47 | encoder:double; |
| 48 | absolute_encoder:double; |
Diana Vandenberg | abb3d19 | 2017-01-28 16:19:43 -0800 | [diff] [blame] | 49 | |
| 50 | // Current position read from the potentiometer. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 51 | pot:double; |
| 52 | } |
Diana Vandenberg | abb3d19 | 2017-01-28 16:19:43 -0800 | [diff] [blame] | 53 | |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 54 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 58 | table AbsolutePosition { |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 59 | // Current position read from each encoder. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 60 | encoder:double; |
| 61 | absolute_encoder:double; |
| 62 | } |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 63 | |
Ravago Jones | 988b038 | 2020-10-10 15:33:40 -0700 | [diff] [blame^] | 64 | // 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. |
| 71 | table 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 Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 81 | // 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. |
| 84 | table RelativePosition { |
| 85 | // Current position read from the encoder. |
| 86 | encoder:double; |
| 87 | } |
| 88 | |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 89 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 90 | table EstimatorState { |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 91 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 92 | error:bool; |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 93 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 94 | zeroed:bool; |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 95 | // The estimated position of the joint. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 96 | position:double; |
Austin Schuh | be133ed | 2016-03-11 21:23:34 -0800 | [diff] [blame] | 97 | |
| 98 | // The estimated position not using the index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | pot_position:double; |
| 100 | } |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 101 | |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 102 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 103 | table PotAndAbsoluteEncoderEstimatorState { |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 104 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 105 | error:bool; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 106 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 107 | zeroed:bool; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 108 | // The estimated position of the joint. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 109 | position:double; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 110 | |
| 111 | // The estimated position not using the index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 112 | pot_position:double; |
Austin Schuh | 0e1c2c6 | 2017-02-21 02:03:25 -0800 | [diff] [blame] | 113 | |
| 114 | // The estimated absolute position of the encoder. This is filtered, so it |
| 115 | // can be easily used when zeroing. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 116 | absolute_position:double; |
| 117 | } |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 118 | |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 119 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 120 | table AbsoluteEncoderEstimatorState { |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 121 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 122 | error:bool; |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 123 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 124 | zeroed:bool; |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 125 | // The estimated position of the joint. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 126 | position:double; |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 127 | |
| 128 | // The estimated absolute position of the encoder. This is filtered, so it |
| 129 | // can be easily used when zeroing. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 130 | absolute_position:double; |
| 131 | } |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 132 | |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 133 | table 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 Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 141 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 142 | table IndexEstimatorState { |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 143 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 144 | error:bool; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 145 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 146 | zeroed:bool; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 147 | // The estimated position of the joint. This is just the position relative to |
| 148 | // where we started if we're not zeroed yet. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 149 | position:double; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 150 | |
| 151 | // The positions of the extreme index pulses we've seen. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 152 | min_index_position:double; |
| 153 | max_index_position:double; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 154 | // The number of index pulses we've seen. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 155 | index_pulses_seen:int; |
| 156 | } |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 157 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 158 | table HallEffectAndPositionEstimatorState { |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 159 | // If error. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 160 | error:bool; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 161 | // If we've found a positive edge while moving backwards and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 162 | zeroed:bool; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 163 | // Encoder angle relative to where we started. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 164 | encoder:double; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 165 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 168 | high_long_enough:bool; |
| 169 | offset:double; |
| 170 | } |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 171 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 172 | // A left/right pair of PotAndIndexPositions. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 173 | table PotAndIndexPair { |
| 174 | left:PotAndIndexPosition; |
| 175 | right:PotAndIndexPosition; |
| 176 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 177 | |
| 178 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 179 | table HallEffectStruct { |
| 180 | current:bool; |
| 181 | posedge_count:int; |
| 182 | negedge_count:int; |
| 183 | posedge_value:double; |
| 184 | negedge_value:double; |
| 185 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 186 | |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 187 | // Records the hall effect sensor and encoder values. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 188 | table HallEffectAndPosition { |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 189 | // The current hall effect state. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 190 | current:bool; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 191 | // The current encoder position. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 192 | encoder:double; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 193 | // The number of positive and negative edges we've seen on the hall effect |
| 194 | // sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 195 | posedge_count:int; |
| 196 | negedge_count:int; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 197 | // The values corresponding to the last hall effect sensor reading. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 198 | posedge_value:double; |
| 199 | negedge_value:double; |
| 200 | } |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 201 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 202 | // Records the positions for a mechanism with edge-capturing sensors on it. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 203 | table HallEventPositions { |
| 204 | current:double; |
| 205 | posedge:double; |
| 206 | negedge:double; |
| 207 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 208 | |
| 209 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 210 | table PosedgeOnlyCountedHallEffectStruct { |
| 211 | current:bool; |
| 212 | posedge_count:int; |
| 213 | negedge_count:int; |
| 214 | posedge_value:double; |
| 215 | } |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 216 | |
| 217 | // Parameters for the motion profiles. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 218 | table ProfileParameters { |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 219 | // Maximum velocity for the profile. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 220 | max_velocity:float; |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 221 | // Maximum acceleration for the profile. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 222 | max_acceleration:float; |
| 223 | } |
| 224 | |
| 225 | enum ConstraintType : byte { |
| 226 | CONSTRAINT_TYPE_UNDEFINED, |
| 227 | LONGITUDINAL_ACCELERATION, |
| 228 | LATERAL_ACCELERATION, |
| 229 | VOLTAGE, |
| 230 | VELOCITY, |
| 231 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 232 | |
| 233 | // Definition of a constraint on a trajectory |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 234 | table Constraint { |
| 235 | constraint_type:ConstraintType; |
| 236 | |
| 237 | value:float; |
| 238 | |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 239 | // start and end distance are only checked for velocity limits. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 240 | start_distance:float; |
| 241 | end_distance:float; |
| 242 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 243 | |
| 244 | // Parameters for computing a trajectory using a chain of splines and |
| 245 | // constraints. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 246 | table MultiSpline { |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 247 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 250 | spline_count:byte; |
| 251 | // Maximum of 36 spline points (7 splines). |
| 252 | spline_x:[float]; |
| 253 | spline_y:[float]; |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 254 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 255 | // Maximum of 6 constraints; |
| 256 | constraints:[Constraint]; |
| 257 | } |