blob: 0e495524d34371a5d25ef322b4fa86e7f7cacb20 [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 Kuszmaul3e1bb272020-01-17 18:38:19 -0800102table DownEstimatorState {
103 quaternion_x:double;
104 quaternion_y:double;
105 quaternion_z:double;
106 quaternion_w:double;
107
108 // Side-to-side and forwards/backwards pitch numbers. Note that we do this
109 // instead of standard roll/pitch/yaw euler angles because it was a pain to
110 // try and numerically stable roll/pitch/yaw numbers, and Eigen's interface
111 // doesn't resolve the redundancies quite how we'd like.
112 // Lateral pitch is the side-to-side pitch of the robot; longitudinal pitch is
113 // the forwards to backwards pitch of the robot; longitudinal_pitch
114 // corresponds with the traditional usage of "pitch".
115 // All angles in radians.
116 lateral_pitch:float;
117 longitudinal_pitch:float;
118 // Current yaw angle (heading) of the robot, as estimated solely by the down
119 // estimator.
120 yaw:float;
121}
122
Alex Perrycb7da4b2019-08-28 19:35:56 -0700123table Status {
124 // Estimated speed of the center of the robot in m/s (positive forwards).
125 robot_speed:double;
126
127 // Estimated relative position of each drivetrain side (in meters).
128 estimated_left_position:double;
129 estimated_right_position:double;
130
131 // Estimated velocity of each drivetrain side (in m/s).
132 estimated_left_velocity:double;
133 estimated_right_velocity:double;
134
135 // The voltage we wanted to send to each drivetrain side last cycle.
136 uncapped_left_voltage:double;
137 uncapped_right_voltage:double;
138
139 // The voltage error for the left and right sides.
140 left_voltage_error:double;
141 right_voltage_error:double;
142
143 // The profiled goal states.
144 profiled_left_position_goal:double;
145 profiled_right_position_goal:double;
146 profiled_left_velocity_goal:double;
147 profiled_right_velocity_goal:double;
148
149 // The KF offset
150 estimated_angular_velocity_error:double;
151 // The KF estimated heading.
152 estimated_heading:double;
153
154 // xytheta of the robot.
155 x:double;
156 y:double;
157 theta:double;
158
159 // True if the output voltage was capped last cycle.
160 output_was_capped:bool;
161
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800162 // The pitch of the robot relative to the ground--only includes
163 // forwards/backwards rotation.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700164 ground_angle:double;
165
166 // Information about shifting logic and curent gear, for logging purposes
167 gear_logging:GearLogging;
168 cim_logging:CIMLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800169
Alex Perrycb7da4b2019-08-28 19:35:56 -0700170 trajectory_logging:TrajectoryLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800171
Alex Perrycb7da4b2019-08-28 19:35:56 -0700172 line_follow_logging:LineFollowLogging;
James Kuszmaulaf5dfad2020-01-03 20:02:54 -0800173
174 poly_drive_logging:PolyDriveLogging;
James Kuszmaul3e1bb272020-01-17 18:38:19 -0800175
176 down_estimator:DownEstimatorState;
Alex Perrycb7da4b2019-08-28 19:35:56 -0700177}
178
179root_type Status;