Fixed Drive Train the right way, switched gear buttons for Josh

This commit is contained in:
Aarav Shah
2020-02-28 18:11:11 -07:00
parent c572182678
commit d83d21e062
3 changed files with 20 additions and 14 deletions
@@ -39,26 +39,32 @@ public class DriveWithJoystick extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
double moveInput = m_controller.getRightXAxis();
double steerInput = -m_controller.getLeftYAxis();
double moveInput = -m_controller.getLeftYAxis();
double steerInput = m_controller.getRightXAxis();
double moveOutput = 0;
double steerOutput = 0;
if (steerInput >= 0){
steerOutput = -Math.cos(1.571*steerInput)+1;
if (moveInput >= 0){
moveOutput = -Math.cos(1.571*moveInput)+1;
} else {
steerOutput = Math.cos(1.571*steerInput)-1;
moveOutput = Math.cos(1.571*moveInput)-1;
}
double cosMultiplier = 1.0;
double deadzone = .1;
if (moveInput > 0){
moveOutput = -(cosMultiplier - deadzone) * Math.cos(1.571*moveInput) + cosMultiplier;
} else if (moveInput < 0) {
moveOutput = (cosMultiplier - deadzone) * Math.cos(1.571*moveInput) - cosMultiplier;
if (steerInput > 0){
steerOutput = -(cosMultiplier - deadzone) * Math.cos(1.571*steerInput) + cosMultiplier;
} else if (steerInput < 0) {
steerOutput = (cosMultiplier - deadzone) * Math.cos(1.571*steerInput) - cosMultiplier;
} else {
moveOutput = 0;
steerOutput = 0;
}
if (moveOutput > 0.5) {
moveOutput = 0.5;
} else if(moveOutput < -0.5) {
moveOutput = -0.5;
}
SmartDashboard.putNumber("Steer Output Test", moveOutput);
m_drive.driveWithInput(moveOutput, steerOutput);
}