Manual impementation of drive

This commit is contained in:
C4llSiqn
2023-05-02 15:08:05 -06:00
parent 747b4bf72f
commit 52f58b3e47
2 changed files with 21 additions and 1 deletions
@@ -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));
}
@@ -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);