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 | 425492b | 2015-12-30 15:23:55 -0800 | [diff] [blame] | 6 | #include "frc971/wpilib/pdp_fetcher.h" |
| 7 | |
Brian Silverman | cee260a | 2015-12-24 16:27:51 -0800 | [diff] [blame] | 8 | #include "DriverStation.h" |
| 9 | #include "ControllerPower.h" |
| 10 | #undef ERROR |
| 11 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 12 | namespace frc971 { |
| 13 | namespace wpilib { |
| 14 | |
Brian Silverman | c7e8fdd | 2015-12-06 02:48:27 -0500 | [diff] [blame] | 15 | void SendRobotState(int32_t my_pid, DriverStation *ds, |
Brian Silverman | 425492b | 2015-12-30 15:23:55 -0800 | [diff] [blame] | 16 | PDPFetcher *pdp_fetcher) { |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 17 | 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 Silverman | 1fa9837 | 2016-01-01 13:42:17 -0800 | [diff] [blame] | 31 | if (pdp_fetcher) { |
| 32 | pdp_fetcher->GetValues(&new_state->pdp); |
| 33 | } |
Brian Silverman | c7e8fdd | 2015-12-06 02:48:27 -0500 | [diff] [blame] | 34 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 35 | LOG_STRUCT(DEBUG, "robot_state", *new_state); |
| 36 | |
| 37 | new_state.Send(); |
| 38 | } |
| 39 | |
| 40 | } // namespace wpilib |
| 41 | } // namespace frc971 |