Brian Silverman | e0a9546 | 2014-02-17 00:41:09 -0800 | [diff] [blame] | 1 | package frc971; |
| 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. |
| 9 | struct IndexPosition { |
| 10 | // Current position read from the encoder. |
| 11 | double encoder; |
| 12 | // Position from the encoder latched at the last index pulse. |
| 13 | double latched_encoder; |
| 14 | // How many index pulses we've seen since startup. Starts at 0. |
| 15 | uint32_t index_pulses; |
| 16 | }; |
| 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. |
| 24 | struct PotAndIndexPosition { |
| 25 | // Current position read from the encoder. |
| 26 | double encoder; |
| 27 | // Current position read from the potentiometer. |
| 28 | double pot; |
| 29 | |
| 30 | // Position from the encoder latched at the last index pulse. |
| 31 | double latched_encoder; |
| 32 | // Position from the potentiometer latched at the last index pulse. |
| 33 | double latched_pot; |
| 34 | |
| 35 | // How many index pulses we've seen since startup. Starts at 0. |
| 36 | uint32_t index_pulses; |
Brian Silverman | e0a9546 | 2014-02-17 00:41:09 -0800 | [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. |
| 45 | struct PotAndAbsolutePosition { |
| 46 | // Current position read from each encoder. |
| 47 | double relative_encoder; |
| 48 | double absolute_encoder; |
| 49 | |
| 50 | // Current position read from the potentiometer. |
| 51 | double pot; |
| 52 | }; |
| 53 | |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 54 | // The internal state of a zeroing estimator. |
| 55 | struct EstimatorState { |
| 56 | // If true, there has been a fatal error for the estimator. |
| 57 | bool error; |
| 58 | // If the joint has seen an index pulse and is zeroed. |
| 59 | bool zeroed; |
| 60 | // The estimated position of the joint. |
| 61 | double position; |
Austin Schuh | be133ed | 2016-03-11 21:23:34 -0800 | [diff] [blame] | 62 | |
| 63 | // The estimated position not using the index pulse. |
| 64 | double pot_position; |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 67 | // A left/right pair of PotAndIndexPositions. |
| 68 | struct PotAndIndexPair { |
| 69 | PotAndIndexPosition left; |
| 70 | PotAndIndexPosition right; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 71 | }; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 72 | |
| 73 | // Records edges captured on a single hall effect sensor. |
| 74 | struct HallEffectStruct { |
| 75 | bool current; |
| 76 | int32_t posedge_count; |
| 77 | int32_t negedge_count; |
Brian Silverman | d3efb18 | 2015-05-13 23:04:29 -0400 | [diff] [blame] | 78 | double posedge_value; |
| 79 | double negedge_value; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | // Records the positions for a mechanism with edge-capturing sensors on it. |
| 83 | struct HallEffectPositions { |
| 84 | double current; |
| 85 | double posedge; |
| 86 | double negedge; |
| 87 | }; |
| 88 | |
| 89 | // Records edges captured on a single hall effect sensor. |
| 90 | struct PosedgeOnlyCountedHallEffectStruct { |
| 91 | bool current; |
| 92 | int32_t posedge_count; |
| 93 | int32_t negedge_count; |
| 94 | double posedge_value; |
| 95 | }; |
Austin Schuh | edbb64f | 2016-03-19 01:18:09 -0700 | [diff] [blame] | 96 | |
| 97 | // Parameters for the motion profiles. |
| 98 | struct ProfileParameters { |
| 99 | // Maximum velocity for the profile. |
| 100 | float max_velocity; |
| 101 | // Maximum acceleration for the profile. |
| 102 | float max_acceleration; |
| 103 | }; |