blob: 36421315422ab5f7d0422a6cb850aae200b0a833 [file] [log] [blame]
Alex Perrycb7da4b2019-08-28 19:35:56 -07001include "frc971/control_loops/control_loops.fbs";
2
3namespace frc971.control_loops.drivetrain;
4
5// For logging information about what the code is doing with the shifters.
6table 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.
20table 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 Kuszmaulaf5dfad2020-01-03 20:02:54 -080036// Logging information for the polydrivetrain implementation.
37table 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 Perrycb7da4b2019-08-28 19:35:56 -070047enum 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.
55table 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.
83table 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
James Kuszmaul18f669c2020-02-11 16:51:06 -0800102// Current states of the EKF. See hybrid_ekf.h for detailed comments.
103table LocalizerState {
104 // X/Y field position, in meters.
105 x:float;
106 y:float;
107 // Current heading, in radians.
108 theta:float;
109 // Current estimate of the left encoder position, in meters.
110 left_encoder:float;
111 // Velocity of the left side of the robot.
112 left_velocity:float;
113 // Current estimate of the right encoder position, in meters.
114 right_encoder:float;
115 // Velocity of the right side of the robot.
116 right_velocity:float;
117 // Current "voltage error" terms, in V.
118 left_voltage_error:float;
119 right_voltage_error:float;
120 // Estimate of the offset between the encoder readings and true rotation of
121 // the robot, in rad/sec.
122 angular_error:float;
123 // Current difference between the estimated longitudinal velocity of the robot
124 // and that experienced by the wheels, in m/s.
125 longitudinal_velocity_offset:float;
126 // Lateral velocity of the robot, in m/s.
127 lateral_velocity:float;
128}
129
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800130table DownEstimatorState {
131 quaternion_x:double;
132 quaternion_y:double;
133 quaternion_z:double;
134 quaternion_w:double;
135
136 // Side-to-side and forwards/backwards pitch numbers. Note that we do this
137 // instead of standard roll/pitch/yaw euler angles because it was a pain to
138 // try and numerically stable roll/pitch/yaw numbers, and Eigen's interface
139 // doesn't resolve the redundancies quite how we'd like.
140 // Lateral pitch is the side-to-side pitch of the robot; longitudinal pitch is
141 // the forwards to backwards pitch of the robot; longitudinal_pitch
142 // corresponds with the traditional usage of "pitch".
143 // All angles in radians.
144 lateral_pitch:float;
145 longitudinal_pitch:float;
James Kuszmaul18f669c2020-02-11 16:51:06 -0800146 // Current yaw angle (heading) of the robot, as estimated solely by
147 // integrating the Z-axis of the gyro (in rad).
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800148 yaw:float;
James Kuszmaul18f669c2020-02-11 16:51:06 -0800149
150 // Current position of the robot, as determined solely from the
151 // IMU/down-estimator, in meters.
152 position_x:float;
153 position_y:float;
154 position_z:float;
155
156 // Current velocity of the robot, as determined solely from the
157 // IMU/down-estimator, in meters / sec.
158 velocity_x:float;
159 velocity_y:float;
160 velocity_z:float;
161
162 // Current acceleration of the robot, with pitch/roll (but not yaw)
163 // compensated out, in meters / sec / sec.
164 accel_x:float;
165 accel_y:float;
166 accel_z:float;
167
168 // Current acceleration that we expect to see from the accelerometer, assuming
169 // no acceleration other than that due to gravity, in g's.
170 expected_accel_x:float;
171 expected_accel_y:float;
172 expected_accel_z:float;
173
174 // Current estimate of the overall acceleration due to gravity, in g's. Should
175 // generally be within ~0.003 g's of 1.0.
176 gravity_magnitude:float;
177
178 consecutive_still:int;
179}
180
181table ImuZeroerState {
182 // True if we have successfully zeroed the IMU.
183 zeroed:bool;
184 // True if the zeroing code has observed some inconsistency in the IMU.
185 faulted:bool;
186 // Number of continuous zeroing measurements that we have accumulated for use
187 // in the zeroing.
188 number_of_zeroes:int;
189
190 // Current zeroing values beind used for each gyro axis, in rad / sec.
191 gyro_x_average:float;
192 gyro_y_average:float;
193 gyro_z_average:float;
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800194}
195
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196table Status {
197 // Estimated speed of the center of the robot in m/s (positive forwards).
198 robot_speed:double;
199
200 // Estimated relative position of each drivetrain side (in meters).
201 estimated_left_position:double;
202 estimated_right_position:double;
203
204 // Estimated velocity of each drivetrain side (in m/s).
205 estimated_left_velocity:double;
206 estimated_right_velocity:double;
207
208 // The voltage we wanted to send to each drivetrain side last cycle.
209 uncapped_left_voltage:double;
210 uncapped_right_voltage:double;
211
212 // The voltage error for the left and right sides.
213 left_voltage_error:double;
214 right_voltage_error:double;
215
216 // The profiled goal states.
217 profiled_left_position_goal:double;
218 profiled_right_position_goal:double;
219 profiled_left_velocity_goal:double;
220 profiled_right_velocity_goal:double;
221
222 // The KF offset
223 estimated_angular_velocity_error:double;
224 // The KF estimated heading.
225 estimated_heading:double;
226
227 // xytheta of the robot.
228 x:double;
229 y:double;
230 theta:double;
231
232 // True if the output voltage was capped last cycle.
233 output_was_capped:bool;
234
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800235 // The pitch of the robot relative to the ground--only includes
236 // forwards/backwards rotation.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700237 ground_angle:double;
238
239 // Information about shifting logic and curent gear, for logging purposes
240 gear_logging:GearLogging;
241 cim_logging:CIMLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800242
Alex Perrycb7da4b2019-08-28 19:35:56 -0700243 trajectory_logging:TrajectoryLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800244
Alex Perrycb7da4b2019-08-28 19:35:56 -0700245 line_follow_logging:LineFollowLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800246
247 poly_drive_logging:PolyDriveLogging;
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800248
249 down_estimator:DownEstimatorState;
James Kuszmaul18f669c2020-02-11 16:51:06 -0800250
251 localizer:LocalizerState;
252
253 zeroing:ImuZeroerState;
Alex Perrycb7da4b2019-08-28 19:35:56 -0700254}
255
256root_type Status;