mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] MecanumDriveWheelSpeeds: Fix desaturate() (#6040)
This commit is contained in:
@@ -11,7 +11,6 @@ import edu.wpi.first.math.kinematics.struct.MecanumDriveWheelSpeedsStruct;
|
||||
import edu.wpi.first.units.Distance;
|
||||
import edu.wpi.first.units.Measure;
|
||||
import edu.wpi.first.units.Velocity;
|
||||
import java.util.stream.DoubleStream;
|
||||
|
||||
public class MecanumDriveWheelSpeeds {
|
||||
/** Speed of the front left wheel. */
|
||||
@@ -83,13 +82,9 @@ public class MecanumDriveWheelSpeeds {
|
||||
*/
|
||||
public void desaturate(double attainableMaxSpeedMetersPerSecond) {
|
||||
double realMaxSpeed =
|
||||
DoubleStream.of(
|
||||
frontLeftMetersPerSecond,
|
||||
frontRightMetersPerSecond,
|
||||
rearLeftMetersPerSecond,
|
||||
rearRightMetersPerSecond)
|
||||
.max()
|
||||
.getAsDouble();
|
||||
Math.max(Math.abs(frontLeftMetersPerSecond), Math.abs(frontRightMetersPerSecond));
|
||||
realMaxSpeed = Math.max(realMaxSpeed, Math.abs(rearLeftMetersPerSecond));
|
||||
realMaxSpeed = Math.max(realMaxSpeed, Math.abs(rearRightMetersPerSecond));
|
||||
|
||||
if (realMaxSpeed > attainableMaxSpeedMetersPerSecond) {
|
||||
frontLeftMetersPerSecond =
|
||||
|
||||
Reference in New Issue
Block a user