mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[examples] Fix arcade inversions (#3841)
Accounts for differences between ArcadeDrive and the methods used in some other examples.
This commit is contained in:
@@ -27,7 +27,7 @@ class Robot : public frc::TimedRobot {
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Drive with arcade style
|
||||
m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());
|
||||
m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Robot : public frc::TimedRobot {
|
||||
// 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_driverController.GetRightX());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Robot : public frc::TimedRobot {
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Drive with arcade style (use right stick)
|
||||
m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());
|
||||
m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
|
||||
}
|
||||
|
||||
void TestInit() override {}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Robot : public frc::TimedRobot {
|
||||
double turningValue = (kAngleSetpoint - m_gyro.GetAngle()) * kP;
|
||||
// Invert the direction of the turn if we are going backwards
|
||||
turningValue = std::copysign(turningValue, m_joystick.GetY());
|
||||
m_robotDrive.ArcadeDrive(m_joystick.GetY(), turningValue);
|
||||
m_robotDrive.ArcadeDrive(-m_joystick.GetY(), turningValue);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,7 +19,7 @@ RobotContainer::RobotContainer() {
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(m_driverController.GetLeftY(),
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
|
||||
@@ -23,7 +23,7 @@ RobotContainer::RobotContainer() {
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(m_driverController.GetLeftY(),
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
|
||||
@@ -28,7 +28,7 @@ RobotContainer::RobotContainer() {
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(DefaultDrive(
|
||||
&m_drive, [this] { return -m_driverController.GetLeftY(); },
|
||||
[this] { return -m_driverController.GetRightX(); }));
|
||||
[this] { return m_driverController.GetRightX(); }));
|
||||
}
|
||||
|
||||
void RobotContainer::ConfigureButtonBindings() {
|
||||
|
||||
@@ -29,7 +29,7 @@ RobotContainer::RobotContainer() {
|
||||
m_drive.SetDefaultCommand(frc2::RunCommand(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
m_driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,6 @@ public class Robot extends TimedRobot {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class RobotContainer {
|
||||
// Setpoint is 0
|
||||
0,
|
||||
// Pipe the output to the turning controls
|
||||
output -> m_robotDrive.arcadeDrive(m_driverController.getLeftY(), output),
|
||||
output -> m_robotDrive.arcadeDrive(-m_driverController.getLeftY(), output),
|
||||
// Require the robot drive
|
||||
m_robotDrive));
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
|
||||
// Add commands to the autonomous command chooser
|
||||
|
||||
@@ -53,7 +53,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RobotContainer {
|
||||
new RunCommand(
|
||||
() ->
|
||||
m_robotDrive.arcadeDrive(
|
||||
-m_driverController.getLeftY(), -m_driverController.getRightX()),
|
||||
-m_driverController.getLeftY(), m_driverController.getRightX()),
|
||||
m_robotDrive));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user