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 | |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 64 | // 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. |
| 67 | table RelativePosition { |
| 68 | // Current position read from the encoder. |
| 69 | encoder:double; |
| 70 | } |
| 71 | |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 72 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 73 | table EstimatorState { |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 74 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 75 | error:bool; |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 76 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 77 | zeroed:bool; |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 78 | // The estimated position of the joint. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 79 | position:double; |
Austin Schuh | be133ed | 2016-03-11 21:23:34 -0800 | [diff] [blame] | 80 | |
| 81 | // The estimated position not using the index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 82 | pot_position:double; |
| 83 | } |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 84 | |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 85 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 86 | table PotAndAbsoluteEncoderEstimatorState { |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 87 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 88 | error:bool; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 89 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 90 | zeroed:bool; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 91 | // The estimated position of the joint. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 92 | position:double; |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 93 | |
| 94 | // The estimated position not using the index pulse. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 95 | pot_position:double; |
Austin Schuh | 0e1c2c6 | 2017-02-21 02:03:25 -0800 | [diff] [blame] | 96 | |
| 97 | // The estimated absolute position of the encoder. This is filtered, so it |
| 98 | // can be easily used when zeroing. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | absolute_position:double; |
| 100 | } |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 101 | |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -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 AbsoluteEncoderEstimatorState { |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -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 | d82068e | 2019-01-26 20:05:42 -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 | d82068e | 2019-01-26 20:05:42 -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 | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 110 | |
| 111 | // The estimated absolute position of the encoder. This is filtered, so it |
| 112 | // can be easily used when zeroing. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 113 | absolute_position:double; |
| 114 | } |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 115 | |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 116 | table 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 Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 124 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 125 | table IndexEstimatorState { |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 126 | // If true, there has been a fatal error for the estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 127 | error:bool; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 128 | // If the joint has seen an index pulse and is zeroed. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 129 | zeroed:bool; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 130 | // The estimated position of the joint. This is just the position relative to |
| 131 | // where we started if we're not zeroed yet. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 132 | position:double; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 133 | |
| 134 | // The positions of the extreme index pulses we've seen. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 135 | min_index_position:double; |
| 136 | max_index_position:double; |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 137 | // The number of index pulses we've seen. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 138 | index_pulses_seen:int; |
| 139 | } |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 140 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 141 | table HallEffectAndPositionEstimatorState { |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 142 | // If error. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 143 | error:bool; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 144 | // 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] | 145 | zeroed:bool; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 146 | // Encoder angle relative to where we started. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 147 | encoder:double; |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 148 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 151 | high_long_enough:bool; |
| 152 | offset:double; |
| 153 | } |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 154 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 155 | // A left/right pair of PotAndIndexPositions. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 156 | table PotAndIndexPair { |
| 157 | left:PotAndIndexPosition; |
| 158 | right:PotAndIndexPosition; |
| 159 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 160 | |
| 161 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 162 | table HallEffectStruct { |
| 163 | current:bool; |
| 164 | posedge_count:int; |
| 165 | negedge_count:int; |
| 166 | posedge_value:double; |
| 167 | negedge_value:double; |
| 168 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 169 | |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 170 | // Records the hall effect sensor and encoder values. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 171 | table HallEffectAndPosition { |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 172 | // The current hall effect state. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 173 | current:bool; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 174 | // The current encoder position. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 175 | encoder:double; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 176 | // The number of positive and negative edges we've seen on the hall effect |
| 177 | // sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 178 | posedge_count:int; |
| 179 | negedge_count:int; |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 180 | // The values corresponding to the last hall effect sensor reading. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 181 | posedge_value:double; |
| 182 | negedge_value:double; |
| 183 | } |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 184 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 185 | // Records the positions for a mechanism with edge-capturing sensors on it. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 186 | table HallEventPositions { |
| 187 | current:double; |
| 188 | posedge:double; |
| 189 | negedge:double; |
| 190 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 191 | |
| 192 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 193 | table PosedgeOnlyCountedHallEffectStruct { |
| 194 | current:bool; |
| 195 | posedge_count:int; |
| 196 | negedge_count:int; |
| 197 | posedge_value:double; |
| 198 | } |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 199 | |
| 200 | // Parameters for the motion profiles. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 201 | table ProfileParameters { |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 202 | // Maximum velocity for the profile. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 203 | max_velocity:float; |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 204 | // Maximum acceleration for the profile. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 205 | max_acceleration:float; |
| 206 | } |
| 207 | |
| 208 | enum ConstraintType : byte { |
| 209 | CONSTRAINT_TYPE_UNDEFINED, |
| 210 | LONGITUDINAL_ACCELERATION, |
| 211 | LATERAL_ACCELERATION, |
| 212 | VOLTAGE, |
| 213 | VELOCITY, |
| 214 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 215 | |
| 216 | // Definition of a constraint on a trajectory |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 217 | table Constraint { |
| 218 | constraint_type:ConstraintType; |
| 219 | |
| 220 | value:float; |
| 221 | |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 222 | // start and end distance are only checked for velocity limits. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 223 | start_distance:float; |
| 224 | end_distance:float; |
| 225 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 226 | |
| 227 | // Parameters for computing a trajectory using a chain of splines and |
| 228 | // constraints. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 229 | table MultiSpline { |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 230 | // 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 Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 233 | spline_count:byte; |
| 234 | // Maximum of 36 spline points (7 splines). |
| 235 | spline_x:[float]; |
| 236 | spline_y:[float]; |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 237 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 238 | // Maximum of 6 constraints; |
| 239 | constraints:[Constraint]; |
| 240 | } |