blob: 842beb78702d10d2213f83a120f6ca2103b80fff [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
40 // with the ground. This will be essentially when we are in the intaking
41 // position. Positive is up. The angle is measured relative to the top
42 // of the robot frame.
43 // Zero on the shoulder is horizontal. Positive is up. The angle is
44 // measured relative to the top of the robot frame.
45 // Zero on the wrist is horizontal and landed in the bellypan. Positive is
Austin Schuh5551b072016-02-15 14:06:36 -080046 // the same direction as the shoulder. The angle is measured relative to
47 // the top of the robot frame.
Austin Schuh2fc10fa2016-02-08 00:44:34 -080048
49 // Goal angles and angular velocities of the superstructure subsystems.
50 double angle_intake;
51 double angle_shoulder;
52 // In relation to the ground plane.
53 double angle_wrist;
54
55 // Caps on velocity/acceleration for profiling. 0 for the default.
56 float max_angular_velocity_intake;
57 float max_angular_velocity_shoulder;
58 float max_angular_velocity_wrist;
59
60 float max_angular_acceleration_intake;
61 float max_angular_acceleration_shoulder;
62 float max_angular_acceleration_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +000063
64 // Voltage to send to the rollers. Positive is sucking in.
Campbell Crowleyd4fd6552016-02-21 17:53:46 -080065 float voltage_top_rollers;
66 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -070067
Comran Morshed71466fe2016-04-21 20:21:14 -070068 // Voltage to sent to the climber. Positive is pulling the robot up.
69 float voltage_climber;
70 // If true, unlatch the climber and allow it to unfold.
71 bool unfold_climber;
72
Austin Schuh1defd262016-04-03 16:13:32 -070073 bool force_intake;
74
Austin Schuh843412b2016-03-20 16:48:46 -070075 // If true, release the latch which holds the traverse mechanism in the
76 // middle.
77 bool traverse_unlatched;
78 // If true, fire the traverse mechanism down.
79 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +000080 };
81
82 message Status {
Austin Schuh2fc10fa2016-02-08 00:44:34 -080083 // Are the superstructure subsystems zeroed?
84 bool zeroed;
85
86 // If true, we have aborted.
87 bool estopped;
88
89 // The internal state of the state machine.
90 int32_t state;
91
92
93 // Estimated angles and angular velocities of the superstructure subsystems.
94 JointState intake;
95 JointState shoulder;
96 JointState wrist;
Austin Schuhf59b6bc2016-03-11 21:26:19 -080097
98 int32_t shoulder_controller_index;
Austin Schuh5b1a4cd2016-03-11 21:28:38 -080099
100 // Is the superstructure collided?
101 bool is_collided;
Comran Morshed25f81a02016-01-23 13:40:10 +0000102 };
103
104 message Position {
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800105 // Zero for the intake potentiometer value is horizontal, and positive is
106 // up.
107 // Zero for the shoulder potentiometer value is horizontal, and positive is
108 // up.
109 // Zero for the wrist potentiometer value is parallel to the arm and with
110 // the shooter wheels pointed towards the shoulder joint. This is measured
111 // relative to the arm, not the ground, not like the world we actually
112 // present to users.
113 .frc971.PotAndIndexPosition intake;
114 .frc971.PotAndIndexPosition shoulder;
115 .frc971.PotAndIndexPosition wrist;
116 };
117
118 message Output {
Austin Schuh39fd6102016-02-13 22:59:48 -0800119 float voltage_intake;
120 float voltage_shoulder;
121 float voltage_wrist;
Comran Morshedf4cd7642016-02-15 20:40:49 +0000122
Campbell Crowleyd4fd6552016-02-21 17:53:46 -0800123 float voltage_top_rollers;
124 float voltage_bottom_rollers;
Austin Schuh843412b2016-03-20 16:48:46 -0700125
Comran Morshed71466fe2016-04-21 20:21:14 -0700126 // Voltage to sent to the climber. Positive is pulling the robot up.
127 float voltage_climber;
128 // If true, release the latch to trigger the climber to unfold.
129 bool unfold_climber;
130
Austin Schuh843412b2016-03-20 16:48:46 -0700131 // If true, release the latch to hold the traverse mechanism in the middle.
132 bool traverse_unlatched;
133 // If true, fire the traverse mechanism down.
134 bool traverse_down;
Comran Morshed25f81a02016-01-23 13:40:10 +0000135 };
136
137 queue Goal goal;
138 queue Position position;
Austin Schuh2fc10fa2016-02-08 00:44:34 -0800139 queue Output output;
Comran Morshed25f81a02016-01-23 13:40:10 +0000140 queue Status status;
141};
142
143queue_group SuperstructureQueue superstructure_queue;