Convert imu_values to event loops.
Change-Id: Ia31a022550ef076526e2198e1dbf60570caf6a16
diff --git a/frc971/wpilib/ADIS16448.cc b/frc971/wpilib/ADIS16448.cc
index aec4d4f..75f082d 100644
--- a/frc971/wpilib/ADIS16448.cc
+++ b/frc971/wpilib/ADIS16448.cc
@@ -123,6 +123,8 @@
: event_loop_(event_loop),
joystick_state_fetcher_(event_loop_->MakeFetcher<::aos::JoystickState>(
".aos.joystick_state")),
+ imu_values_sender_(
+ event_loop_->MakeSender<::frc971::IMUValues>(".frc971.imu_values")),
spi_(new frc::SPI(port)),
dio1_(dio1) {
// 1MHz is the maximum supported for burst reads, but we
@@ -241,7 +243,7 @@
}
}
- auto message = imu_values.MakeMessage();
+ auto message = imu_values_sender_.MakeMessage();
message->fpga_timestamp = ::aos::time::DurationInSeconds(
dio1_->ReadRisingTimestamp().time_since_epoch());
message->monotonic_timestamp_ns =
diff --git a/frc971/wpilib/ADIS16448.h b/frc971/wpilib/ADIS16448.h
index a1d6dcd..5af6a4f 100644
--- a/frc971/wpilib/ADIS16448.h
+++ b/frc971/wpilib/ADIS16448.h
@@ -14,6 +14,7 @@
#include "aos/events/event-loop.h"
#include "aos/logging/logging.h"
#include "aos/robot_state/robot_state.q.h"
+#include "frc971/wpilib/imu.q.h"
#include "frc971/wpilib/spi_rx_clearer.h"
namespace frc971 {
@@ -94,6 +95,7 @@
::aos::EventLoop *event_loop_;
::aos::Fetcher<::aos::JoystickState> joystick_state_fetcher_;
+ ::aos::Sender<::frc971::IMUValues> imu_values_sender_;
// TODO(Brian): This object has no business owning these ones.
const ::std::unique_ptr<frc::SPI> spi_;
diff --git a/frc971/wpilib/imu.q b/frc971/wpilib/imu.q
index c404126..4d9dec7 100644
--- a/frc971/wpilib/imu.q
+++ b/frc971/wpilib/imu.q
@@ -1,6 +1,7 @@
package frc971;
// Values returned from an IMU.
+// Published on ".frc971.imu_values"
message IMUValues {
// Gyro readings in radians/second.
// Positive is clockwise looking at the connector.
@@ -37,5 +38,3 @@
// CLOCK_MONOTONIC time in nanoseconds when the values were captured.
int64_t monotonic_timestamp_ns;
};
-
-queue IMUValues imu_values;