From ef598ee7bf5eeec629c7456a7ef45424364b1403 Mon Sep 17 00:00:00 2001 From: Abhishrek05 <90010729+Abhishrek05@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:59:22 -0700 Subject: [PATCH] Working on Rotation Orientation --- src/main/java/frc4388/robot/RobotContainer.java | 10 ++++++---- .../java/frc4388/robot/subsystems/SwerveDrive.java | 4 ++-- src/main/java/frc4388/utility/RobotGyro.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index ad3a927..261d33f 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -227,11 +227,13 @@ public class RobotContainer { * passing it to a {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}. */ private void configureButtonBindings() { - /* Driver Buttons */ + + // ? /* Driver Buttons */ + new JoystickButton(getDeadbandedDriverController(), XboxController.A_BUTTON) .onTrue(new InstantCommand(() -> m_robotSwerveDrive.resetGyroFlip(), m_robotSwerveDrive)); - /* Auto Recording */ + // ! /* Auto Recording */ // new JoystickButton(getDeadbandedDriverController(), XboxController.RIGHT_BUMPER_BUTTON) // .whileTrue(new JoystickRecorder(m_robotSwerveDrive, // () -> getDeadbandedDriverController().getLeftX(), @@ -258,7 +260,7 @@ public class RobotContainer { // true, false)) // .onFalse(new InstantCommand()); - // /* Speed */ + // ! /* Speed */ new JoystickButton(getDeadbandedDriverController(), XboxController.RIGHT_BUMPER_BUTTON) // final .onTrue(new InstantCommand(() -> m_robotSwerveDrive.shiftUp())); // .onFalse(new InstantCommand(() -> m_robotSwerveDrive.setToFast())); @@ -268,7 +270,7 @@ public class RobotContainer { - /* Operator Buttons */ + //? /* Operator Buttons */ new JoystickButton(getDeadbandedOperatorController(), XboxController.Y_BUTTON) .onTrue(new InstantCommand(() -> m_robotIntake.talonPIDIn())) diff --git a/src/main/java/frc4388/robot/subsystems/SwerveDrive.java b/src/main/java/frc4388/robot/subsystems/SwerveDrive.java index a96e593..cac8f93 100644 --- a/src/main/java/frc4388/robot/subsystems/SwerveDrive.java +++ b/src/main/java/frc4388/robot/subsystems/SwerveDrive.java @@ -95,10 +95,10 @@ public class SwerveDrive extends SubsystemBase { orientRotTarget = rightStick.getAngle().minus(new Rotation2d(0, 1)); rot = orientRotTarget.minus(gyro.getRotation2d()).getRadians(); } - + Translation2d speed = leftStick.times(leftStick.getNorm() * speedAdjust); - chassisSpeeds = ChassisSpeeds.fromFieldRelativeSpeeds(-1 * speed.getX(), -1 * speed.getY(), rot * SwerveDriveConstants.ROTATION_SPEED, gyro.getRotation2d());//.times(-1)); + chassisSpeeds = ChassisSpeeds.fromFieldRelativeSpeeds(-1 * speed.getX(), -1 * speed.getY(), -1 * rot * SwerveDriveConstants.ROTATION_SPEED, gyro.getRotation2d()).times(1); } else { // Create robot-relative speeds. chassisSpeeds = new ChassisSpeeds(-1 * leftStick.getX(), -1 * leftStick.getY(), -1 * rightStick.getX() * SwerveDriveConstants.ROTATION_SPEED); } diff --git a/src/main/java/frc4388/utility/RobotGyro.java b/src/main/java/frc4388/utility/RobotGyro.java index 4d36404..22d4c72 100644 --- a/src/main/java/frc4388/utility/RobotGyro.java +++ b/src/main/java/frc4388/utility/RobotGyro.java @@ -99,7 +99,7 @@ public class RobotGyro implements Gyro { resetZeroValues(); if (m_isGyroAPigeon) { - m_pigeon.setYaw(0); + m_pigeon.setYaw(180); } else { m_navX.reset(); }