Interface Manner.SpeedSupplier
-
- All Known Subinterfaces:
MovementManner.MovementSpeedSupplier
,TurnManner.TurnSpeedSupplier
- Enclosing class:
- Manner
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public static interface Manner.SpeedSupplier
A functional interface which gets the speed the robot should perform an abstract autonomous task given the amount left to be completed.IMPLEMENTATION NOTE: The interfaces which extend
SpeedSupplier
do not actually make changes, but are specific toMovementManner
orTurnManner
for clarity. Because of this, anySpeedSupplier
class can be casted to any other class which extendsSpeedSupplier
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Manner.SpeedSupplier
constantSpeed(double speed)
Returns aManner.SpeedSupplier
representing a constant speed at all points in the given autonomous task.double
getSpeed(double remaining)
Gets the speed the robot should perform the autonomous task at.static Manner.SpeedSupplier
speedWithSlowdown(double maxSpeed, double slowdownOffset, double minSpeed)
Returns aManner.SpeedSupplier
representing a speed that slows down after a certain proximity to the endpoint of the autonomous task, until a minimum speed is hit.
-
-
-
Method Detail
-
getSpeed
double getSpeed(double remaining)
Gets the speed the robot should perform the autonomous task at.- Parameters:
remaining
- The amount already completed, in an arbitrary unit.- Returns:
- The speed the robot should perform the task at, on the interval [0, 1].
-
constantSpeed
static Manner.SpeedSupplier constantSpeed(double speed)
Returns aManner.SpeedSupplier
representing a constant speed at all points in the given autonomous task.- Parameters:
speed
- The constant robot speed along the path.- Returns:
- The equivalent
Manner.SpeedSupplier
.
-
speedWithSlowdown
static Manner.SpeedSupplier speedWithSlowdown(double maxSpeed, double slowdownOffset, double minSpeed)
Returns aManner.SpeedSupplier
representing a speed that slows down after a certain proximity to the endpoint of the autonomous task, until a minimum speed is hit. That is, this type ofManner.SpeedSupplier
will return a given default (maximum) speed up until the robot must slow down (the slowdown offset). Then, the robot will slow down proportionally after the slowdown offset. However, the robot will not slow down past a given minimum speed.- Parameters:
maxSpeed
- The speed the robot will move/complete the autonomous task at for the majority of the path.slowdownOffset
- The point (in units for distance, rotation, etc.) from the end position of the autonomous task at which the robot will begin proportionally slowing down.minSpeed
- After the slowdown offset, the robot will not move any slower thanminSpeed
. This is to prevent the robot moving so slowly that friction or some other force prevents the robot from fully completing the autonomous path.- Returns:
- A
Manner.SpeedSupplier
described by the given parameters.
-
-