diff --git a/wpilibc/src/main/native/cpp/DriverStation.cpp b/wpilibc/src/main/native/cpp/DriverStation.cpp index a31473062c..9584b7ffbb 100644 --- a/wpilibc/src/main/native/cpp/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/DriverStation.cpp @@ -336,6 +336,12 @@ bool DriverStation::IsDisabled() const { return !(controlWord.enabled && controlWord.dsAttached); } +bool DriverStation::IsEStopped() const { + HAL_ControlWord controlWord; + HAL_GetControlWord(&controlWord); + return controlWord.eStop; +} + bool DriverStation::IsAutonomous() const { HAL_ControlWord controlWord; HAL_GetControlWord(&controlWord); diff --git a/wpilibc/src/main/native/cpp/RobotState.cpp b/wpilibc/src/main/native/cpp/RobotState.cpp index f5da5c1201..530cee34a0 100644 --- a/wpilibc/src/main/native/cpp/RobotState.cpp +++ b/wpilibc/src/main/native/cpp/RobotState.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -19,6 +19,10 @@ bool RobotState::IsEnabled() { return DriverStation::GetInstance().IsEnabled(); } +bool RobotState::IsEStopped() { + return DriverStation::GetInstance().IsEStopped(); +} + bool RobotState::IsOperatorControl() { return DriverStation::GetInstance().IsOperatorControl(); } diff --git a/wpilibc/src/main/native/include/frc/DriverStation.h b/wpilibc/src/main/native/include/frc/DriverStation.h index 9a87af8cde..8abffde766 100644 --- a/wpilibc/src/main/native/include/frc/DriverStation.h +++ b/wpilibc/src/main/native/include/frc/DriverStation.h @@ -197,6 +197,13 @@ class DriverStation : public ErrorBase { */ bool IsDisabled() const; + /** + * Check if the robot is e-stopped. + * + * @return True if the robot is e-stopped + */ + bool IsEStopped() const; + /** * Check if the DS is commanding autonomous mode. * diff --git a/wpilibc/src/main/native/include/frc/RobotState.h b/wpilibc/src/main/native/include/frc/RobotState.h index 6b916929ec..c6b6b875cd 100644 --- a/wpilibc/src/main/native/include/frc/RobotState.h +++ b/wpilibc/src/main/native/include/frc/RobotState.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -15,6 +15,7 @@ class RobotState { public: static bool IsDisabled(); static bool IsEnabled(); + static bool IsEStopped(); static bool IsOperatorControl(); static bool IsAutonomous(); static bool IsTest(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index ac78d54f2a..1bd261c819 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -625,6 +625,18 @@ public class DriverStation { return !isEnabled(); } + /** + * Gets a value indicating whether the Robot is e-stopped. + * + * @return True if the robot is e-stopped, false otherwise. + */ + public boolean isEStopped() { + synchronized (m_controlWordMutex) { + updateControlWord(false); + return m_controlWordCache.getEStop(); + } + } + /** * Gets a value indicating whether the Driver Station requires the robot to be running in * autonomous mode. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java index 0f384ee288..58004d51f0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -17,6 +17,10 @@ public final class RobotState { return DriverStation.getInstance().isEnabled(); } + public static boolean isEStopped() { + return DriverStation.getInstance().isEStopped(); + } + public static boolean isOperatorControl() { return DriverStation.getInstance().isOperatorControl(); }