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:
Tyler Veness
2019-08-28 23:24:30 -07:00
committed by Peter Johnson
parent eb3e0c9c95
commit 1fb3011235
12 changed files with 75 additions and 78 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -26,16 +26,6 @@ void RobotDriveBase::SetMaxOutput(double maxOutput) { m_maxOutput = maxOutput; }
void RobotDriveBase::FeedWatchdog() { Feed(); }
double RobotDriveBase::Limit(double value) {
if (value > 1.0) {
return 1.0;
}
if (value < -1.0) {
return -1.0;
}
return value;
}
double RobotDriveBase::ApplyDeadband(double value, double deadband) {
if (std::abs(value) > deadband) {
if (value > 0.0) {