Package me.wobblyyyy.pathfinder.math
Class RotationalVelocity
java.lang.Object
me.wobblyyyy.pathfinder.math.RotationalVelocity
public class RotationalVelocity
extends java.lang.Object
A representation of a rotational velocity force. This force is measured in
either rotations per second or rotations per minute. Either way works just
fine. This class was created mostly to simplify the process of writing code
that modifies swerve module values for swerve module odometry.
- Since:
- 0.3.0
- Author:
- Colin Robertson
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RotationalVelocity.Type
Different types of rotational velocity measurement. -
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<java.lang.Double>
velocitySupplier
An internal access point for the wheel's rotational velocity.private RotationalVelocity.Type
velocityType
An internal reference to what type of velocity this instance of theRotationalVelocity
is - RPS or RPM. -
Constructor Summary
Constructors Constructor Description RotationalVelocity(java.util.function.Supplier<java.lang.Double> velocitySupplier, RotationalVelocity.Type velocityType)
Create a newRotationalVelocity
instance. -
Method Summary
Modifier and Type Method Description double
get(RotationalVelocity.Type type)
Get the wheel's rotational velocity in whatever type is specified.double
getRotationsPerMinute()
Get the velocity, notated in rotations per minute (RPM)double
getRotationsPerSecond()
Get the velocity, notated in rotations per second (RPS)static double
perMinuteToPerSecond(double perMinute)
Convert rotations per minute to rotations per second.static double
perSecondToPerMinute(double perSecond)
Convert rotations per second to rotations per minute.private double
raw()
Get the raw velocity of the wheel.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
velocitySupplier
private final java.util.function.Supplier<java.lang.Double> velocitySupplierAn internal access point for the wheel's rotational velocity. -
velocityType
An internal reference to what type of velocity this instance of theRotationalVelocity
is - RPS or RPM.
-
-
Constructor Details
-
RotationalVelocity
public RotationalVelocity(java.util.function.Supplier<java.lang.Double> velocitySupplier, RotationalVelocity.Type velocityType)Create a newRotationalVelocity
instance.- Parameters:
velocitySupplier
- a method that is capable of supplying the velocity of the given wheel. This method should call some sort of a "getVelocity()" method that will determine the wheel's velocity based on an encoder.velocityType
- what type of velocity is being used. In general, this is most often RPM, not RPS. Unless you know for certain that this is measured in RPS and not RPM, you should just use RPM.
-
-
Method Details
-
perSecondToPerMinute
public static double perSecondToPerMinute(double perSecond)Convert rotations per second to rotations per minute.- Parameters:
perSecond
- the value to convert.- Returns:
- the converted value.
-
perMinuteToPerSecond
public static double perMinuteToPerSecond(double perMinute)Convert rotations per minute to rotations per second.- Parameters:
perMinute
- the value to convert.- Returns:
- the converted value.
-
raw
private double raw()Get the raw velocity of the wheel.- Returns:
- the wheel's raw velocity.
-
get
Get the wheel's rotational velocity in whatever type is specified.- Parameters:
type
- the type of velocity to get.- Returns:
- the wheel's velocity, in whatever type you specified.
-
getRotationsPerSecond
public double getRotationsPerSecond()Get the velocity, notated in rotations per second (RPS)- Returns:
- the velocity of the target, notated in RPS
-
getRotationsPerMinute
public double getRotationsPerMinute()Get the velocity, notated in rotations per minute (RPM)- Returns:
- the velocity of the target, notated in RPM
-