blob: 76c9850ecc82724f876225f08c7123ac09e58942 [file] [log] [blame]
Comran Morshed25f81a02016-01-23 13:40:10 +00001package y2016.control_loops;
2
3import "aos/common/controls/control_loops.q";
4import "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
Comran Morshed25f81a02016-01-23 13:40:10 +000035queue_group SuperstructureQueue {
36 implements aos.control_loops.ControlLoop;
37
38 message Goal {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080039 // Zero on the intake is when the horizontal tube stock members are level
Austin Schuh009b93e2017-02-05 23:22:19 -080040 // with the top frame rails of the robot. This will be essentially when we
41 // are in the intaking position. Positive is up. The angle is measured
42 // relative to the top
Austin Schuh2fc10fa2016-02-08 00:44:34 -080043 // of the robot frame.
Austin Schuh009b93e2017-02-05 23:22:19 -080044 // Zero on the shoulder is when the shoulder is down against the hard stop
45 // blocks. Positive is up. The angle is measured relative to the top of
46 // the robot frame.
Austin Schuh2fc10fa2016-02-08 00:44:34 -080047 // Zero on the wrist is horizontal and landed in the bellypan. Positive is
Austin Schuh5551b072016-02-15 14:06:36 -080048 // the same direction as the shoulder. The angle is measured relative to
Austin Schuh009b93e2017-02-05 23:22:19 -080049 // the top of the robot frame. For calibration, 0 is measured as parallel
50 // to the big frame supporting the shooter.
Austin Schuh2fc10fa2016-02-08 00:44:34 -080051
52 // Goal angles and angular velocities of the superstructure subsystems.
53 double angle_intake;
54 double angle_shoulder;
55 // In relation to the ground plane.
56 double angle_wrist;
57
58 // Caps on velocity/acceleration for profiling. 0 for the default.
59 float max_angular_velocity_intake;
60 float max_angular_velocity_shoulder;
61 float max_angular_velocity_wrist;
62
63 float max_angular_acceleration_intake;
64 float max_angular_acceleration_shoulder;
65 float max_angular_acceleration_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +000066
67 // Voltage to send to the rollers. Positive is sucking in.
Campbell Crowleyd4fd6552016-02-21 17:53:46 -080068 float voltage_top_rollers;
69 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -070070
Comran Morshed71466fe2016-04-21 20:21:14 -070071 // Voltage to sent to the climber. Positive is pulling the robot up.
72 float voltage_climber;
73 // If true, unlatch the climber and allow it to unfold.
74 bool unfold_climber;
75
Austin Schuh1defd262016-04-03 16:13:32 -070076 bool force_intake;
77
Austin Schuh843412b2016-03-20 16:48:46 -070078 // If true, release the latch which holds the traverse mechanism in the
79 // middle.
80 bool traverse_unlatched;
81 // If true, fire the traverse mechanism down.
82 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +000083 };
84
85 message Status {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080086 // Are the superstructure subsystems zeroed?
87 bool zeroed;
88
89 // If true, we have aborted.
90 bool estopped;
91
92 // The internal state of the state machine.
93 int32_t state;
94
95
96 // Estimated angles and angular velocities of the superstructure subsystems.
97 JointState intake;
98 JointState shoulder;
99 JointState wrist;
Austin Schuhf59b6bc2016-03-11 21:26:19 -0800100
101 int32_t shoulder_controller_index;
Austin Schuh5b1a4cd2016-03-11 21:28:38 -0800102
103 // Is the superstructure collided?
104 bool is_collided;
Comran Morshed25f81a02016-01-23 13:40:10 +0000105 };
106
107 message Position {
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800108 // Zero for the intake potentiometer value is horizontal, and positive is
109 // up.
110 // Zero for the shoulder potentiometer value is horizontal, and positive is
111 // up.
112 // Zero for the wrist potentiometer value is parallel to the arm and with
113 // the shooter wheels pointed towards the shoulder joint. This is measured
114 // relative to the arm, not the ground, not like the world we actually
115 // present to users.
116 .frc971.PotAndIndexPosition intake;
117 .frc971.PotAndIndexPosition shoulder;
118 .frc971.PotAndIndexPosition wrist;
119 };
120
121 message Output {
Austin Schuh39fd6102016-02-13 22:59:48 -0800122 float voltage_intake;
123 float voltage_shoulder;
124 float voltage_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +0000125
Campbell Crowleyd4fd6552016-02-21 17:53:46 -0800126 float voltage_top_rollers;
127 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -0700128
Comran Morshed71466fe2016-04-21 20:21:14 -0700129 // Voltage to sent to the climber. Positive is pulling the robot up.
130 float voltage_climber;
131 // If true, release the latch to trigger the climber to unfold.
132 bool unfold_climber;
133
Austin Schuh843412b2016-03-20 16:48:46 -0700134 // If true, release the latch to hold the traverse mechanism in the middle.
135 bool traverse_unlatched;
136 // If true, fire the traverse mechanism down.
137 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +0000138 };
139
140 queue Goal goal;
141 queue Position position;
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800142 queue Output output;
Comran Morshed25f81a02016-01-23 13:40:10 +0000143 queue Status status;
144};
145
146queue_group SuperstructureQueue superstructure_queue;