mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[artf3717] Added isEnabled to Teleop Loops in Samples.
Anywhere in the sample programs where there was just a isOperatorControl() in the while loop for Teleop, added an "&& isEnabled()". Change-Id: Ib81e8bab79923e262c314a073a591855cbf06846
This commit is contained in:
@@ -28,7 +28,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
||||||
Wait(0.005); // wait for a motor update time
|
Wait(0.005); // wait for a motor update time
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
// Get the current going through channel 7, in Amperes.
|
// Get the current going through channel 7, in Amperes.
|
||||||
// The PDP returns the current in increments of 0.125A.
|
// The PDP returns the current in increments of 0.125A.
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
// Retrieve the net displacement of the Encoder since the lsat Reset.
|
// Retrieve the net displacement of the Encoder since the lsat Reset.
|
||||||
SmartDashboard::PutNumber("Encoder Distance", m_encoder.GetDistance());
|
SmartDashboard::PutNumber("Encoder Distance", m_encoder.GetDistance());
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
robotDrive.SetSafetyEnabled(false);
|
robotDrive.SetSafetyEnabled(false);
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
|
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
|
||||||
// This sample does not use field-oriented drive, so the gyro input is set to zero.
|
// This sample does not use field-oriented drive, so the gyro input is set to zero.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
* Runs the motor from the output of a Joystick.
|
* Runs the motor from the output of a Joystick.
|
||||||
*/
|
*/
|
||||||
void OperatorControl() {
|
void OperatorControl() {
|
||||||
while (IsOperatorControl()) {
|
while (IsOperatorControl() && IsEnabled()) {
|
||||||
// Set the motor controller's output.
|
// Set the motor controller's output.
|
||||||
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed forwards).
|
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed forwards).
|
||||||
m_motor.Set(m_stick.GetY());
|
m_motor.Set(m_stick.GetY());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
* Simultaneously displays encoder values on the SmartDashboard.
|
* Simultaneously displays encoder values on the SmartDashboard.
|
||||||
*/
|
*/
|
||||||
void OperatorControl() {
|
void OperatorControl() {
|
||||||
while (IsOperatorControl()) {
|
while (IsOperatorControl() && IsEnabled()) {
|
||||||
// Set the motor controller's output.
|
// Set the motor controller's output.
|
||||||
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed forwards).
|
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed forwards).
|
||||||
m_motor.Set(m_stick.GetY());
|
m_motor.Set(m_stick.GetY());
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
// Retrieve the button values. GetRawButton will return
|
// Retrieve the button values. GetRawButton will return
|
||||||
// true if the button is pressed and false if not.
|
// true if the button is pressed and false if not.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
// The output of GetRawButton is true/false depending on whether
|
// The output of GetRawButton is true/false depending on whether
|
||||||
// the button is pressed; Set takes a boolean for for whether to
|
// the button is pressed; Set takes a boolean for for whether to
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
void OperatorControl()
|
void OperatorControl()
|
||||||
{
|
{
|
||||||
myRobot.SetSafetyEnabled(true);
|
myRobot.SetSafetyEnabled(true);
|
||||||
while (IsOperatorControl())
|
while (IsOperatorControl() && IsEnabled())
|
||||||
{
|
{
|
||||||
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
||||||
Wait(0.005); // wait for a motor update time
|
Wait(0.005); // wait for a motor update time
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class Robot extends SampleRobot {
|
|||||||
*/
|
*/
|
||||||
public void operatorControl() {
|
public void operatorControl() {
|
||||||
robotDrive.setSafetyEnabled(true);
|
robotDrive.setSafetyEnabled(true);
|
||||||
while (isOperatorControl()) {
|
while (isOperatorControl() && isEnabled()) {
|
||||||
|
|
||||||
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
|
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
|
||||||
// This sample does not use field-oriented drive, so the gyro input is set to zero.
|
// This sample does not use field-oriented drive, so the gyro input is set to zero.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class Robot extends SampleRobot {
|
|||||||
* Runs the motor from a joystick.
|
* Runs the motor from a joystick.
|
||||||
*/
|
*/
|
||||||
public void operatorControl() {
|
public void operatorControl() {
|
||||||
while (isOperatorControl()) {
|
while (isOperatorControl() && isEnabled()) {
|
||||||
// Set the motor's output.
|
// Set the motor's output.
|
||||||
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed going forward)
|
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed going forward)
|
||||||
motor.set(stick.getY());
|
motor.set(stick.getY());
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class Robot extends SampleRobot {
|
|||||||
*/
|
*/
|
||||||
public void operatorControl() {
|
public void operatorControl() {
|
||||||
myRobot.setSafetyEnabled(true);
|
myRobot.setSafetyEnabled(true);
|
||||||
while (isOperatorControl()) {
|
while (isOperatorControl() && isEnabled()) {
|
||||||
myRobot.tankDrive(leftStick, rightStick);
|
myRobot.tankDrive(leftStick, rightStick);
|
||||||
Timer.delay(0.005); // wait for a motor update time
|
Timer.delay(0.005); // wait for a motor update time
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class Robot extends SampleRobot {
|
|||||||
*/
|
*/
|
||||||
public void operatorControl() {
|
public void operatorControl() {
|
||||||
myRobot.setSafetyEnabled(true);
|
myRobot.setSafetyEnabled(true);
|
||||||
while (isOperatorControl()) {
|
while (isOperatorControl() && isEnabled()) {
|
||||||
myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
|
myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
|
||||||
Timer.delay(0.005); // wait for a motor update time
|
Timer.delay(0.005); // wait for a motor update time
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user