Class UnitScaler

    • Constructor Detail

      • UnitScaler

        public UnitScaler​(double distanceFactor,
                          double timeFactor)
        Creates a new UnitScaler.
        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 provided TankDriveData instance. During scaling, for both sides (left and right), position is multiplied by the distance factor, and velocity and acceleration 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 interface Function<TankDriveData,​TankDriveData>
        Parameters:
        d - The data to scale.
        Returns:
        A new TankDriveData, scaled as above.