make the queues for this year's robot match the hardware better
Change-Id: Icada3ff4a7fc24e1ba1fea2e60945db8ebb23948
diff --git a/frc971/control_loops/claw/claw.gyp b/frc971/control_loops/claw/claw.gyp
new file mode 100644
index 0000000..4c65994
--- /dev/null
+++ b/frc971/control_loops/claw/claw.gyp
@@ -0,0 +1,22 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'claw_queues',
+ 'type': 'static_library',
+ 'sources': ['claw.q'],
+ 'variables': {
+ 'header_path': 'frc971/control_loops/claw',
+ },
+ 'dependencies': [
+ '<(AOS)/common/controls/controls.gyp:control_loop_queues',
+ '<(DEPTH)/frc971/control_loops/control_loops.gyp:queues',
+ ],
+ 'export_dependent_settings': [
+ '<(AOS)/common/controls/controls.gyp:control_loop_queues',
+ '<(DEPTH)/frc971/control_loops/control_loops.gyp:queues',
+
+ ],
+ 'includes': ['../../../aos/build/queues.gypi'],
+ },
+ ],
+}
diff --git a/frc971/control_loops/claw/claw.q b/frc971/control_loops/claw/claw.q
index 38252d7..51659be 100644
--- a/frc971/control_loops/claw/claw.q
+++ b/frc971/control_loops/claw/claw.q
@@ -1,57 +1,39 @@
package frc971.control_loops;
import "aos/common/controls/control_loops.q";
+import "frc971/control_loops/control_loops.q";
queue_group Claw {
implements aos.control_loops.ControlLoop;
- // NOTE: Unless otherwise specified, assume that all angle measures are in
- // radians. An angle of zero means that the appendage is sticking straight out
- // horizontally, pointing towards the front of the robot. Rotating the appendage
- // up and towards the back of the robot increases the angle, moving it down
- // and towards the back decreases it. (Think unit circle.) This rule holds
- // true for both angle goals and encoder positions.
- // Also note that unless otherwise specified, potentiometer readings are
- // from 0V to 5V. As with the encoders, moving up and towards the back
- // of the robot increases this value, moving down and towards the back
- // decreases it.
- // For all output voltage parameters, assume that a positive voltage moves
- // the appendage in a direction that increases the value of the encoder, and
- // vice versa. (For an output voltage parameter for something without an
- // encoder, directions will be individually specified.)
+ // All angles are in radians with 0 sticking straight out the front. Rotating
+ // up and into the robot is positive. Positive output voltage moves in the
+ // direction of positive encoder values.
message Goal {
- // Angle of shoulder joint.
+ // Angle of wrist joint.
double angle;
// Voltage of intake rollers. Positive means sucking in, negative means
// spitting out.
double intake;
- // Should claw be in open or closed position? (true means open.)
- bool open;
+ // true to signal the rollers to close.
+ bool rollers_closed;
};
message Position {
- // Position of shoulder joint from encoder.
- double encoder_pos;
- // Reading from potentiometer.
- double pot_pos;
- // Position of encoder at last index pulse.
- double last_index;
- // Reading from potentiometer at last index pulse.
- double last_index_pot;
- // A count of how many index pulses we've seen on the shoulder encoder.
- uint32_t index_pulses;
+ PotAndIndexPair joint;
};
message Output {
// Voltage for intake motors. Positive is sucking in, negative is spitting
// out.
double intake_voltage;
- // Voltage for shoulder motors.
- double shoulder_voltage;
- // Claw in opened or closed position. (true means open.)
- bool open;
+ // Voltage for claw motor.
+ double voltage;
+
+ // true to signal the rollers to close.
+ bool rollers_closed;
};
message Status {
@@ -59,6 +41,13 @@
bool zeroed;
// Has claw zeroed and reached goal?
bool done;
+
+ // True iff there has been enough time since we actuated the rollers outward
+ // that they should be there.
+ bool rollers_open;
+ // True iff there has been enough time since we actuated the rollers closed
+ // that they should be there.
+ bool rollers_close;
};
queue Goal goal;
diff --git a/frc971/control_loops/control_loops.q b/frc971/control_loops/control_loops.q
index ffadb94..03929a2 100644
--- a/frc971/control_loops/control_loops.q
+++ b/frc971/control_loops/control_loops.q
@@ -1,23 +1,28 @@
package frc971;
-// Records edges captured on a single hall effect sensor.
-struct HallEffectStruct {
- bool current;
- int32_t posedge_count;
- int32_t negedge_count;
+// Represents all of the data for a single potentiometer and indexed encoder
+// pair.
+// The units on all of the positions are the same.
+// All encoder values are relative to where the encoder was at some arbitrary
+// point in time. All potentiometer values are relative to some arbitrary 0
+// position which varies with each robot.
+struct PotAndIndexPosition {
+ // Current position read from the encoder.
+ double encoder;
+ // Current position read from the potentiometer.
+ double pot;
+
+ // Position from the encoder latched at the last index pulse.
+ double latched_encoder;
+ // Position from the potentiometer latched at the last index pulse.
+ double latched_pot;
+
+ // How many index pulses we've seen since startup. Starts at 0.
+ uint32_t index_pulses;
};
-// Records the positions for a mechanism with edge-capturing sensors on it.
-struct HallEffectPositions {
- double current;
- double posedge;
- double negedge;
-};
-
-// Records edges captured on a single hall effect sensor.
-struct PosedgeOnlyCountedHallEffectStruct {
- bool current;
- int32_t posedge_count;
- int32_t negedge_count;
- double posedge_value;
+// A left/right pair of PotAndIndexPositions.
+struct PotAndIndexPair {
+ PotAndIndexPosition left;
+ PotAndIndexPosition right;
};
diff --git a/frc971/control_loops/fridge/fridge.gyp b/frc971/control_loops/fridge/fridge.gyp
new file mode 100644
index 0000000..093be4d
--- /dev/null
+++ b/frc971/control_loops/fridge/fridge.gyp
@@ -0,0 +1,22 @@
+{
+ 'targets': [
+ {
+ 'target_name': 'fridge_queues',
+ 'type': 'static_library',
+ 'sources': ['fridge.q'],
+ 'variables': {
+ 'header_path': 'frc971/control_loops/fridge',
+ },
+ 'dependencies': [
+ '<(AOS)/common/controls/controls.gyp:control_loop_queues',
+ '<(DEPTH)/frc971/control_loops/control_loops.gyp:queues',
+ ],
+ 'export_dependent_settings': [
+ '<(AOS)/common/controls/controls.gyp:control_loop_queues',
+ '<(DEPTH)/frc971/control_loops/control_loops.gyp:queues',
+
+ ],
+ 'includes': ['../../../aos/build/queues.gypi'],
+ },
+ ],
+}
diff --git a/frc971/control_loops/fridge/fridge.q b/frc971/control_loops/fridge/fridge.q
index 9e623b3..1abd821 100644
--- a/frc971/control_loops/fridge/fridge.q
+++ b/frc971/control_loops/fridge/fridge.q
@@ -1,77 +1,40 @@
package frc971.control_loops;
import "aos/common/controls/control_loops.q";
+import "frc971/control_loops/control_loops.q";
+
+// Represents states for all of the box-grabbing pistons.
+// true is grabbed and false is retracted for all of them.
+struct GrabberPistons {
+ bool top_front;
+ bool top_back;
+ bool bottom_front;
+ bool bottom_back;
+};
queue_group Fridge {
implements aos.control_loops.ControlLoop;
- // NOTE: Unless otherwise specified, assume that all angle measures are in
- // radians. An angle of zero means that the appendage is sticking straight out
- // horizontally, pointing towards the front of the robot. Rotating the appendage
- // up and towards the back of the robot increases the angle, moving it down
- // and towards the back decreases it. (Think unit circle.) This rule holds
- // true for both angle goals and encoder positions.
- // Also note that unless otherwise specified, potentiometer readings are
- // from 0V to 5V. As with the encoders, moving up and towards the back
- // of the robot increases this value, moving down and towards the back
- // decreases it.
- // For all output voltage parameters, assume that a positive voltage moves
- // the appendage in a direction that increases the value of the encoder, and
- // vice versa. (For an output voltage parameter for something without an
- // encoder, directions will be individually specified.)
+ // All angles are in radians with 0 sticking straight out horizontally over
+ // the intake (the front). Rotating up and into the robot (towards the back
+ // where boxes are placed) is positive. Positive output voltage moves all
+ // mechanisms in the direction with positive sensor values.
- // NOTE: Elevator heights are defined as follows: The height of the elevator
- // is the vertical distance (in meters) between the top of the frame
- // (front and back), and the arm pivot axis. A constant specifies the minimum
- // value for this distance.
+ // Elevator heights are the vertical distance (in meters) from the top of the
+ // frame (at the front and back) to the axis of the bottom pivot of the arm.
message Goal {
- // Position of the arm in radians.
+ // Angle of the arm.
double angle;
- // Height of the elevator in meters.
+ // Height of the elevator.
double height;
- // Should the grabbers be deployed?
- bool grabbers_deployed;
+ GrabberPistons grabbers;
};
message Position {
- // Position of arm from encoder.
- double arm_encoder_pos;
- // Reading from arm potentiometer.
- double arm_pot_pos;
- // Position of arm encoder at last index pulse.
- double arm_last_index;
- // Reading from arm potentiometer at last index pulse.
- double arm_last_index_pot;
- // A count of how many index pulses we've seen on the arm encoder.
- uint32_t arm_index_pulses;
-
- // Height of left side from encoder.
- double left_encoder_pos;
- // Reading from left side potentiometer. Directions work the same for this
- // as for the encoder.
- double left_pot_pos;
- // Position of left encoder at last index pulse.
- double left_last_index;
- // Reading from left potentiometer at last index pulse.
- double left_last_index_pot;
- // A count of how many index pulses we've seen on the left encoder.
- uint32_t left_index_pulses;
-
- // Height of right side from encoder. Directions are the same as
- // for the left side.
- double right_encoder_pos;
- // Reading from right side potentiometer. Directions work the same for this
- // as for the encoder.
- double right_pot_pos;
- // Position of right encoder at last index pulse.
- double right_last_index;
- // Reading from right potentiometer at last index pulse.
- double right_last_index_pot;
- // A count of how many index pulses we've seen on the right encoder.
- uint32_t right_index_pulses;
-
+ PotAndIndexPair arm;
+ PotAndIndexPair elevator;
};
message Status {
@@ -83,15 +46,12 @@
};
message Output {
- // Voltage of arm motor.
- double arm_voltage;
- // Voltage of left elevator motor.
- double left_voltage;
- // Voltage of right elevator motor.
- double right_voltage;
+ double left_arm;
+ double right_arm;
+ double left_elevator;
+ double right_elevator;
- // Are grabber pistons deployed?
- bool grabbers_deployed;
+ GrabberPistons grabbers;
};
queue Goal goal;