Class DifferentialDriveWheelVelocities

java.lang.Object
org.wpilib.math.kinematics.DifferentialDriveWheelVelocities
All Implemented Interfaces:
Interpolatable<DifferentialDriveWheelVelocities>, ProtobufSerializable, StructSerializable, WPISerializable

public class DifferentialDriveWheelVelocities extends Object implements Interpolatable<DifferentialDriveWheelVelocities>, ProtobufSerializable, StructSerializable
Represents the wheel velocities for a differential drive drivetrain.
  • Field Details

    • left

      public double left
      Velocity of the left side of the robot in meters per second.
    • proto

      public static final DifferentialDriveWheelVelocitiesProto proto
      DifferentialDriveWheelVelocities protobuf for serialization.
    • struct

      public static final DifferentialDriveWheelVelocitiesStruct struct
      DifferentialDriveWheelVelocities struct for serialization.
  • Constructor Details

    • DifferentialDriveWheelVelocities

      public DifferentialDriveWheelVelocities()
      Constructs a DifferentialDriveWheelVelocities with zeros for left and right velocities.
    • DifferentialDriveWheelVelocities

      public DifferentialDriveWheelVelocities(double left, double right)
      Constructs a DifferentialDriveWheelVelocities.
      Parameters:
      left - The left velocity in meters per second.
      right - The right velocity in meters per second.
    • DifferentialDriveWheelVelocities

      public DifferentialDriveWheelVelocities(LinearVelocity left, LinearVelocity right)
      Constructs a DifferentialDriveWheelVelocities.
      Parameters:
      left - The left velocity in meters per second.
      right - The right velocity in meters per second.
  • Method Details

    • desaturate

      public DifferentialDriveWheelVelocities desaturate(double attainableMaxVelocity)
      Renormalizes the wheel velocities if any either side is above the specified maximum.

      Sometimes, after inverse kinematics, the requested velocity from one or more wheels may be above the max attainable velocity for the driving motor on that wheel. To fix this issue, one can reduce all the wheel velocities to make sure that all requested module velocities are at-or-below the absolute threshold, while maintaining the ratio of velocities between wheels.

      Parameters:
      attainableMaxVelocity - The absolute max velocity in meters per second that a wheel can reach.
      Returns:
      The desaturated DifferentialDriveWheelVelocities.
    • desaturate

      public DifferentialDriveWheelVelocities desaturate(LinearVelocity attainableMaxVelocity)
      Renormalizes the wheel velocities if any either side is above the specified maximum.

      Sometimes, after inverse kinematics, the requested velocity from one or more wheels may be above the max attainable velocity for the driving motor on that wheel. To fix this issue, one can reduce all the wheel velocities to make sure that all requested module velocities are at-or-below the absolute threshold, while maintaining the ratio of velocities between wheels.

      Parameters:
      attainableMaxVelocity - The absolute max velocity in meters per second that a wheel can reach.
      Returns:
      The desaturated DifferentialDriveWheelVelocities.
    • plus

      Adds two DifferentialDriveWheelVelocities and returns the sum.

      For example, DifferentialDriveWheelVelocities{1.0, 0.5} + DifferentialDriveWheelVelocities{2.0, 1.5} = DifferentialDriveWheelVelocities{3.0, 2.0}

      Parameters:
      other - The DifferentialDriveWheelVelocities to add.
      Returns:
      The sum of the DifferentialDriveWheelVelocities.
    • minus

      Subtracts the other DifferentialDriveWheelVelocities from the current DifferentialDriveWheelVelocities and returns the difference.

      For example, DifferentialDriveWheelVelocities{5.0, 4.0} - DifferentialDriveWheelVelocities{1.0, 2.0} = DifferentialDriveWheelVelocities{4.0, 2.0}

      Parameters:
      other - The DifferentialDriveWheelVelocities to subtract.
      Returns:
      The difference between the two DifferentialDriveWheelVelocities.
    • unaryMinus

      public DifferentialDriveWheelVelocities unaryMinus()
      Returns the inverse of the current DifferentialDriveWheelVelocities. This is equivalent to negating all components of the DifferentialDriveWheelVelocities.
      Returns:
      The inverse of the current DifferentialDriveWheelVelocities.
    • times

      public DifferentialDriveWheelVelocities times(double scalar)
      Multiplies the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWheelVelocities.

      For example, DifferentialDriveWheelVelocities{2.0, 2.5} * 2 = DifferentialDriveWheelVelocities{4.0, 5.0}

      Parameters:
      scalar - The scalar to multiply by.
      Returns:
      The scaled DifferentialDriveWheelVelocities.
    • div

      public DifferentialDriveWheelVelocities div(double scalar)
      Divides the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWheelVelocities.

      For example, DifferentialDriveWheelVelocities{2.0, 2.5} / 2 = DifferentialDriveWheelVelocities{1.0, 1.25}

      Parameters:
      scalar - The scalar to divide by.
      Returns:
      The scaled DifferentialDriveWheelVelocities.
    • interpolate

      public DifferentialDriveWheelVelocities interpolate(DifferentialDriveWheelVelocities endValue, double t)
      Returns the linear interpolation of this DifferentialDriveWheelVelocities and another.
      Specified by:
      interpolate in interface Interpolatable<DifferentialDriveWheelVelocities>
      Parameters:
      endValue - The end value for the interpolation.
      t - How far between the two values to interpolate. This is clamped to [0, 1].
      Returns:
      The interpolated value.
    • toString

      public String toString()
      Overrides:
      toString in class Object