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