blob: 5df3c9c41add2a09aaee52b0e0d4e6e4540b8290 [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 Silverman425492b2015-12-30 15:23:55 -08006#include "frc971/wpilib/pdp_fetcher.h"
7
Brian Silvermancee260a2015-12-24 16:27:51 -08008#include "DriverStation.h"
9#include "ControllerPower.h"
10#undef ERROR
11
Brian Silverman811f8ec2015-12-06 01:29:42 -050012namespace frc971 {
13namespace wpilib {
14
Brian Silvermanc7e8fdd2015-12-06 02:48:27 -050015void SendRobotState(int32_t my_pid, DriverStation *ds,
Brian Silverman425492b2015-12-30 15:23:55 -080016 PDPFetcher *pdp_fetcher) {
Brian Silverman811f8ec2015-12-06 01:29:42 -050017 auto new_state = ::aos::robot_state.MakeMessage();
18
19 new_state->reader_pid = my_pid;
20 new_state->outputs_enabled = ds->IsSysActive();
21 new_state->browned_out = ds->IsSysBrownedOut();
22
23 new_state->is_3v3_active = ControllerPower::GetEnabled3V3();
24 new_state->is_5v_active = ControllerPower::GetEnabled5V();
25 new_state->voltage_3v3 = ControllerPower::GetVoltage3V3();
26 new_state->voltage_5v = ControllerPower::GetVoltage5V();
27
28 new_state->voltage_roborio_in = ControllerPower::GetInputVoltage();
29 new_state->voltage_battery = ds->GetBatteryVoltage();
30
Brian Silverman425492b2015-12-30 15:23:55 -080031 pdp_fetcher->GetValues(&new_state->pdp);
Brian Silvermanc7e8fdd2015-12-06 02:48:27 -050032
Brian Silverman811f8ec2015-12-06 01:29:42 -050033 LOG_STRUCT(DEBUG, "robot_state", *new_state);
34
35 new_state.Send();
36}
37
38} // namespace wpilib
39} // namespace frc971