Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 1 | #include "frc971/wpilib/wpilib_interface.h" |
| 2 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 3 | #include "aos/common/messages/robot_state.q.h" |
| 4 | #include "aos/common/logging/queue_logging.h" |
| 5 | |
Brian Silverman | cee260a | 2015-12-24 16:27:51 -0800 | [diff] [blame] | 6 | #include "DriverStation.h" |
| 7 | #include "ControllerPower.h" |
| 8 | #undef ERROR |
| 9 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 10 | namespace frc971 { |
| 11 | namespace wpilib { |
| 12 | |
Brian Silverman | 39b339e | 2016-01-03 13:24:22 -0800 | [diff] [blame] | 13 | void SendRobotState(int32_t my_pid, DriverStation *ds) { |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 14 | 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 Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 28 | LOG_STRUCT(DEBUG, "robot_state", *new_state); |
| 29 | |
| 30 | new_state.Send(); |
| 31 | } |
| 32 | |
| 33 | } // namespace wpilib |
| 34 | } // namespace frc971 |