Added forwards and backwards flash lights.
Change-Id: I813aeb1f300115e323d32823fbbca7d01a834d00
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index 0936eea..629b980 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -84,7 +84,17 @@
// Turn the lights on if we are supposed to spin.
if (output) {
- if (::std::abs(goal->angular_velocity) > 0.0 || goal->force_lights_on) {
+ if (::std::abs(goal->angular_velocity) > 0.0) {
+ output->lights_on = true;
+ if (goal->shooting_forwards) {
+ output->forwards_flashlight = true;
+ output->backwards_flashlight = false;
+ } else {
+ output->forwards_flashlight = false;
+ output->backwards_flashlight = true;
+ }
+ }
+ if (goal->force_lights_on) {
output->lights_on = true;
}
}
diff --git a/y2016/control_loops/shooter/shooter.q b/y2016/control_loops/shooter/shooter.q
index b799b5a..0e00a02 100644
--- a/y2016/control_loops/shooter/shooter.q
+++ b/y2016/control_loops/shooter/shooter.q
@@ -31,6 +31,9 @@
// Forces the lights on.
bool force_lights_on;
+
+ // If true, the robot is shooting forwards.
+ bool shooting_forwards;
};
message Position {
@@ -65,6 +68,9 @@
// If true, the lights are on.
bool lights_on;
+
+ bool forwards_flashlight;
+ bool backwards_flashlight;
};
queue Goal goal;
diff --git a/y2016/joystick_reader.cc b/y2016/joystick_reader.cc
index 0023ac8..6706485 100644
--- a/y2016/joystick_reader.cc
+++ b/y2016/joystick_reader.cc
@@ -380,6 +380,7 @@
.clamp_open(is_intaking_ || is_outtaking_)
.push_to_shooter(fire_)
.force_lights_on(force_lights_on)
+ .shooting_forwards(wrist_goal_ > 0)
.Send()) {
LOG(ERROR, "Sending shooter goal failed.\n");
}
diff --git a/y2016/wpilib/wpilib_interface.cc b/y2016/wpilib/wpilib_interface.cc
index d169b42..b3ed0a8 100644
--- a/y2016/wpilib/wpilib_interface.cc
+++ b/y2016/wpilib/wpilib_interface.cc
@@ -499,7 +499,19 @@
shooter_clamp_->Set(shooter_->clamp_open);
shooter_pusher_->Set(shooter_->push_to_shooter);
lights_->Set(shooter_->lights_on);
- flashlight_->Set(shooter_->lights_on ? Relay::kForward : Relay::kOff);
+ if (shooter_->forwards_flashlight) {
+ if (shooter_->backwards_flashlight) {
+ flashlight_->Set(Relay::kOn);
+ } else {
+ flashlight_->Set(Relay::kReverse);
+ }
+ } else {
+ if (shooter_->backwards_flashlight) {
+ flashlight_->Set(Relay::kForward);
+ } else {
+ flashlight_->Set(Relay::kOff);
+ }
+ }
}
}