mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add MathUtils.clamp() for Java (#1861)
Also use std::clamp() and MathUtils.clamp() in as many places as possible in place of custom clamp functions or if statements.
This commit is contained in:
committed by
Peter Johnson
parent
eb3e0c9c95
commit
1fb3011235
@@ -51,10 +51,10 @@ void KilloughDrive::DriveCartesian(double ySpeed, double xSpeed,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
ySpeed = Limit(ySpeed);
|
||||
ySpeed = std::clamp(ySpeed, -1.0, 1.0);
|
||||
ySpeed = ApplyDeadband(ySpeed, m_deadband);
|
||||
|
||||
xSpeed = Limit(xSpeed);
|
||||
xSpeed = std::clamp(xSpeed, -1.0, 1.0);
|
||||
xSpeed = ApplyDeadband(xSpeed, m_deadband);
|
||||
|
||||
// Compensate for gyro angle.
|
||||
|
||||
Reference in New Issue
Block a user