Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 1 | include "frc971/control_loops/control_loops.fbs"; |
| 2 | |
| 3 | namespace frc971.control_loops.drivetrain; |
| 4 | |
| 5 | // For logging information about what the code is doing with the shifters. |
| 6 | table GearLogging { |
| 7 | // Which controller is being used. |
| 8 | controller_index:byte; |
| 9 | |
| 10 | // Whether each loop for the drivetrain sides is the high-gear one. |
| 11 | left_loop_high:bool; |
| 12 | right_loop_high:bool; |
| 13 | |
| 14 | // The states of each drivetrain shifter. |
| 15 | left_state:byte; |
| 16 | right_state:byte; |
| 17 | } |
| 18 | |
| 19 | // For logging information about the state of the shifters. |
| 20 | table CIMLogging { |
| 21 | // Whether the code thinks each drivetrain side is currently in gear. |
| 22 | left_in_gear:bool; |
| 23 | right_in_gear:bool; |
| 24 | |
| 25 | // The angular velocities (in rad/s, positive forward) the code thinks motors |
| 26 | // on each side of the drivetrain are moving at. |
| 27 | left_motor_speed:double; |
| 28 | right_motor_speed:double; |
| 29 | |
| 30 | // The velocity estimates for each drivetrain side of the robot (in m/s, |
| 31 | // positive forward) that can be used for shifting. |
| 32 | left_velocity:double; |
| 33 | right_velocity:double; |
| 34 | } |
| 35 | |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 36 | // Logging information for the polydrivetrain implementation. |
| 37 | table PolyDriveLogging { |
| 38 | // Calculated velocity goals for the left/right sides of the drivetrain, in |
| 39 | // m/s. |
| 40 | goal_left_velocity:float; |
| 41 | goal_right_velocity:float; |
| 42 | // Feedforward components of the left/right voltages. |
| 43 | ff_left_voltage:float; |
| 44 | ff_right_voltage:float; |
| 45 | } |
| 46 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 47 | enum PlanningState : byte { |
| 48 | NO_PLAN, |
| 49 | BUILDING_TRAJECTORY, |
| 50 | PLANNING_TRAJECTORY, |
| 51 | PLANNED, |
| 52 | } |
| 53 | |
| 54 | // For logging information about the state of the trajectory planning. |
| 55 | table TrajectoryLogging { |
| 56 | // state of planning the trajectory. |
| 57 | planning_state:PlanningState; |
| 58 | |
| 59 | // State of the spline execution. |
| 60 | is_executing:bool; |
| 61 | // Whether we have finished the spline specified by current_spline_idx. |
| 62 | is_executed:bool; |
| 63 | |
| 64 | // The handle of the goal spline. 0 means stop requested. |
| 65 | goal_spline_handle:int; |
| 66 | // Handle of the executing spline. -1 means none requested. If there was no |
| 67 | // spline executing when a spline finished optimizing, it will become the |
| 68 | // current spline even if we aren't ready to start yet. |
| 69 | current_spline_idx:int; |
| 70 | // Handle of the spline that is being optimized and staged. |
| 71 | planning_spline_idx:int; |
| 72 | |
| 73 | // Expected position and velocity on the spline |
| 74 | x:float; |
| 75 | y:float; |
| 76 | theta:float; |
| 77 | left_velocity:float; |
| 78 | right_velocity:float; |
| 79 | distance_remaining:float; |
| 80 | } |
| 81 | |
| 82 | // For logging state of the line follower. |
| 83 | table LineFollowLogging { |
| 84 | // Whether we are currently freezing target choice. |
| 85 | frozen:bool; |
| 86 | // Whether we currently have a target. |
| 87 | have_target:bool; |
| 88 | // Absolute position of the current goal. |
| 89 | x:float; |
| 90 | y:float; |
| 91 | theta:float; |
| 92 | // Current lateral offset from line pointing straight out of the target. |
| 93 | offset:float; |
| 94 | // Current distance from the plane of the target, in meters. |
| 95 | distance_to_target:float; |
| 96 | // Current goal heading. |
| 97 | goal_theta:float; |
| 98 | // Current relative heading. |
| 99 | rel_theta:float; |
| 100 | } |
| 101 | |
| 102 | table Status { |
| 103 | // Estimated speed of the center of the robot in m/s (positive forwards). |
| 104 | robot_speed:double; |
| 105 | |
| 106 | // Estimated relative position of each drivetrain side (in meters). |
| 107 | estimated_left_position:double; |
| 108 | estimated_right_position:double; |
| 109 | |
| 110 | // Estimated velocity of each drivetrain side (in m/s). |
| 111 | estimated_left_velocity:double; |
| 112 | estimated_right_velocity:double; |
| 113 | |
| 114 | // The voltage we wanted to send to each drivetrain side last cycle. |
| 115 | uncapped_left_voltage:double; |
| 116 | uncapped_right_voltage:double; |
| 117 | |
| 118 | // The voltage error for the left and right sides. |
| 119 | left_voltage_error:double; |
| 120 | right_voltage_error:double; |
| 121 | |
| 122 | // The profiled goal states. |
| 123 | profiled_left_position_goal:double; |
| 124 | profiled_right_position_goal:double; |
| 125 | profiled_left_velocity_goal:double; |
| 126 | profiled_right_velocity_goal:double; |
| 127 | |
| 128 | // The KF offset |
| 129 | estimated_angular_velocity_error:double; |
| 130 | // The KF estimated heading. |
| 131 | estimated_heading:double; |
| 132 | |
| 133 | // xytheta of the robot. |
| 134 | x:double; |
| 135 | y:double; |
| 136 | theta:double; |
| 137 | |
| 138 | // True if the output voltage was capped last cycle. |
| 139 | output_was_capped:bool; |
| 140 | |
| 141 | // The angle of the robot relative to the ground. |
| 142 | ground_angle:double; |
| 143 | |
| 144 | // Information about shifting logic and curent gear, for logging purposes |
| 145 | gear_logging:GearLogging; |
| 146 | cim_logging:CIMLogging; |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 147 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 148 | trajectory_logging:TrajectoryLogging; |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 149 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 150 | line_follow_logging:LineFollowLogging; |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 151 | |
| 152 | poly_drive_logging:PolyDriveLogging; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | root_type Status; |