public class DriveBase extends java.lang.Object implements ActuatorModule, MotorSafety
| Modifier and Type | Class and Description |
|---|---|
static class |
DriveBase.MotorType
Enum representation of each motor
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_allocatedFrontMotors |
protected boolean |
m_allocatedRearMotors |
protected SpeedController |
m_frontLeftMotor |
protected SpeedController |
m_frontRightMotor |
protected SpeedController |
m_rearLeftMotor |
protected SpeedController |
m_rearRightMotor |
protected MotorSafetyHelper |
m_safetyHelper |
protected byte |
m_syncGroup |
protected double[] |
m_wheelSpeeds |
private static double |
sqrt2 |
SAFETY_TIMEOUT_DEFAULT, SAFETY_TIMEOUT_LOOSE, SAFETY_TIMEOUT_STRICT| Constructor and Description |
|---|
DriveBase(PWM.PWMChannel left,
PWM.PWMChannel right) |
DriveBase(PWM.PWMChannel frontLeft,
PWM.PWMChannel frontRight,
PWM.PWMChannel rearLeft,
PWM.PWMChannel rearRight) |
DriveBase(SpeedController left,
SpeedController right) |
DriveBase(SpeedController frontLeft,
SpeedController frontRight,
SpeedController rearLeft,
SpeedController rearRight) |
| Modifier and Type | Method and Description |
|---|---|
void |
arcade(double forward,
double rotation)
Arcade drive implements single stick driving.
|
void |
arcade(double forward,
double rotation,
boolean squared)
Arcade drive implements single stick driving.
|
<T> void |
bind(T o,
java.util.function.BiConsumer<DriveBase,T> q) |
void |
disableModule()
Disable the module
|
void |
enableModule()
Enable the module
|
void |
free() |
java.lang.String |
getDescription()
Gets the description.
|
boolean |
getModuleEnabled() |
MotorSafetyHelper |
getSafetyHelper()
Return the MotorSafetyHelper object for this MotorSafety Object
|
void |
makeSafe()
Make this actuator safe.
|
void |
mecanum_polar(double magnitude,
double direction,
double rotation)
Drive method for Mecanum wheeled robots.
|
void |
mecanum_polar(double magnitude,
double direction,
double rotation,
boolean squared)
Drive method for Mecanum wheeled robots.
|
void |
mecanum(double x,
double y,
double rotation)
Drive method for Mecanum wheeled robots.
|
void |
mecanum(double x,
double y,
double rotation,
boolean squared)
Drive method for Mecanum wheeled robots.
|
void |
mecanum(double x,
double y,
double rotation,
double gyro)
Drive method for Mecanum wheeled robots.
|
void |
mecanum(double x,
double y,
double rotation,
double gyro,
boolean squared)
Drive method for Mecanum wheeled robots.
|
protected void |
normalize()
Normalize all wheel speeds if the magnitude of any wheel is greater than 1.0.
|
protected static double[] |
rotateVector(double x,
double y,
double angle)
Rotate a vector in Cartesian space.
|
void |
setLeftMotors(double speed)
Set the speed of the left motors.
|
void |
setMotorInverted(DriveBase.MotorType type,
boolean inverted)
Invert a motor direction.
|
protected void |
setMotors()
Set the speed of the motors to the values in m_wheelSpeeds.
|
void |
setMotors(double speed)
Set the speed of all the motors to a single value.
|
void |
setMotors(double left,
double right)
Set the speed of the right and left motors.
|
void |
setMotors(double frontLeft,
double frontRight,
double rearLeft,
double rearRight)
Set the speed of all the motors.
|
void |
setRightMotors(double speed)
Set the speed of the right motors.
|
protected static double |
squareInput(double input)
Square an input, keeping the sign(-/+)
|
void |
stopMotor()
Stop motor.
|
void |
tank(double left,
double right)
Provide tank steering using the stored robot configuration.
|
void |
tank(double left,
double right,
boolean squared)
Provide tank steering using the stored robot configuration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfeed, getSafetyExpiration, isAlive, isSafetyEnabled, setSafetyEnabled, setSafetyExpirationprotected MotorSafetyHelper m_safetyHelper
protected SpeedController m_frontLeftMotor
protected SpeedController m_frontRightMotor
protected SpeedController m_rearLeftMotor
protected SpeedController m_rearRightMotor
protected boolean m_allocatedFrontMotors
protected boolean m_allocatedRearMotors
protected byte m_syncGroup
protected double[] m_wheelSpeeds
private static final double sqrt2
public DriveBase(PWM.PWMChannel left, PWM.PWMChannel right)
left - right - public DriveBase(SpeedController left, SpeedController right)
left - right - public DriveBase(PWM.PWMChannel frontLeft, PWM.PWMChannel frontRight, PWM.PWMChannel rearLeft, PWM.PWMChannel rearRight)
frontLeft - frontRight - rearLeft - rearRight - public DriveBase(SpeedController frontLeft, SpeedController frontRight, SpeedController rearLeft, SpeedController rearRight)
frontLeft - frontRight - rearLeft - rearRight - public void free()
public void setMotorInverted(DriveBase.MotorType type, boolean inverted)
type - the DriveBase.MotorType to setinverted - True if the motor should be inverted when operated.public <T> void bind(T o,
java.util.function.BiConsumer<DriveBase,T> q)
public void arcade(double forward,
double rotation)
forward - The value to use for forwards/backwardsrotation - The value to use for the rotate right/leftpublic void arcade(double forward,
double rotation,
boolean squared)
forward - The value to use for forwards/backwardsrotation - The value to use for the rotate right/leftsquared - If set, decreases the sensitivity at low speedspublic void tank(double left,
double right)
left - The value of the left stick.right - The value of the right stick.public void tank(double left,
double right,
boolean squared)
left - The value of the left stick.right - The value of the right stick.squared - If set, decreases the sensitivity at low speedspublic void mecanum(double x,
double y,
double rotation)
x - The speed that the robot should drive in the X direction. [-1.0..1.0]y - The speed that the robot should drive in the Y direction.
This input is inverted to match the forward == -1.0 that joysticks produce. [-1.0..1.0]rotation - The rate of rotation for the robot that is completely independent of
the translation. [-1.0..1.0]public void mecanum(double x,
double y,
double rotation,
boolean squared)
x - The speed that the robot should drive in the X direction. [-1.0..1.0]y - The speed that the robot should drive in the Y direction.
This input is inverted to match the forward == -1.0 that joysticks produce. [-1.0..1.0]rotation - The rate of rotation for the robot that is completely independent of
the translation. [-1.0..1.0]squared - If set, decreases the sensitivity at low speedspublic void mecanum(double x,
double y,
double rotation,
double gyro)
x - The speed that the robot should drive in the X direction. [-1.0..1.0]y - The speed that the robot should drive in the Y direction.
This input is inverted to match the forward == -1.0 that joysticks produce. [-1.0..1.0]rotation - The rate of rotation for the robot that is completely independent of
the translation. [-1.0..1.0]gyro - The current angle reading from the gyro. Use this to implement field-oriented controls.public void mecanum(double x,
double y,
double rotation,
double gyro,
boolean squared)
x - The speed that the robot should drive in the X direction. [-1.0..1.0]y - The speed that the robot should drive in the Y direction.
This input is inverted to match the forward == -1.0 that joysticks produce. [-1.0..1.0]rotation - The rate of rotation for the robot that is completely independent of
the translation. [-1.0..1.0]gyro - The current angle reading from the gyro. Use this to implement field-oriented controls.squared - If set, decreases the sensitivity at low speedspublic void mecanum_polar(double magnitude,
double direction,
double rotation)
magnitude - The speed that the robot should drive in a given direction.direction - The direction the robot should drive in degrees. The direction and maginitute are
independent of the rotation rate.rotation - The rate of rotation for the robot that is completely independent of
the magnitute or direction. [-1.0..1.0]public void mecanum_polar(double magnitude,
double direction,
double rotation,
boolean squared)
magnitude - The speed that the robot should drive in a given direction.direction - The direction the robot should drive in degrees. The direction and maginitute are
independent of the rotation rate.rotation - The rate of rotation for the robot that is completely independent of
the magnitute or direction. [-1.0..1.0]squared - If set, decreases the sensitivity at low speedsprotected static double squareInput(double input)
input - the value to be squaredprotected void normalize()
protected static double[] rotateVector(double x,
double y,
double angle)
x - the x componenty - the y componentangle - the angle of rotationpublic void setLeftMotors(double speed)
speed - The speed to send to the left side of the robot.public void setRightMotors(double speed)
speed - The speed to send to the right side of the robot.public void setMotors(double speed)
speed - The speed to send to all the motors.public void setMotors(double left,
double right)
left - The speed to send to the left side of the robot.right - The speed to send to the right side of the robot.public void setMotors(double frontLeft,
double frontRight,
double rearLeft,
double rearRight)
frontLeft - The speed to send to the front left motor.frontRight - The speed to send to the front right motor.rearLeft - The speed to send to the rear left motor.rearRight - The speed to send to the rear right motor.protected void setMotors()
public MotorSafetyHelper getSafetyHelper()
getSafetyHelper in interface MotorSafetypublic void stopMotor()
stopMotor in interface MotorSafetypublic java.lang.String getDescription()
getDescription in interface MotorSafetypublic void enableModule()
enableModule in interface Modulepublic void disableModule()
disableModule in interface Modulepublic void makeSafe()
makeSafe in interface ActuatorModulepublic boolean getModuleEnabled()
getModuleEnabled in interface Module