blob: 3225d2f25ff8d19697fd94244beef503152aff4c [file] [log] [blame]
Austin Schuh3bb9a442014-02-02 16:01:45 -08001package frc971.control_loops;
2
3import "aos/common/control_loop/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
Austin Schuh3bb9a442014-02-02 16:01:45 -080025// All angles here are 0 horizontal, positive up.
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 {
Austin Schuh4f8633f2014-03-02 13:59:46 -080055 // True if zeroed.
56 bool zeroed;
James Kuszmaul4abaf482014-02-26 21:16:35 -080057 // True if zeroed and within tolerance for separation and bottom angle.
58 bool done;
Ben Fredrickson81ba2d52014-03-02 08:21:46 +000059 // True if zeroed and within tolerance for separation and bottom angle.
Austin Schuh4f8633f2014-03-02 13:59:46 -080060 // seperation allowance much wider as a ball may be included
Ben Fredrickson81ba2d52014-03-02 08:21:46 +000061 bool done_with_ball;
James Kuszmaul4abaf482014-02-26 21:16:35 -080062 // Dump the values of the state matrix.
63 double bottom;
64 double bottom_velocity;
65 double separation;
66 double separation_velocity;
67 };
68
Austin Schuh3bb9a442014-02-02 16:01:45 -080069 queue Goal goal;
70 queue Position position;
71 queue Output output;
James Kuszmaul9ead1de2014-02-28 21:24:39 -080072 queue Status status;
Austin Schuh3bb9a442014-02-02 16:01:45 -080073};
74
Austin Schuhcc0bf312014-02-09 00:39:29 -080075queue_group ClawGroup claw_queue_group;
Brian Silvermanf48fab32014-03-09 14:32:24 -070076
77struct ClawPositionToLog {
78 double top;
79 double bottom;
80};
81
82struct ClawGoalToLog {
83 double bottom_pos;
84 double bottom_vel;
85 double separation;
86};