Drive Moment

This commit is contained in:
C4llSiqn
2023-05-04 16:20:15 -06:00
parent a26a0bf164
commit e0b6a24286
2 changed files with 12 additions and 11 deletions
@@ -62,8 +62,8 @@ public class RobotContainer {
/* Default Commands */
// drives the robot with a two-axis input from the driver controller
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));
m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.hotwireDrive(getController().getRightX(), getController().getLeftY()), m_robotDrive));
// m_robotDrive.setDefaultCommand(new RunCommand(() -> m_robotDrive.tankDrive(getController().getLeftY(), getController().getRightY()), m_robotDrive));
}
/**
@@ -34,25 +34,26 @@ public class Drive extends SubsystemBase {
public void hotwireDrive(double xStick, double yStick) {
// deadzone constraints
final double deadzone = 0.1d;
yStick *= -1;
if (Math.abs(xStick) < deadzone) xStick = 0;
if (Math.abs(yStick) < deadzone) yStick = 0;
double maximum = Math.max(xStick, yStick);
double total = xStick + yStick;
double maximum = Math.max(Math.abs(xStick), Math.abs(yStick));
double total = yStick + xStick;
double difference = yStick - xStick;
double leftSpeed, rightSpeed;
if (xStick >= 0) {
leftSpeed = rotate >= 0 ? maximum : total;
rightSpeed = rotate >= 0 ? difference : maximum;
if (yStick >= 0) {
leftSpeed = xStick >= 0 ? maximum : total;
rightSpeed = xStick >= 0 ? difference : maximum;
} else {
leftSpeed = rotate >= 0 ? total : -maximum;
rightSpeed = rotate >= 0 ? -maximum : difference;
leftSpeed = xStick >= 0 ? total : -maximum;
rightSpeed = xStick >= 0 ? -maximum : difference;
}
leftMotor.set(-leftSpeed);
rightMotor.set(leftSpeed);
m_leftMotor.set(-leftSpeed);
m_rightMotor.set(rightSpeed);
}
public void tankDrive(double leftSpeed, double rightSpeed) {