/** * Check if the DS is attached * @return True if the DS is connected to the robot */ bool DriverStation::IsDSAttached() { HALControlWord controlWord; memset(&controlWord, 0, sizeof(controlWord)); HALGetControlWord(&controlWord); return controlWord.dsAttached; }
/** * Check if the DS is commanding teleop mode * @return True if the robot is being commanded to be in teleop mode */ bool DriverStation::IsOperatorControl() { HALControlWord controlWord; memset(&controlWord, 0, sizeof(controlWord)); HALGetControlWord(&controlWord); return !(controlWord.autonomous || controlWord.test); }
/** * Check if the DS is commanding autonomous mode * @return True if the robot is being commanded to be in autonomous mode */ bool DriverStation::IsAutonomous() { HALControlWord controlWord; memset(&controlWord, 0, sizeof(controlWord)); HALGetControlWord(&controlWord); return controlWord.autonomous; }
/** * Check if the robot is disabled * @return True if the robot is explicitly disabled or the DS is not connected */ bool DriverStation::IsDisabled() { HALControlWord controlWord; memset(&controlWord, 0, sizeof(controlWord)); HALGetControlWord(&controlWord); return !(controlWord.enabled && controlWord.dsAttached); }
/** * Report an error to the DriverStation messages window. * The error is also printed to the program console. */ void DriverStation::ReportError(std::string error) { std::cout << error << std::endl; HALControlWord controlWord; HALGetControlWord(&controlWord); if (controlWord.dsAttached) { HALSetErrorData(error.c_str(), error.size(), 0); } }
/** * Is the driver station attached to a Field Management System? * @return True if the robot is competing on a field being controlled by a Field Management System */ bool DriverStation::IsFMSAttached() { HALControlWord controlWord; HALGetControlWord(&controlWord); return controlWord.fmsAttached; }
/** * Check if the DS is commanding test mode * @return True if the robot is being commanded to be in test mode */ bool DriverStation::IsTest() { HALControlWord controlWord; HALGetControlWord(&controlWord); return controlWord.test; }