blob: d7849299c5b2d33e87dffbcccdbb3aa6054f8f63 [file] [log] [blame]
Comran Morshed25f81a02016-01-23 13:40:10 +00001package y2016.control_loops;
2
John Park33858a32018-09-28 23:05:48 -07003import "aos/controls/control_loops.q";
Comran Morshed25f81a02016-01-23 13:40:10 +00004import "frc971/control_loops/control_loops.q";
5
Austin Schuh2fc10fa2016-02-08 00:44:34 -08006struct JointState {
7 // Angle of the joint in radians.
Austin Schuh39fd6102016-02-13 22:59:48 -08008 float angle;
Austin Schuh2fc10fa2016-02-08 00:44:34 -08009 // Angular velocity of the joint in radians/second.
10 float angular_velocity;
11 // Profiled goal angle of the joint in radians.
Austin Schuh39fd6102016-02-13 22:59:48 -080012 float goal_angle;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080013 // Profiled goal angular velocity of the joint in radians/second.
Austin Schuh39fd6102016-02-13 22:59:48 -080014 float goal_angular_velocity;
15 // Unprofiled goal angle of the joint in radians.
16 float unprofiled_goal_angle;
17 // Unprofiled goal angular velocity of the joint in radians/second.
18 float unprofiled_goal_angular_velocity;
Austin Schuh2fc10fa2016-02-08 00:44:34 -080019
Austin Schuhbe041152016-02-28 22:01:52 -080020 // The estimated voltage error.
21 float voltage_error;
22
23 // The calculated velocity with delta x/delta t
24 float calculated_velocity;
25
26 // Components of the control loop output
27 float position_power;
28 float velocity_power;
29 float feedforwards_power;
30
Austin Schuh2fc10fa2016-02-08 00:44:34 -080031 // State of the estimator.
32 .frc971.EstimatorState estimator_state;
33};
34
Austin Schuh9481d0d2019-06-29 21:56:17 -070035// Published on ".y2016.control_loops.superstructure_queue"
Comran Morshed25f81a02016-01-23 13:40:10 +000036queue_group SuperstructureQueue {
37 implements aos.control_loops.ControlLoop;
38
39 message Goal {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080040 // Zero on the intake is when the horizontal tube stock members are level
Austin Schuh009b93e2017-02-05 23:22:19 -080041 // with the top frame rails of the robot. This will be essentially when we
42 // are in the intaking position. Positive is up. The angle is measured
43 // relative to the top
Austin Schuh2fc10fa2016-02-08 00:44:34 -080044 // of the robot frame.
Austin Schuh009b93e2017-02-05 23:22:19 -080045 // Zero on the shoulder is when the shoulder is down against the hard stop
46 // blocks. Positive is up. The angle is measured relative to the top of
47 // the robot frame.
Austin Schuh2fc10fa2016-02-08 00:44:34 -080048 // Zero on the wrist is horizontal and landed in the bellypan. Positive is
Austin Schuh5551b072016-02-15 14:06:36 -080049 // the same direction as the shoulder. The angle is measured relative to
Austin Schuh009b93e2017-02-05 23:22:19 -080050 // the top of the robot frame. For calibration, 0 is measured as parallel
51 // to the big frame supporting the shooter.
Austin Schuh2fc10fa2016-02-08 00:44:34 -080052
53 // Goal angles and angular velocities of the superstructure subsystems.
54 double angle_intake;
55 double angle_shoulder;
56 // In relation to the ground plane.
57 double angle_wrist;
58
59 // Caps on velocity/acceleration for profiling. 0 for the default.
60 float max_angular_velocity_intake;
61 float max_angular_velocity_shoulder;
62 float max_angular_velocity_wrist;
63
64 float max_angular_acceleration_intake;
65 float max_angular_acceleration_shoulder;
66 float max_angular_acceleration_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +000067
68 // Voltage to send to the rollers. Positive is sucking in.
Campbell Crowleyd4fd6552016-02-21 17:53:46 -080069 float voltage_top_rollers;
70 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -070071
Comran Morshed71466fe2016-04-21 20:21:14 -070072 // Voltage to sent to the climber. Positive is pulling the robot up.
73 float voltage_climber;
74 // If true, unlatch the climber and allow it to unfold.
75 bool unfold_climber;
76
Austin Schuh1defd262016-04-03 16:13:32 -070077 bool force_intake;
78
Austin Schuh843412b2016-03-20 16:48:46 -070079 // If true, release the latch which holds the traverse mechanism in the
80 // middle.
81 bool traverse_unlatched;
82 // If true, fire the traverse mechanism down.
83 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +000084 };
85
86 message Status {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080087 // Are the superstructure subsystems zeroed?
88 bool zeroed;
89
90 // If true, we have aborted.
91 bool estopped;
92
93 // The internal state of the state machine.
94 int32_t state;
95
96
97 // Estimated angles and angular velocities of the superstructure subsystems.
98 JointState intake;
99 JointState shoulder;
100 JointState wrist;
Austin Schuhf59b6bc2016-03-11 21:26:19 -0800101
102 int32_t shoulder_controller_index;
Austin Schuh5b1a4cd2016-03-11 21:28:38 -0800103
104 // Is the superstructure collided?
105 bool is_collided;
Comran Morshed25f81a02016-01-23 13:40:10 +0000106 };
107
108 message Position {
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800109 // Zero for the intake potentiometer value is horizontal, and positive is
110 // up.
111 // Zero for the shoulder potentiometer value is horizontal, and positive is
112 // up.
113 // Zero for the wrist potentiometer value is parallel to the arm and with
114 // the shooter wheels pointed towards the shoulder joint. This is measured
115 // relative to the arm, not the ground, not like the world we actually
116 // present to users.
117 .frc971.PotAndIndexPosition intake;
118 .frc971.PotAndIndexPosition shoulder;
119 .frc971.PotAndIndexPosition wrist;
120 };
121
122 message Output {
Austin Schuh39fd6102016-02-13 22:59:48 -0800123 float voltage_intake;
124 float voltage_shoulder;
125 float voltage_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +0000126
Campbell Crowleyd4fd6552016-02-21 17:53:46 -0800127 float voltage_top_rollers;
128 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -0700129
Comran Morshed71466fe2016-04-21 20:21:14 -0700130 // Voltage to sent to the climber. Positive is pulling the robot up.
131 float voltage_climber;
132 // If true, release the latch to trigger the climber to unfold.
133 bool unfold_climber;
134
Austin Schuh843412b2016-03-20 16:48:46 -0700135 // If true, release the latch to hold the traverse mechanism in the middle.
136 bool traverse_unlatched;
137 // If true, fire the traverse mechanism down.
138 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +0000139 };
140
141 queue Goal goal;
142 queue Position position;
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800143 queue Output output;
Comran Morshed25f81a02016-01-23 13:40:10 +0000144 queue Status status;
145};