public class DiffySwerveModuleEx extends DiffySwerveModule
Modifier and Type | Field and Description |
---|---|
double |
kRevConstant
This is the constant that corresponds to the
revolutions of the module; this value must be tuned;
this is in degrees per tick
|
double |
kWheelConstant
This is the constant that corresponds to the revolution
of the wheel rather than the rotation of the module;
this value must be tuned; this is in centimeters per tick
|
java.util.function.DoubleSupplier |
moduleHeading
This is the heading of the module.
|
m_motorOne, m_motorTwo, MOTOR_1_POWER, MOTOR_2_POWER
Constructor and Description |
---|
DiffySwerveModuleEx(MotorEx one,
MotorEx two)
Make sure the motors are already reversed if needed
|
DiffySwerveModuleEx(MotorEx one,
MotorEx two,
double kAngle,
double kWheel,
PIDFController cont)
Make sure the motors are already reversed if needed
|
Modifier and Type | Method and Description |
---|---|
void |
driveModule(Vector2d powerVec)
Once the difference between the desired angle
and the current angle reaches 0, the vector becomes
(magnitude, 0), which means it will strictly move forward.
|
double |
getDistanceTravelled() |
double[] |
getLastEncoderCounts() |
double[] |
getRawEncoderCounts()
Returns the encoder counts of the motors in the module
|
double |
getRawHeading()
Returns the raw heading of the module in degrees
|
void |
resetEncoders()
Resets the encoder values of the motors
|
void |
setCmsPerTick(double val) |
void |
setDegreesPerTick(double val) |
void |
setHeadingInterpol(java.util.function.DoubleSupplier headingReader)
You can set this to use the value returned by getRawHeading()
or from an external sensor.
|
void |
setThreshold(double kThreshold)
Allows you to set the threshold value of the PController
|
void |
turnToAngle(double angle)
Turns the module to a desired angle.
|
void |
updateTracking()
Updates the distance travelled
|
disable, driveModule, normalize, setInverted, stopMotor
public double kRevConstant
public double kWheelConstant
public java.util.function.DoubleSupplier moduleHeading
public DiffySwerveModuleEx(MotorEx one, MotorEx two)
one
- the first motortwo
- the second motorpublic DiffySwerveModuleEx(MotorEx one, MotorEx two, double kAngle, double kWheel, PIDFController cont)
one
- the first motortwo
- the second motorkAngle
- the module constant that is used for heading;
this is a value that needs to be tuned;
it takes into consideration the gear ratios
and counts per revolution of the motorskWheel
- the module constant that is used for distance;
this is a value that needs to be tuned;
it takes into consideration the gear ratios
and counts per revolution of the motorscont
- the pidf controller that controls the rotation of the modulepublic void resetEncoders()
public void setDegreesPerTick(double val)
public void setCmsPerTick(double val)
public double[] getRawEncoderCounts()
public void setThreshold(double kThreshold)
kThreshold
- the desired threshold for the controllerpublic double[] getLastEncoderCounts()
public double getRawHeading()
public void updateTracking()
public void setHeadingInterpol(java.util.function.DoubleSupplier headingReader)
headingReader
- the heading pointerpublic double getDistanceTravelled()
public void driveModule(Vector2d powerVec)
driveModule
in class DiffySwerveModule
public void turnToAngle(double angle)
angle
- The desired set angle in radians