Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 1 | #include "frc971/wpilib/wpilib_interface.h" |
| 2 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 3 | #include "aos/robot_state/robot_state.q.h" |
| 4 | #include "aos/logging/queue_logging.h" |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 5 | |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame^] | 6 | #include "hal/HAL.h" |
Brian Silverman | e48dbc1 | 2017-02-04 20:06:29 -0800 | [diff] [blame] | 7 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 8 | namespace frc971 { |
| 9 | namespace wpilib { |
| 10 | |
Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame] | 11 | void SendRobotState(int32_t my_pid) { |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 12 | auto new_state = ::aos::robot_state.MakeMessage(); |
| 13 | |
Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame] | 14 | int32_t status = 0; |
| 15 | |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 16 | new_state->reader_pid = my_pid; |
Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame] | 17 | new_state->outputs_enabled = HAL_GetSystemActive(&status); |
| 18 | new_state->browned_out = HAL_GetBrownedOut(&status); |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 19 | |
Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame] | 20 | new_state->is_3v3_active = HAL_GetUserActive3V3(&status); |
| 21 | new_state->is_5v_active = HAL_GetUserActive5V(&status); |
| 22 | new_state->voltage_3v3 = HAL_GetUserVoltage3V3(&status); |
| 23 | new_state->voltage_5v = HAL_GetUserVoltage5V(&status); |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 24 | |
Austin Schuh | 94f51e9 | 2017-10-30 19:25:32 -0700 | [diff] [blame] | 25 | new_state->voltage_roborio_in = HAL_GetVinVoltage(&status); |
| 26 | new_state->voltage_battery = HAL_GetVinVoltage(&status); |
Brian Silverman | 811f8ec | 2015-12-06 01:29:42 -0500 | [diff] [blame] | 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 |