blob: 819a28f7e56d1c9622015616187dfe44f90f56a1 [file] [log] [blame]
Brian Silvermanc71537c2016-01-01 13:43:14 -08001package y2012.control_loops;
2
3import "aos/common/controls/control_loops.q";
4
5// For logging information about what the code is doing with the shifters.
6struct GearLogging {
7 // Which controller is being used.
8 int8_t controller_index;
9 // Whether the left loop is the high-gear one.
10 bool left_loop_high;
11 // Whether the right loop is the high-gear one.
12 bool right_loop_high;
13 // The state of the left shifter.
14 int8_t left_state;
15 // The state of the right shifter.
16 int8_t right_state;
17};
18
19// For logging information about the state of the shifters.
20struct CIMLogging {
21 // Whether the code thinks the left side is currently in gear.
22 bool left_in_gear;
23 // Whether the code thinks the right side is currently in gear.
24 bool right_in_gear;
25 // The velocity in rad/s (positive forward) the code thinks the left motor
26 // is currently spinning at.
27 double left_motor_speed;
28 // The velocity in rad/s (positive forward) the code thinks the right motor
29 // is currently spinning at.
30 double right_motor_speed;
31 // The velocity estimate for the left side of the robot in m/s (positive
32 // forward) used for shifting.
33 double left_velocity;
34 // The velocity estimate for the right side of the robot in m/s (positive
35 // forward) used for shifting.
36 double right_velocity;
37};
38
39queue_group DrivetrainQueue {
40 implements aos.control_loops.ControlLoop;
41
42 message Goal {
43 // Position of the steering wheel (positive = turning left when going
44 // forwards).
45 double steering;
46 // Position of the throttle (positive forwards).
47 double throttle;
48 // True to shift into high, false to shift into low.
49 bool highgear;
50 // True to activate quickturn.
51 bool quickturn;
52 // True to have the closed-loop controller take over.
53 bool control_loop_driving;
54 // Position goal for the left side in meters when the closed-loop controller
55 // is active.
56 double left_goal;
57 // Velocity goal for the left side in m/s when the closed-loop controller
58 // is active.
59 double left_velocity_goal;
60 // Position goal for the right side in meters when the closed-loop
61 // controller is active.
62 double right_goal;
63 // Velocity goal for the right side in m/s when the closed-loop controller
64 // is active.
65 double right_velocity_goal;
66 };
67
68 message Position {
69 // Relative position of the left side in meters.
70 double left_encoder;
71 // Relative position of the right side in meters.
72 double right_encoder;
73 // The speed in m/s of the left side from the most recent encoder pulse,
74 // or 0 if there was no edge within the last 5ms.
75 double left_speed;
76 // The speed in m/s of the right side from the most recent encoder pulse,
77 // or 0 if there was no edge within the last 5ms.
78 double right_speed;
79 // Position of the left shifter (smaller = towards low gear).
80 double left_shifter_position;
81 // Position of the right shifter (smaller = towards low gear).
82 double right_shifter_position;
83 double low_left_hall;
84 double high_left_hall;
85 double low_right_hall;
86 double high_right_hall;
87 };
88
89 message Output {
90 // Voltage to send to the left motor(s).
91 double left_voltage;
92 // Voltage to send to the right motor(s).
93 double right_voltage;
94 // True to set the left shifter piston for high gear.
95 bool left_high;
96 // True to set the right shifter piston for high gear.
97 bool right_high;
98 };
99
100 message Status {
101 // Estimated speed of the center of the robot in m/s (positive forwards).
102 double robot_speed;
103 // Estimated relative position of the left side in meters.
104 double filtered_left_position;
105 // Estimated relative position of the right side in meters.
106 double filtered_right_position;
107 // Estimated velocity of the left side in m/s.
108 double filtered_left_velocity;
109 // Estimated velocity of the left side in m/s.
110 double filtered_right_velocity;
111
112 // The voltage we wanted to send to the left side last cycle.
113 double uncapped_left_voltage;
114 // The voltage we wanted to send to the right side last cycle.
115 double uncapped_right_voltage;
116 // True if the output voltage was capped last cycle.
117 bool output_was_capped;
118 };
119
120 queue Goal goal;
121 queue Position position;
122 queue Output output;
123 queue Status status;
124};
125
126queue_group DrivetrainQueue drivetrain_queue;