Lights turn on when shooter is on.
Change-Id: I434dc4a3eecd2fc3b96e954831cedaba8d8ee4e4
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index 2f1ae4a..699903d 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -80,6 +80,13 @@
// Update position/goal for our two shooter sides.
left_.set_goal(goal->angular_velocity);
right_.set_goal(goal->angular_velocity);
+
+ // Turn the lights on if we are supposed to spin.
+ if (output) {
+ if (::std::abs(goal->angular_velocity) > 0.0) {
+ output->lights_on = true;
+ }
+ }
}
left_.set_position(position->theta_left);
diff --git a/y2016/control_loops/shooter/shooter.q b/y2016/control_loops/shooter/shooter.q
index 5559bbb..00149a8 100644
--- a/y2016/control_loops/shooter/shooter.q
+++ b/y2016/control_loops/shooter/shooter.q
@@ -55,6 +55,9 @@
// See comments on the identical fields in Goal for details.
bool clamp_open;
bool push_to_shooter;
+
+ // If true, the lights are on.
+ bool lights_on;
};
queue Goal goal;
diff --git a/y2016/wpilib/wpilib_interface.cc b/y2016/wpilib/wpilib_interface.cc
index 6d16323..b1c52a4 100644
--- a/y2016/wpilib/wpilib_interface.cc
+++ b/y2016/wpilib/wpilib_interface.cc
@@ -408,6 +408,11 @@
shooter_pusher_ = ::std::move(s);
}
+ void set_lights(
+ ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
+ lights_ = ::std::move(s);
+ }
+
void operator()() {
compressor_->Start();
::aos::SetCurrentThreadName("Solenoids");
@@ -439,6 +444,7 @@
LOG_STRUCT(DEBUG, "solenoids", *shooter_);
shooter_clamp_->Set(shooter_->clamp_open);
shooter_pusher_->Set(shooter_->push_to_shooter);
+ lights_->Set(shooter_->lights_on);
}
}
@@ -461,7 +467,7 @@
const ::std::unique_ptr<::frc971::wpilib::BufferedPcm> &pcm_;
::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> drivetrain_left_,
- drivetrain_right_, shooter_clamp_, shooter_pusher_;
+ drivetrain_right_, shooter_clamp_, shooter_pusher_, lights_;
::std::unique_ptr<Compressor> compressor_;
::aos::Queue<::frc971::control_loops::DrivetrainQueue::Output> drivetrain_;
@@ -673,6 +679,7 @@
solenoid_writer.set_drivetrain_right(pcm->MakeSolenoid(0));
solenoid_writer.set_shooter_clamp(pcm->MakeSolenoid(4));
solenoid_writer.set_shooter_pusher(pcm->MakeSolenoid(5));
+ solenoid_writer.set_lights(pcm->MakeSolenoid(6));
solenoid_writer.set_compressor(make_unique<Compressor>());