Class DifferentialDriveWheelVelocities
- All Implemented Interfaces:
Interpolatable<DifferentialDriveWheelVelocities>, ProtobufSerializable, StructSerializable, WPISerializable
-
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleVelocity of the left side of the robot in meters per second.static final DifferentialDriveWheelVelocitiesProtoDifferentialDriveWheelVelocities protobuf for serialization.doubleVelocity of the right side of the robot in meters per second.static final DifferentialDriveWheelVelocitiesStructDifferentialDriveWheelVelocities struct for serialization. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a DifferentialDriveWheelVelocities with zeros for left and right velocities.DifferentialDriveWheelVelocities(double left, double right) Constructs a DifferentialDriveWheelVelocities.DifferentialDriveWheelVelocities(LinearVelocity left, LinearVelocity right) Constructs a DifferentialDriveWheelVelocities. -
Method Summary
Modifier and TypeMethodDescriptionvoiddesaturate(double attainableMaxVelocity) Renormalizes the wheel velocities if any either side is above the specified maximum.voiddesaturate(LinearVelocity attainableMaxVelocity) Renormalizes the wheel velocities if any either side is above the specified maximum.div(double scalar) Divides the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWheelVelocities.interpolate(DifferentialDriveWheelVelocities endValue, double t) Returns the linear interpolation of this DifferentialDriveWheelVelocities and another.Subtracts the other DifferentialDriveWheelVelocities from the current DifferentialDriveWheelVelocities and returns the difference.Adds two DifferentialDriveWheelVelocities and returns the sum.times(double scalar) Multiplies the DifferentialDriveWheelVelocities by a scalar and returns the new DifferentialDriveWheelVelocities.toString()Returns the inverse of the current DifferentialDriveWheelVelocities.
-
Field Details
-
left
Velocity of the left side of the robot in meters per second. -
right
Velocity of the right side of the robot in meters per second. -
proto
DifferentialDriveWheelVelocities protobuf for serialization. -
struct
DifferentialDriveWheelVelocities struct for serialization.
-
-
Constructor Details
-
DifferentialDriveWheelVelocities
public DifferentialDriveWheelVelocities()Constructs a DifferentialDriveWheelVelocities with zeros for left and right velocities. -
DifferentialDriveWheelVelocities
Constructs a DifferentialDriveWheelVelocities.- Parameters:
left- The left velocity in meters per second.right- The right velocity in meters per second.
-
DifferentialDriveWheelVelocities
Constructs a DifferentialDriveWheelVelocities.- Parameters:
left- The left velocity in meters per second.right- The right velocity in meters per second.
-
-
Method Details
-
desaturate
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.
-
desaturate
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.
-
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
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
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
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:
interpolatein interfaceInterpolatable<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
-