[examples] Ensure right side motors are inverted (#3836)

Fixes #3827
Adds MotorController inversion for right side, removes inversion in
setVoltage methods.

Also fixes various XboxController negations (was inconsistent throughout examples).
This commit is contained in:
sciencewhiz
2021-12-26 19:25:26 -08:00
committed by GitHub
parent baacbc8e24
commit dceb5364f4
42 changed files with 155 additions and 52 deletions

View File

@@ -28,8 +28,8 @@ RobotContainer::RobotContainer() {
// Set up default drive command
m_drive.SetDefaultCommand(frc2::RunCommand(
[this] {
m_drive.ArcadeDrive(m_driverController.GetLeftY(),
m_driverController.GetRightX());
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
-m_driverController.GetRightX());
},
{&m_drive}));
}

View File

@@ -42,7 +42,7 @@ void DriveSubsystem::SimulationPeriodic() {
// voltages make the right side move forward.
m_drivetrainSimulator.SetInputs(units::volt_t{m_leftMotors.Get()} *
frc::RobotController::GetInputVoltage(),
units::volt_t{-m_rightMotors.Get()} *
units::volt_t{m_rightMotors.Get()} *
frc::RobotController::GetInputVoltage());
m_drivetrainSimulator.Update(20_ms);
@@ -64,7 +64,7 @@ void DriveSubsystem::ArcadeDrive(double fwd, double rot) {
void DriveSubsystem::TankDriveVolts(units::volt_t left, units::volt_t right) {
m_leftMotors.SetVoltage(left);
m_rightMotors.SetVoltage(-right);
m_rightMotors.SetVoltage(right);
m_drive.Feed();
}