blob: 860854bf5d86ecaa16ba566d49039fc21e50d980 [file] [log] [blame]
Austin Schuh3bb9a442014-02-02 16:01:45 -08001package frc971.control_loops;
2
Briana6553ed2014-04-02 21:26:46 -07003import "aos/common/controls/control_loops.q";
Brian Silvermane0a95462014-02-17 00:41:09 -08004import "frc971/control_loops/control_loops.q";
Austin Schuh3bb9a442014-02-02 16:01:45 -08005
Austin Schuh4339ebb2014-02-11 00:56:44 -08006struct HalfClawPosition {
7 // The current position of this half of the claw.
Austin Schuh4b7b5d02014-02-10 21:20:34 -08008 double position;
Brian Silvermane0a95462014-02-17 00:41:09 -08009
10 // The hall effect sensor at the front limit.
11 HallEffectStruct front;
12 // The hall effect sensor in the middle to use for real calibration.
13 HallEffectStruct calibration;
14 // The hall effect at the back limit.
15 HallEffectStruct back;
Austin Schuh4b7b5d02014-02-10 21:20:34 -080016
17 // The encoder value at the last posedge of any of the claw hall effect
Austin Schuh4339ebb2014-02-11 00:56:44 -080018 // sensors (front, calibration, or back).
Austin Schuh4b7b5d02014-02-10 21:20:34 -080019 double posedge_value;
20 // The encoder value at the last negedge of any of the claw hall effect
Austin Schuh4339ebb2014-02-11 00:56:44 -080021 // sensors (front, calibration, or back).
Austin Schuh4b7b5d02014-02-10 21:20:34 -080022 double negedge_value;
23};
24
Brian Silverman0e7c03e2014-03-23 17:06:24 -070025// All angles here are 0 vertical, positive "up" (aka backwards).
Austin Schuhcc0bf312014-02-09 00:39:29 -080026queue_group ClawGroup {
Austin Schuh3bb9a442014-02-02 16:01:45 -080027 implements aos.control_loops.ControlLoop;
28
29 message Goal {
Austin Schuhcc0bf312014-02-09 00:39:29 -080030 // The angle of the bottom claw.
Austin Schuh3bb9a442014-02-02 16:01:45 -080031 double bottom_angle;
Austin Schuhcc0bf312014-02-09 00:39:29 -080032 // How much higher the top claw is.
Brian Silverman7c021c42014-02-17 15:15:56 -080033 double separation_angle;
Austin Schuh78d55462014-02-23 01:39:30 -080034 // top claw intake roller
Ben Fredrickson2f76ddf2014-02-23 05:58:23 +000035 double intake;
Austin Schuh78d55462014-02-23 01:39:30 -080036 // bottom claw tusk centering
37 double centering;
Austin Schuh3bb9a442014-02-02 16:01:45 -080038 };
Austin Schuh4b7b5d02014-02-10 21:20:34 -080039
Austin Schuh3bb9a442014-02-02 16:01:45 -080040 message Position {
Austin Schuh4339ebb2014-02-11 00:56:44 -080041 // All the top claw information.
42 HalfClawPosition top;
43 // All the bottom claw information.
44 HalfClawPosition bottom;
Austin Schuh3bb9a442014-02-02 16:01:45 -080045 };
46
47 message Output {
48 double intake_voltage;
49 double top_claw_voltage;
50 double bottom_claw_voltage;
Austin Schuhd36c3692014-02-18 21:00:57 -080051 double tusk_voltage;
Austin Schuh3bb9a442014-02-02 16:01:45 -080052 };
53
James Kuszmaul4abaf482014-02-26 21:16:35 -080054 message Status {
Brian Silverman80fc94c2014-03-09 16:56:01 -070055 // True if zeroed enough for the current period (autonomous or teleop).
Austin Schuh4f8633f2014-03-02 13:59:46 -080056 bool zeroed;
Brian Silverman80fc94c2014-03-09 16:56:01 -070057 // True if zeroed as much as we will force during autonomous.
58 bool zeroed_for_auto;
James Kuszmaul4abaf482014-02-26 21:16:35 -080059 // True if zeroed and within tolerance for separation and bottom angle.
60 bool done;
Ben Fredrickson81ba2d52014-03-02 08:21:46 +000061 // True if zeroed and within tolerance for separation and bottom angle.
Austin Schuh4f8633f2014-03-02 13:59:46 -080062 // seperation allowance much wider as a ball may be included
Ben Fredrickson81ba2d52014-03-02 08:21:46 +000063 bool done_with_ball;
James Kuszmaul4abaf482014-02-26 21:16:35 -080064 // Dump the values of the state matrix.
65 double bottom;
66 double bottom_velocity;
67 double separation;
68 double separation_velocity;
69 };
70
Austin Schuh3bb9a442014-02-02 16:01:45 -080071 queue Goal goal;
72 queue Position position;
73 queue Output output;
James Kuszmaul9ead1de2014-02-28 21:24:39 -080074 queue Status status;
Austin Schuh3bb9a442014-02-02 16:01:45 -080075};
76
Austin Schuhcc0bf312014-02-09 00:39:29 -080077queue_group ClawGroup claw_queue_group;
Brian Silvermanf48fab32014-03-09 14:32:24 -070078
79struct ClawPositionToLog {
80 double top;
81 double bottom;
82};