blob: 9c31443c00fa40bbbbab8899866e45cc9574334f [file] [log] [blame]
Brian Silvermane0a95462014-02-17 00:41:09 -08001package frc971;
2
Brian Silverman0a7f6062015-01-24 17:41:33 -05003// 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.
9struct 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 Silvermane0a95462014-02-17 00:41:09 -080022};
Brian Silverman5b433df2014-02-17 11:57:37 -080023
Daniel Pettiab274232015-02-16 19:15:34 -080024// The internal state of a zeroing estimator.
25struct 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;
Austin Schuhbe133ed2016-03-11 21:23:34 -080032
33 // The estimated position not using the index pulse.
34 double pot_position;
Daniel Pettiab274232015-02-16 19:15:34 -080035};
36
Brian Silverman0a7f6062015-01-24 17:41:33 -050037// A left/right pair of PotAndIndexPositions.
38struct PotAndIndexPair {
39 PotAndIndexPosition left;
40 PotAndIndexPosition right;
Austin Schuh60c56662014-02-17 14:37:19 -080041};
Brian Silverman17f503e2015-08-02 18:17:18 -070042
43// Records edges captured on a single hall effect sensor.
44struct HallEffectStruct {
45 bool current;
46 int32_t posedge_count;
47 int32_t negedge_count;
Brian Silvermand3efb182015-05-13 23:04:29 -040048 double posedge_value;
49 double negedge_value;
Brian Silverman17f503e2015-08-02 18:17:18 -070050};
51
52// Records the positions for a mechanism with edge-capturing sensors on it.
53struct HallEffectPositions {
54 double current;
55 double posedge;
56 double negedge;
57};
58
59// Records edges captured on a single hall effect sensor.
60struct PosedgeOnlyCountedHallEffectStruct {
61 bool current;
62 int32_t posedge_count;
63 int32_t negedge_count;
64 double posedge_value;
65};
Austin Schuhedbb64f2016-03-19 01:18:09 -070066
67// Parameters for the motion profiles.
68struct ProfileParameters {
69 // Maximum velocity for the profile.
70 float max_velocity;
71 // Maximum acceleration for the profile.
72 float max_acceleration;
73};