blob: 851d8095570524f6c68f23f097f6d261c33cc2c0 [file] [log] [blame]
Brian Silverman811f8ec2015-12-06 01:29:42 -05001#include "frc971/wpilib/wpilib_interface.h"
2
John Park33858a32018-09-28 23:05:48 -07003#include "aos/robot_state/robot_state.q.h"
Brian Silverman811f8ec2015-12-06 01:29:42 -05004
Austin Schuhf6b94632019-02-02 22:11:27 -08005#include "hal/HAL.h"
Brian Silvermane48dbc12017-02-04 20:06:29 -08006
Brian Silverman811f8ec2015-12-06 01:29:42 -05007namespace frc971 {
8namespace wpilib {
9
Austin Schuhdf6cbb12019-02-02 13:46:52 -080010void PopulateRobotState(::aos::RobotState *robot_state, int32_t my_pid) {
Austin Schuh94f51e92017-10-30 19:25:32 -070011 int32_t status = 0;
12
Austin Schuhdf6cbb12019-02-02 13:46:52 -080013 robot_state->reader_pid = my_pid;
14 robot_state->outputs_enabled = HAL_GetSystemActive(&status);
15 robot_state->browned_out = HAL_GetBrownedOut(&status);
Brian Silverman811f8ec2015-12-06 01:29:42 -050016
Austin Schuhdf6cbb12019-02-02 13:46:52 -080017 robot_state->is_3v3_active = HAL_GetUserActive3V3(&status);
18 robot_state->is_5v_active = HAL_GetUserActive5V(&status);
19 robot_state->voltage_3v3 = HAL_GetUserVoltage3V3(&status);
20 robot_state->voltage_5v = HAL_GetUserVoltage5V(&status);
Brian Silverman811f8ec2015-12-06 01:29:42 -050021
Austin Schuhdf6cbb12019-02-02 13:46:52 -080022 robot_state->voltage_roborio_in = HAL_GetVinVoltage(&status);
23 robot_state->voltage_battery = HAL_GetVinVoltage(&status);
Brian Silverman811f8ec2015-12-06 01:29:42 -050024
Austin Schuhdf6cbb12019-02-02 13:46:52 -080025 if (status != 0) {
26 LOG(FATAL, "Failed to get robot state: %d\n", status);
27 }
Brian Silverman811f8ec2015-12-06 01:29:42 -050028}
29
30} // namespace wpilib
31} // namespace frc971