Convert all year's robots to proper event loops
Each robot has a couple of event loops, one per thread. Each of these
threads corresponds to the threads from before the change. y2016 has
been tested on real hardware.
Change-Id: I99f726a8bc0498204c1a3b99f15508119eed9ad3
diff --git a/frc971/wpilib/ADIS16448.h b/frc971/wpilib/ADIS16448.h
index 5af6a4f..6aeac9d 100644
--- a/frc971/wpilib/ADIS16448.h
+++ b/frc971/wpilib/ADIS16448.h
@@ -43,25 +43,21 @@
// Sets the reset line for the IMU to use for error recovery.
void set_reset(frc::DigitalOutput *output) { reset_ = output; }
- // For ::std::thread to call.
- //
- // Initializes the sensor and then loops until Quit() is called taking
- // readings.
- void operator()();
-
// Sets a function to be called immediately after each time this class uses
// the SPI bus. This is a good place to do other things on the bus.
void set_spi_idle_callback(std::function<void()> spi_idle_callback) {
spi_idle_callback_ = std::move(spi_idle_callback);
}
- void Quit() { run_ = false; }
-
double gyro_x_zeroed_offset() const { return gyro_x_zeroed_offset_; }
double gyro_y_zeroed_offset() const { return gyro_y_zeroed_offset_; }
double gyro_z_zeroed_offset() const { return gyro_z_zeroed_offset_; }
private:
+ // Initializes the sensor and then loops until Quit() is called taking
+ // readings.
+ void DoRun();
+
// Try to initialize repeatedly as long as we're supposed to be running.
void InitializeUntilSuccessful();
@@ -104,7 +100,6 @@
frc::DigitalOutput *reset_ = nullptr;
std::function<void()> spi_idle_callback_ = []() {};
- ::std::atomic<bool> run_{true};
// The averaged values of the gyro over 6 seconds after power up.
bool gyros_are_zeroed_ = false;