This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FF-19 Basic Pure Pursuit and tuned odometry for new drivetrain
- Loading branch information
Showing
21 changed files
with
664 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
**/.DS_STORE | ||
|
||
# Built application files | ||
*.apk | ||
*.aar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
TeamCode/src/main/java/com/kuriosityrobotics/firstforward/robot/math/MathUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.kuriosityrobotics.firstforward.robot.math; | ||
|
||
public class MathUtil { | ||
private static final double EPSILON = 0.00001; | ||
|
||
/** | ||
* Wraps angle (in radians) to a value from -pi to pi | ||
* | ||
* @param angle Angle to be wrapped | ||
* @return The wrapped angle, between -pi and pi | ||
*/ | ||
public static double angleWrap(double angle) { | ||
return angleWrap(angle, 0); | ||
} | ||
|
||
/** | ||
* Wraps an angle (in radians) to a value within pi of centerOfWrap. | ||
* | ||
* @param angle The angle to be wrapped | ||
* @param centerOfWrap The center of the boundary in which the angle can be wrapped to. | ||
* @return The wrapped angle, which will lie within pi of the centerOfWrap. | ||
*/ | ||
public static double angleWrap(double angle, double centerOfWrap) { | ||
if (angle > centerOfWrap + Math.PI) { | ||
return angleWrap(angle - (2 * Math.PI), centerOfWrap); | ||
} else if (angle < centerOfWrap - Math.PI) { | ||
return angleWrap(angle + (2 * Math.PI), centerOfWrap); | ||
} else { | ||
return angle; | ||
} | ||
} | ||
|
||
public static boolean doublesEqual(double a, double b) { | ||
return Math.abs(a - b) < EPSILON; | ||
} | ||
|
||
public static double max(double... in) { | ||
double max = Double.MIN_VALUE; | ||
for (double x : in) { | ||
max = Math.max(max, x); | ||
} | ||
|
||
return max; | ||
} | ||
} |
Oops, something went wrong.