Class UnitScaler
- java.lang.Object
-
- org.team1540.rooster.drive.pipeline.UnitScaler
-
- All Implemented Interfaces:
Function<TankDriveData,TankDriveData>
,Processor<TankDriveData,TankDriveData>
public class UnitScaler extends Object implements Processor<TankDriveData,TankDriveData>
Scales units by a desired factor. For details of the scaling, seeapply()
.
-
-
Constructor Summary
Constructors Constructor Description UnitScaler(double distanceFactor, double timeFactor)
Creates a newUnitScaler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TankDriveData
apply(TankDriveData d)
Scales the units in the providedTankDriveData
instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.team1540.rooster.functional.Processor
followedBy, process
-
-
-
-
Constructor Detail
-
UnitScaler
public UnitScaler(double distanceFactor, double timeFactor)
Creates a newUnitScaler
.- Parameters:
distanceFactor
- The scale factor from input distance units (e.g. feet, meters) to output distance units (e.g. ticks).timeFactor
- The scale factor from input time units (e.g. seconds) to output time units.
-
-
Method Detail
-
apply
public TankDriveData apply(TankDriveData d)
Scales the units in the providedTankDriveData
instance. During scaling, for both sides (left
andright
),position
is multiplied by the distance factor, andvelocity
andacceleration
are multiplied by the distance factor then divided by the time factor. If any of these parameters are not present, they will also simply not be present in the output. Feed-forward, heading, and turning rate setpoints are passed through unaffected.- Specified by:
apply
in interfaceFunction<TankDriveData,TankDriveData>
- Parameters:
d
- The data to scale.- Returns:
- A new
TankDriveData
, scaled as above.
-
-