James Kuszmaul | ef35d73 | 2022-02-12 16:37:32 -0800 | [diff] [blame] | 1 | include "frc971/control_loops/drivetrain/drivetrain_status.fbs"; |
| 2 | |
| 3 | namespace frc971.controls; |
| 4 | |
| 5 | // Stores the state associated with the acceleration-based modelling. |
| 6 | table AccelBasedState { |
| 7 | // x/y position, in meters. |
| 8 | x:double (id: 0); |
| 9 | y:double (id: 1); |
| 10 | // heading, in radians. |
| 11 | theta:double (id: 2); |
| 12 | // Velocity in X/Y directions, in m/s. |
| 13 | velocity_x:double (id: 3); |
| 14 | velocity_y:double (id: 4); |
| 15 | } |
| 16 | |
| 17 | // Stores the state associated with the drivetrain model-based state. |
| 18 | // This model assumes zero lateral motion of the drivetrain. |
| 19 | table ModelBasedState { |
| 20 | // x/y position, in meters. |
| 21 | x:double (id: 0); |
| 22 | y:double (id: 1); |
| 23 | // heading, in radians. |
| 24 | theta:double (id: 2); |
| 25 | // Expected encoder reading for the left side of the drivetrain, in meters. |
| 26 | left_encoder:double (id: 3); |
| 27 | // Modelled velocity of the left side of the drivetrain, in meters / second. |
| 28 | left_velocity:double (id: 4); |
| 29 | // Estimated voltage error, in volts. |
| 30 | left_voltage_error:double (id: 5); |
| 31 | // Same as the left_* fields, but for the right side of the drivetrain. |
| 32 | right_encoder:double (id: 6); |
| 33 | right_velocity:double (id: 7); |
| 34 | right_voltage_error:double (id: 8); |
| 35 | } |
| 36 | |
| 37 | table ModelBasedStatus { |
| 38 | // Current acceleration and model-based states. Depending on using_model, |
| 39 | // one of these will be the ground-truth and the other will be calculated |
| 40 | // based on it. E.g. if using_model is true, then model_state will be |
| 41 | // populated as you'd expect, while accel_state will be populated to be |
| 42 | // consistent with model_state (e.g., no lateral motion). |
| 43 | accel_state:AccelBasedState (id: 0); |
| 44 | model_state:ModelBasedState (id: 1); |
| 45 | // using_model indicates whether we are currently in in model-based or |
| 46 | // accelerometer-based estimation. |
| 47 | using_model:bool (id: 2); |
| 48 | // Current residual associated with the amount of inconsistency between |
| 49 | // the two models. Will be zero if the drivetrain model is perfectly |
| 50 | // consistent with the IMU readings. |
| 51 | residual:double (id: 3); |
| 52 | // Status from the down estimator. |
| 53 | down_estimator:frc971.control_loops.drivetrain.DownEstimatorState (id: 4); |
| 54 | // Current ground-truth for x/y/theta. Should match those present in *_state. |
| 55 | x:double (id: 5); |
| 56 | y:double (id: 6); |
| 57 | theta:double (id: 7); |
| 58 | // Current accelerations implied by the current accelerometer + down estimator |
| 59 | // + yaw readings. |
| 60 | implied_accel_x:double (id: 8); |
| 61 | implied_accel_y:double (id: 9); |
| 62 | implied_accel_z:double (id: 10); |
| 63 | // oldest_* are the oldest surviving branches of the model that have just been |
| 64 | // running purely on one model. |
| 65 | oldest_accel_state:AccelBasedState (id: 11); |
| 66 | oldest_model_state:ModelBasedState (id: 12); |
| 67 | // Filtered version of the residual field--this is what is actually used by |
| 68 | // the code for determining when to swap between modes. |
| 69 | filtered_residual:double (id: 13); |
| 70 | // Components of the residual. Useful for debugging. |
| 71 | velocity_residual:double (id: 14); |
| 72 | accel_residual:double (id: 15); |
| 73 | theta_rate_residual:double (id: 16); |
| 74 | // Number of times we have missed an IMU reading. Should never increase except |
| 75 | // *maybe* during startup. |
| 76 | clock_resets:int (id: 17); |
| 77 | } |
| 78 | |
| 79 | table LocalizerStatus { |
| 80 | model_based:ModelBasedStatus (id: 0); |
| 81 | // Whether the IMU is zeroed or not. |
| 82 | zeroed:bool (id: 1); |
| 83 | // Whether the IMU zeroing is faulted or not. |
| 84 | faulted_zero:bool (id: 2); |
| 85 | } |
| 86 | |
| 87 | root_type LocalizerStatus; |