[wpilib] Add methods to check game and enabled state together (#2661)

This avoids users having to call both IsOperatorControl() and IsEnabled() to figure out if their robot is
enabled and in the teleop state. The expression above involves calling two methods that each have their
own lock.

These new methods should only involve locking one mutex, since only one call is made to HAL_GetControlWord().
This commit is contained in:
Prateek Machiraju
2020-08-29 16:32:19 -04:00
committed by GitHub
parent 5d1220e629
commit 526f26685d
8 changed files with 106 additions and 6 deletions

View File

@@ -154,8 +154,16 @@ bool RobotBase::IsDisabled() const { return m_ds.IsDisabled(); }
bool RobotBase::IsAutonomous() const { return m_ds.IsAutonomous(); }
bool RobotBase::IsAutonomousEnabled() const {
return m_ds.IsAutonomousEnabled();
}
bool RobotBase::IsOperatorControl() const { return m_ds.IsOperatorControl(); }
bool RobotBase::IsOperatorControlEnabled() const {
return m_ds.IsOperatorControlEnabled();
}
bool RobotBase::IsTest() const { return m_ds.IsTest(); }
bool RobotBase::IsNewDataAvailable() const { return m_ds.IsNewControlData(); }