blob: 016f52f5ec87db320b57ea6f464d281c3196d365 [file] [log] [blame]
Brian Silverman811f8ec2015-12-06 01:29:42 -05001#include "frc971/wpilib/wpilib_interface.h"
2
Brian Silverman811f8ec2015-12-06 01:29:42 -05003#include "aos/common/messages/robot_state.q.h"
4#include "aos/common/logging/queue_logging.h"
5
Brian Silvermancee260a2015-12-24 16:27:51 -08006#include "DriverStation.h"
7#include "ControllerPower.h"
8#undef ERROR
9
Brian Silverman811f8ec2015-12-06 01:29:42 -050010namespace frc971 {
11namespace wpilib {
12
Brian Silverman39b339e2016-01-03 13:24:22 -080013void SendRobotState(int32_t my_pid, DriverStation *ds) {
Brian Silverman811f8ec2015-12-06 01:29:42 -050014 auto new_state = ::aos::robot_state.MakeMessage();
15
16 new_state->reader_pid = my_pid;
17 new_state->outputs_enabled = ds->IsSysActive();
18 new_state->browned_out = ds->IsSysBrownedOut();
19
20 new_state->is_3v3_active = ControllerPower::GetEnabled3V3();
21 new_state->is_5v_active = ControllerPower::GetEnabled5V();
22 new_state->voltage_3v3 = ControllerPower::GetVoltage3V3();
23 new_state->voltage_5v = ControllerPower::GetVoltage5V();
24
25 new_state->voltage_roborio_in = ControllerPower::GetInputVoltage();
26 new_state->voltage_battery = ds->GetBatteryVoltage();
27
Brian Silverman811f8ec2015-12-06 01:29:42 -050028 LOG_STRUCT(DEBUG, "robot_state", *new_state);
29
30 new_state.Send();
31}
32
33} // namespace wpilib
34} // namespace frc971