Class VelocityControlModule
- java.lang.Object
-
- com.thegongoliers.output.drivetrain.VelocityControlModule
-
- All Implemented Interfaces:
DriveModule
public class VelocityControlModule extends java.lang.Object implements DriveModule
A drivetrain module which will set the wheel velocity rather than percent power
-
-
Constructor Summary
Constructors Constructor Description VelocityControlModule(edu.wpi.first.wpilibj.Encoder leftEncoder, edu.wpi.first.wpilibj.Encoder rightEncoder, double maxVelocity, double strength)
Default constructorVelocityControlModule(edu.wpi.first.wpilibj.Encoder leftEncoder, edu.wpi.first.wpilibj.Encoder rightEncoder, double maxVelocity, com.kylecorry.pid.PID velocityPID)
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DriveSpeed
run(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)
Run the drive modulevoid
setLeftEncoder(edu.wpi.first.wpilibj.Encoder leftEncoder)
void
setMaxVelocity(double maxVelocity)
void
setPID(com.kylecorry.pid.PID pid)
void
setRightEncoder(edu.wpi.first.wpilibj.Encoder rightEncoder)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.thegongoliers.output.drivetrain.DriveModule
overridesUser
-
-
-
-
Constructor Detail
-
VelocityControlModule
public VelocityControlModule(edu.wpi.first.wpilibj.Encoder leftEncoder, edu.wpi.first.wpilibj.Encoder rightEncoder, double maxVelocity, double strength)
Default constructor- Parameters:
leftEncoder
- the left encoderrightEncoder
- the right encodermaxVelocity
- the maximum velocity of the robot in the same units as the encoder's rate (something / second)strength
- the velocity correction strength
-
VelocityControlModule
public VelocityControlModule(edu.wpi.first.wpilibj.Encoder leftEncoder, edu.wpi.first.wpilibj.Encoder rightEncoder, double maxVelocity, com.kylecorry.pid.PID velocityPID)
Default constructor- Parameters:
leftEncoder
- the left encoderrightEncoder
- the right encodermaxVelocity
- the maximum velocity of the robot in the same units as the encoder's rate (something / second)velocityPID
- the PID to control velocity
-
-
Method Detail
-
run
public DriveSpeed run(DriveSpeed currentSpeed, DriveSpeed desiredSpeed, double deltaTime)
Description copied from interface:DriveModule
Run the drive module- Specified by:
run
in interfaceDriveModule
- Parameters:
currentSpeed
- the current speed of the drivetraindesiredSpeed
- the desired speed of the drivetraindeltaTime
- the delta time since the last call in seconds- Returns:
- the speed the drivetrain should set
-
setLeftEncoder
public void setLeftEncoder(edu.wpi.first.wpilibj.Encoder leftEncoder)
-
setRightEncoder
public void setRightEncoder(edu.wpi.first.wpilibj.Encoder rightEncoder)
-
setPID
public void setPID(com.kylecorry.pid.PID pid)
-
setMaxVelocity
public void setMaxVelocity(double maxVelocity)
-
-