Brian Silverman | e0a9546 | 2014-02-17 00:41:09 -0800 | [diff] [blame] | 1 | package frc971; |
| 2 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 3 | // Represents all of the data for a single potentiometer and indexed encoder |
| 4 | // pair. |
| 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 PotAndIndexPosition { |
| 10 | // Current position read from the encoder. |
| 11 | double encoder; |
| 12 | // Current position read from the potentiometer. |
| 13 | double pot; |
| 14 | |
| 15 | // Position from the encoder latched at the last index pulse. |
| 16 | double latched_encoder; |
| 17 | // Position from the potentiometer latched at the last index pulse. |
| 18 | double latched_pot; |
| 19 | |
| 20 | // How many index pulses we've seen since startup. Starts at 0. |
| 21 | uint32_t index_pulses; |
Brian Silverman | e0a9546 | 2014-02-17 00:41:09 -0800 | [diff] [blame] | 22 | }; |
Brian Silverman | 5b433df | 2014-02-17 11:57:37 -0800 | [diff] [blame] | 23 | |
Daniel Petti | ab27423 | 2015-02-16 19:15:34 -0800 | [diff] [blame] | 24 | // The internal state of a zeroing estimator. |
| 25 | struct EstimatorState { |
| 26 | // If true, there has been a fatal error for the estimator. |
| 27 | bool error; |
| 28 | // If the joint has seen an index pulse and is zeroed. |
| 29 | bool zeroed; |
| 30 | // The estimated position of the joint. |
| 31 | double position; |
| 32 | }; |
| 33 | |
Brian Silverman | 0a7f606 | 2015-01-24 17:41:33 -0500 | [diff] [blame] | 34 | // A left/right pair of PotAndIndexPositions. |
| 35 | struct PotAndIndexPair { |
| 36 | PotAndIndexPosition left; |
| 37 | PotAndIndexPosition right; |
Austin Schuh | 60c5666 | 2014-02-17 14:37:19 -0800 | [diff] [blame] | 38 | }; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 39 | |
| 40 | // Records edges captured on a single hall effect sensor. |
| 41 | struct HallEffectStruct { |
| 42 | bool current; |
| 43 | int32_t posedge_count; |
| 44 | int32_t negedge_count; |
Brian Silverman | d3efb18 | 2015-05-13 23:04:29 -0400 | [diff] [blame] | 45 | double posedge_value; |
| 46 | double negedge_value; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | // Records the positions for a mechanism with edge-capturing sensors on it. |
| 50 | struct HallEffectPositions { |
| 51 | double current; |
| 52 | double posedge; |
| 53 | double negedge; |
| 54 | }; |
| 55 | |
| 56 | // Records edges captured on a single hall effect sensor. |
| 57 | struct PosedgeOnlyCountedHallEffectStruct { |
| 58 | bool current; |
| 59 | int32_t posedge_count; |
| 60 | int32_t negedge_count; |
| 61 | double posedge_value; |
| 62 | }; |