Skip to content

Commit

Permalink
feat: Polar scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
msoucy committed Jul 2, 2024
1 parent 9ed3340 commit f9452eb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/subsystems/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ private void deadbandMove(final double xSpeed, final double ySpeed,
double xInput = deadband.applyAsDouble(xSpeed);
double yInput = deadband.applyAsDouble(ySpeed);

final double translateXSpeed = xInput
* maxDriveSpeedMetersPerSecond * speedCoef;
final double translateYSpeed = yInput
* maxDriveSpeedMetersPerSecond * speedCoef;
final double rotationSpeed = rotationInput
* maxRotationRadiansPerSecond * rotationCoef;
double r = Math.hypot(xInput, yInput) * maxDriveSpeedMetersPerSecond * speedCoef;
double angle = Math.atan2(yInput, xInput);

final double translateXSpeed = r * Math.cos(angle);
final double translateYSpeed = r * Math.sin(angle);
final double rotationSpeed = rotationInput * maxRotationRadiansPerSecond * rotationCoef;
move(translateXSpeed, translateYSpeed, rotationSpeed, isRobotCentric);
}

Expand Down

0 comments on commit f9452eb

Please sign in to comment.