diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 5547923..d8aae06 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -62,7 +62,7 @@ public class RobotContainer { /* Default Commands */ // drives the robot with a two-axis input from the driver controller - m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.arcadeDrive(getController().getLeftY(), getController().getRightX()), m_robotDrive)); + m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.hotwireDrive(getController().getLeftY(), getController().getRightX()), m_robotDrive)); // m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.tankDrive(getController().getLeftY(), getController().getLeftY()), m_robotDrive)); } diff --git a/src/main/java/frc4388/robot/subsystems/Drive.java b/src/main/java/frc4388/robot/subsystems/Drive.java index f28b7ed..0d1bd14 100644 --- a/src/main/java/frc4388/robot/subsystems/Drive.java +++ b/src/main/java/frc4388/robot/subsystems/Drive.java @@ -31,6 +31,26 @@ public class Drive extends SubsystemBase { } + public void hotwireDrive(double xStick, double yStick) { + // deadzone constraints + double deadzone = 0.1d; + + if (xStick <= (0.5+deadzone) && xStick >= (0.5-deadzone)) {xStick = 0.5d;} + if (yStick <= (0.5+deadzone) && yStick >= (0.5-deadzone)) {yStick = 0.5d;} + + // if stick forword, drive both motors forward + double leftSpeed = -2 * (yStick - 0.5d); + double rightSpeed = -2 * (yStick - 0.5d); + + // if stick right turn right + leftSpeed -= 2 * (xStick - 0.5d); + rightSpeed += 2 * (xStick - 0.5d); + + //set the motors + m_leftMotor.set(-leftSpeed); + m_rightMotor.set(rightspeed); + } + public void tankDrive(double leftSpeed, double rightSpeed) { m_leftMotor.set(leftSpeed); m_rightMotor.set(rightSpeed);