mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] Update all examples to use NWU coordinate conventions (#4725)
This commit is contained in:
@@ -32,6 +32,6 @@ public class Robot extends TimedRobot {
|
||||
// Drive with arcade drive.
|
||||
// That means that the Y axis drives forward
|
||||
// and backward, and the X turns left and right.
|
||||
m_robotDrive.arcadeDrive(-m_stick.getY(), m_stick.getX());
|
||||
m_robotDrive.arcadeDrive(-m_stick.getY(), -m_stick.getX());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ public class Robot extends TimedRobot {
|
||||
// Drive with split arcade drive.
|
||||
// That means that the Y axis of the left stick moves forward
|
||||
// and backward, and the X of the right stick turns left and right.
|
||||
m_robotDrive.arcadeDrive(-m_driverController.getLeftY(), m_driverController.getRightX());
|
||||
m_robotDrive.arcadeDrive(-m_driverController.getLeftY(), -m_driverController.getRightX());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class RobotContainer {
|
||||
Commands.run(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RobotContainer {
|
||||
// A split-stick arcade command, with forward/backward controlled by the left
|
||||
// hand, and turning controlled by the right.
|
||||
m_robotDrive.arcadeDriveCommand(
|
||||
() -> -m_driverController.getLeftY(), () -> m_driverController.getRightX()));
|
||||
() -> -m_driverController.getLeftY(), () -> -m_driverController.getRightX()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RobotContainer {
|
||||
Commands.run(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RobotContainer {
|
||||
Commands.run(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RobotContainer {
|
||||
|
||||
// Assign default commands
|
||||
m_drivetrain.setDefaultCommand(
|
||||
new TankDrive(m_joystick::getLeftY, m_joystick::getRightY, m_drivetrain));
|
||||
new TankDrive(() -> -m_joystick.getLeftY(), () -> -m_joystick.getRightY(), m_drivetrain));
|
||||
|
||||
// Show what command your subsystem is running on the SmartDashboard
|
||||
SmartDashboard.putData(m_drivetrain);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Robot extends TimedRobot {
|
||||
/** This function is called periodically during teleoperated mode. */
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_robotDrive.arcadeDrive(-m_controller.getLeftY(), m_controller.getRightX());
|
||||
m_robotDrive.arcadeDrive(-m_controller.getLeftY(), -m_controller.getRightX());
|
||||
}
|
||||
|
||||
/** This function is called once each time the robot enters test mode. */
|
||||
|
||||
@@ -50,8 +50,6 @@ public class Robot extends TimedRobot {
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
double turningValue = (kAngleSetpoint - m_gyro.getAngle()) * kP;
|
||||
// Invert the direction of the turn if we are going backwards
|
||||
turningValue = Math.copySign(turningValue, m_joystick.getY());
|
||||
m_myRobot.arcadeDrive(-m_joystick.getY(), turningValue);
|
||||
m_myRobot.arcadeDrive(-m_joystick.getY(), -turningValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,6 @@ public class Robot extends TimedRobot {
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_robotDrive.driveCartesian(
|
||||
-m_joystick.getY(), m_joystick.getX(), m_joystick.getZ(), m_gyro.getRotation2d());
|
||||
-m_joystick.getY(), -m_joystick.getX(), -m_joystick.getZ(), m_gyro.getRotation2d());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RobotContainer {
|
||||
Commands.run(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
|
||||
// Add commands to the autonomous command chooser
|
||||
|
||||
@@ -60,7 +60,9 @@ public class RobotContainer {
|
||||
// A split-stick arcade command, with forward/backward controlled by the left
|
||||
// hand, and turning controlled by the right.
|
||||
new DefaultDrive(
|
||||
m_robotDrive, m_driverController::getLeftY, m_driverController::getRightX));
|
||||
m_robotDrive,
|
||||
() -> -m_driverController.getLeftY(),
|
||||
() -> -m_driverController.getRightX()));
|
||||
|
||||
// Add commands to the autonomous command chooser
|
||||
m_chooser.setDefaultOption("Simple Auto", m_simpleAuto);
|
||||
|
||||
@@ -51,9 +51,9 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.drive(
|
||||
m_driverController.getLeftY(),
|
||||
m_driverController.getRightX(),
|
||||
m_driverController.getLeftX(),
|
||||
-m_driverController.getLeftY(),
|
||||
-m_driverController.getRightX(),
|
||||
-m_driverController.getLeftX(),
|
||||
false),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ public class Robot extends TimedRobot {
|
||||
public void teleopPeriodic() {
|
||||
// Use the joystick X axis for forward movement, Y axis for lateral
|
||||
// movement, and Z axis for rotation.
|
||||
m_robotDrive.driveCartesian(-m_stick.getY(), m_stick.getX(), m_stick.getZ());
|
||||
m_robotDrive.driveCartesian(-m_stick.getY(), -m_stick.getX(), -m_stick.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ public class RapidReactCommandBot {
|
||||
|
||||
// Control the drive with split-stick arcade controls
|
||||
m_drive.setDefaultCommand(
|
||||
m_drive.arcadeDriveCommand(m_driverController::getLeftY, m_driverController::getRightX));
|
||||
m_drive.arcadeDriveCommand(
|
||||
() -> -m_driverController.getLeftY(), () -> -m_driverController.getRightX()));
|
||||
|
||||
// Deploy the intake with the X button
|
||||
m_driverController.x().onTrue(m_intake.intakeCommand());
|
||||
|
||||
@@ -92,6 +92,6 @@ public class RobotContainer {
|
||||
*/
|
||||
public Command getArcadeDriveCommand() {
|
||||
return new ArcadeDrive(
|
||||
m_drivetrain, () -> -m_controller.getRawAxis(1), () -> m_controller.getRawAxis(2));
|
||||
m_drivetrain, () -> -m_controller.getRawAxis(1), () -> -m_controller.getRawAxis(2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,6 @@ public class Robot extends TimedRobot {
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_myRobot.tankDrive(m_leftStick.getY(), m_rightStick.getY());
|
||||
m_myRobot.tankDrive(-m_leftStick.getY(), -m_rightStick.getY());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user