Move PDP measurement fetching to a separate thread
Stupid CAN messages are too slow for being inline with the normal
path...
Change-Id: I160a24eb3216fc54083df576555b5bcad062ceb8
diff --git a/frc971/wpilib/wpilib_interface.cc b/frc971/wpilib/wpilib_interface.cc
index 2129ec3..5df3c9c 100644
--- a/frc971/wpilib/wpilib_interface.cc
+++ b/frc971/wpilib/wpilib_interface.cc
@@ -3,6 +3,8 @@
#include "aos/common/messages/robot_state.q.h"
#include "aos/common/logging/queue_logging.h"
+#include "frc971/wpilib/pdp_fetcher.h"
+
#include "DriverStation.h"
#include "ControllerPower.h"
#undef ERROR
@@ -11,7 +13,7 @@
namespace wpilib {
void SendRobotState(int32_t my_pid, DriverStation *ds,
- PowerDistributionPanel *pdp) {
+ PDPFetcher *pdp_fetcher) {
auto new_state = ::aos::robot_state.MakeMessage();
new_state->reader_pid = my_pid;
@@ -26,12 +28,7 @@
new_state->voltage_roborio_in = ControllerPower::GetInputVoltage();
new_state->voltage_battery = ds->GetBatteryVoltage();
- new_state->pdp_voltage = pdp->GetVoltage();
- new_state->pdp_temperature = pdp->GetTemperature();
- new_state->pdp_power = pdp->GetTotalPower();
- for (int i = 0; i < 16; ++i) {
- new_state->pdp_currents[i] = pdp->GetCurrent(i);
- }
+ pdp_fetcher->GetValues(&new_state->pdp);
LOG_STRUCT(DEBUG, "robot_state", *new_state);