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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 11 | encoder:double (id: 0); |
Philipp Schrader | fd6335e | 2017-02-04 01:26:40 +0000 | [diff] [blame] | 12 | // Position from the encoder latched at the last index pulse. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 13 | latched_encoder:double (id: 1); |
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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 15 | index_pulses:uint (id: 2); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 26 | encoder:double (id: 0); |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 27 | // Current position read from the potentiometer. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 28 | pot:double (id: 1); |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 29 | |
| 30 | // Position from the encoder latched at the last index pulse. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 31 | latched_encoder:double (id: 2); |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 32 | // Position from the potentiometer latched at the last index pulse. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 33 | latched_pot:double (id: 3); |
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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 36 | index_pulses:uint (id: 4); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 47 | encoder:double (id: 0); |
| 48 | absolute_encoder:double (id: 1); |
Diana Vandenberg | abb3d19 | 2017-01-28 16:19:43 -0800 | [diff] [blame] | 49 | |
| 50 | // Current position read from the potentiometer. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 51 | pot:double (id: 2); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 60 | encoder:double (id: 0); |
| 61 | absolute_encoder:double (id: 1); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 73 | encoder:double (id: 0); |
| 74 | absolute_encoder:double (id: 1); |
Ravago Jones | 988b038 | 2020-10-10 15:33:40 -0700 | [diff] [blame] | 75 | |
| 76 | // Current position read from the single turn absolute encoder. |
| 77 | // This can not turn more than one rotation. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 78 | single_turn_absolute_encoder:double (id: 2); |
Ravago Jones | 988b038 | 2020-10-10 15:33:40 -0700 | [diff] [blame] | 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. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 86 | encoder:double (id: 0); |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Ravago Jones | 726deb0 | 2021-05-29 14:36:43 -0700 | [diff] [blame^] | 89 | // An enum to represent the different types of errors |
| 90 | // a zeroing estimator could have. |
| 91 | enum ZeroingError : short { |
| 92 | OFFSET_MOVED_TOO_FAR, |
| 93 | LOST_ABSOLUTE_ENCODER |
| 94 | } |
| 95 | |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 96 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 97 | table EstimatorState { |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 98 | // If true, there has been a fatal error for the estimator. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 99 | error:bool (id: 0); |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 100 | // If the joint has seen an index pulse and is zeroed. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 101 | zeroed:bool (id: 1); |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 102 | // The estimated position of the joint. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 103 | position:double (id: 2); |
Austin Schuh | be133ed | 2016-03-11 21:23:34 -0800 | [diff] [blame] | 104 | |
| 105 | // The estimated position not using the index pulse. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 106 | pot_position:double (id: 3); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 107 | } |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 108 | |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 109 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 110 | table PotAndAbsoluteEncoderEstimatorState { |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 111 | // If true, there has been a fatal error for the estimator. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 112 | error:bool (id: 0); |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 113 | // If the joint has seen an index pulse and is zeroed. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 114 | zeroed:bool (id: 1); |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 115 | // The estimated position of the joint. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 116 | position:double (id: 2); |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 117 | |
| 118 | // The estimated position not using the index pulse. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 119 | pot_position:double (id: 3); |
Austin Schuh | 0e1c2c6 | 2017-02-21 02:03:25 -0800 | [diff] [blame] | 120 | |
| 121 | // The estimated absolute position of the encoder. This is filtered, so it |
| 122 | // can be easily used when zeroing. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 123 | absolute_position:double (id: 4); |
Ravago Jones | 726deb0 | 2021-05-29 14:36:43 -0700 | [diff] [blame^] | 124 | |
| 125 | // If errored, this contains the causes for the error. |
| 126 | errors: [ZeroingError] (id: 5); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 127 | } |
Austin Schuh | 5f01f15 | 2017-02-11 21:34:08 -0800 | [diff] [blame] | 128 | |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 129 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 130 | table AbsoluteEncoderEstimatorState { |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 131 | // If true, there has been a fatal error for the estimator. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 132 | error:bool (id: 0); |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 133 | // If the joint has seen an index pulse and is zeroed. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 134 | zeroed:bool (id: 1); |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 135 | // The estimated position of the joint. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 136 | position:double (id: 2); |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 137 | |
| 138 | // The estimated absolute position of the encoder. This is filtered, so it |
| 139 | // can be easily used when zeroing. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 140 | absolute_position:double (id: 3); |
Ravago Jones | 726deb0 | 2021-05-29 14:36:43 -0700 | [diff] [blame^] | 141 | |
| 142 | // If errored, this contains the causes for the error. |
| 143 | errors: [ZeroingError] (id: 4); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 144 | } |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 145 | |
Ravago Jones | ea6464c | 2020-10-10 15:40:46 -0700 | [diff] [blame] | 146 | // The internal state of a zeroing estimator. |
| 147 | table AbsoluteAndAbsoluteEncoderEstimatorState { |
| 148 | // If true, there has been a fatal error for the estimator. |
| 149 | error:bool (id: 0); |
| 150 | // If the joint has seen an index pulse and is zeroed. |
| 151 | zeroed:bool (id: 1); |
| 152 | // The estimated position of the joint. |
| 153 | position:double (id: 2); |
| 154 | |
| 155 | // The estimated absolute position of the encoder. This is filtered, so it |
| 156 | // can be easily used when zeroing. |
| 157 | absolute_position:double (id: 3); |
| 158 | |
| 159 | // Estimated absolute position of the single turn absolute encoder. |
| 160 | single_turn_absolute_position:double (id: 4); |
Ravago Jones | 726deb0 | 2021-05-29 14:36:43 -0700 | [diff] [blame^] | 161 | |
| 162 | // If errored, this contains the causes for the error. |
| 163 | errors: [ZeroingError] (id: 5); |
Ravago Jones | ea6464c | 2020-10-10 15:40:46 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Ravago Jones | 726deb0 | 2021-05-29 14:36:43 -0700 | [diff] [blame^] | 166 | |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 167 | table RelativeEncoderEstimatorState { |
| 168 | // If true, there has been a fatal error for the estimator. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 169 | error:bool (id: 0); |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 170 | |
| 171 | // The estimated position of the joint. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 172 | position:double (id: 1); |
Tyler Chatow | 3c47f3c | 2020-01-29 20:45:23 -0800 | [diff] [blame] | 173 | } |
| 174 | |
Austin Schuh | d82068e | 2019-01-26 20:05:42 -0800 | [diff] [blame] | 175 | // The internal state of a zeroing estimator. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 176 | table IndexEstimatorState { |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 177 | // If true, there has been a fatal error for the estimator. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 178 | error:bool (id: 0); |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 179 | // If the joint has seen an index pulse and is zeroed. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 180 | zeroed:bool (id: 1); |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 181 | // The estimated position of the joint. This is just the position relative to |
| 182 | // where we started if we're not zeroed yet. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 183 | position:double (id: 2); |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 184 | |
| 185 | // The positions of the extreme index pulses we've seen. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 186 | min_index_position:double (id: 3); |
| 187 | max_index_position:double (id: 4); |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 188 | // The number of index pulses we've seen. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 189 | index_pulses_seen:int (id: 5); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 190 | } |
Brian Silverman | f37839c | 2017-02-19 18:07:15 -0800 | [diff] [blame] | 191 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 192 | table HallEffectAndPositionEstimatorState { |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 193 | // If error. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 194 | error:bool (id: 0); |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 195 | // If we've found a positive edge while moving backwards and is zeroed. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 196 | zeroed:bool (id: 1); |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 197 | // Encoder angle relative to where we started. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 198 | encoder:double (id: 2); |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 199 | // The positions of the extreme posedges we've seen. |
| 200 | // If we've gotten enough samples where the hall effect is high before can be |
| 201 | // certain it is not a false positive. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 202 | high_long_enough:bool (id: 3); |
| 203 | offset:double (id: 4); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 204 | } |
Austin Schuh | 5593403 | 2017-03-11 12:45:27 -0800 | [diff] [blame] | 205 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 206 | // A left/right pair of PotAndIndexPositions. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 207 | table PotAndIndexPair { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 208 | left:PotAndIndexPosition (id: 0); |
| 209 | right:PotAndIndexPosition (id: 1); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 210 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 211 | |
| 212 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 213 | table HallEffectStruct { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 214 | current:bool (id: 0); |
| 215 | posedge_count:int (id: 1); |
| 216 | negedge_count:int (id: 2); |
| 217 | posedge_value:double (id: 3); |
| 218 | negedge_value:double (id: 4); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 219 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 220 | |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 221 | // Records the hall effect sensor and encoder values. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 222 | table HallEffectAndPosition { |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 223 | // The current hall effect state. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 224 | current:bool (id: 0); |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 225 | // The current encoder position. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 226 | encoder:double (id: 1); |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 227 | // The number of positive and negative edges we've seen on the hall effect |
| 228 | // sensor. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 229 | posedge_count:int (id: 2); |
| 230 | negedge_count:int (id: 3); |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 231 | // The values corresponding to the last hall effect sensor reading. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 232 | posedge_value:double (id: 4); |
| 233 | negedge_value:double (id: 5); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 234 | } |
Austin Schuh | f380a3f | 2017-03-04 22:31:47 -0800 | [diff] [blame] | 235 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 236 | // Records the positions for a mechanism with edge-capturing sensors on it. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 237 | table HallEventPositions { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 238 | current:double (id: 0); |
| 239 | posedge:double (id: 1); |
| 240 | negedge:double (id: 2); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 241 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 242 | |
| 243 | // Records edges captured on a single hall effect sensor. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 244 | table PosedgeOnlyCountedHallEffectStruct { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 245 | current:bool (id: 0); |
| 246 | posedge_count:int (id: 1); |
| 247 | negedge_count:int (id: 2); |
| 248 | posedge_value:double (id: 3); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 249 | } |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 250 | |
| 251 | // Parameters for the motion profiles. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 252 | table ProfileParameters { |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 253 | // Maximum velocity for the profile. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 254 | max_velocity:float (id: 0); |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 255 | // Maximum acceleration for the profile. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 256 | max_acceleration:float (id: 1); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | enum ConstraintType : byte { |
| 260 | CONSTRAINT_TYPE_UNDEFINED, |
| 261 | LONGITUDINAL_ACCELERATION, |
| 262 | LATERAL_ACCELERATION, |
| 263 | VOLTAGE, |
| 264 | VELOCITY, |
| 265 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 266 | |
| 267 | // Definition of a constraint on a trajectory |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 268 | table Constraint { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 269 | constraint_type:ConstraintType (id: 0); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 270 | |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 271 | value:float (id: 1); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 272 | |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 273 | // start and end distance are only checked for velocity limits. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 274 | start_distance:float (id: 2); |
| 275 | end_distance:float (id: 3); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 276 | } |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 277 | |
| 278 | // Parameters for computing a trajectory using a chain of splines and |
| 279 | // constraints. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 280 | table MultiSpline { |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 281 | // Number of splines. The spline point arrays will be expected to have |
| 282 | // 6 + 5 * (n - 1) points in them. The endpoints are shared between |
| 283 | // neighboring splines. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 284 | spline_count:byte (id: 0); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 285 | // Maximum of 36 spline points (7 splines). |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 286 | spline_x:[float] (id: 1); |
| 287 | spline_y:[float] (id: 2); |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 288 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 289 | // Maximum of 6 constraints; |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 290 | constraints:[Constraint] (id: 3); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 291 | } |