public class DifferentialDrive extends RobotDriveBase
These drive bases typically have drop-center / skid-steer with two or more wheels per side
(e.g., 6WD or 8WD). This class takes a SpeedController per side. For four and
six motor drivetrains, construct and pass in SpeedControllerGroup
instances as follows.
Four motor drivetrain:
public class Robot {
Talon m_frontLeft = new Talon(1);
Talon m_rearLeft = new Talon(2);
SpeedControllerGroup m_left = new SpeedControllerGroup(m_frontLeft, m_rearLeft);
Talon m_frontRight = new Talon(3);
Talon m_rearRight = new Talon(4);
SpeedControllerGroup m_right = new SpeedControllerGroup(m_frontRight, m_rearRight);
DifferentialDrive m_drive = new DifferentialDrive(m_left, m_right);
}
Six motor drivetrain:
public class Robot {
Talon m_frontLeft = new Talon(1);
Talon m_midLeft = new Talon(2);
Talon m_rearLeft = new Talon(3);
SpeedControllerGroup m_left = new SpeedControllerGroup(m_frontLeft, m_midLeft, m_rearLeft);
Talon m_frontRight = new Talon(4);
Talon m_midRight = new Talon(5);
Talon m_rearRight = new Talon(6);
SpeedControllerGroup m_right = new SpeedControllerGroup(m_frontRight, m_midRight, m_rearRight);
DifferentialDrive m_drive = new DifferentialDrive(m_left, m_right);
}
A differential drive robot has left and right wheels separated by an arbitrary width.
Drive base diagram:
|_______| | | | | | | |_|___|_| | |
Each drive() function provides different inverse kinematic relations for a differential drive robot. Motor outputs for the right side are negated, so motor direction inversion by the user is usually unnecessary.
RobotDriveBase.MotorType
m_deadband, m_maxOutput, m_safetyHelper
DEFAULT_SAFETY_EXPIRATION
Constructor and Description |
---|
DifferentialDrive(SpeedController leftMotor,
SpeedController rightMotor)
Construct a DifferentialDrive.
|
Modifier and Type | Method and Description |
---|---|
void |
arcadeDrive(double y,
double rotation)
Arcade drive method for differential drive platform.
|
void |
arcadeDrive(double y,
double rotation,
boolean squaredInputs)
Arcade drive method for differential drive platform.
|
void |
curvatureDrive(double y,
double rotation,
boolean isQuickTurn)
Curvature drive method for differential drive platform.
|
java.lang.String |
getDescription() |
void |
stopMotor() |
void |
tankDrive(double left,
double right)
Tank drive method for differential drive platform.
|
void |
tankDrive(double left,
double right,
boolean squaredInputs)
Tank drive method for differential drive platform.
|
applyDeadband, getExpiration, isAlive, isSafetyEnabled, limit, normalize, setDeadband, setExpiration, setMaxOutput, setSafetyEnabled
public DifferentialDrive(SpeedController leftMotor, SpeedController rightMotor)
To pass multiple motors per side, use a SpeedControllerGroup
. If a motor needs to be
inverted, do so before passing it in.
public void arcadeDrive(double y, double rotation)
y
- The value to use for forwards/backwards. [-1.0..1.0]rotation
- The value to use for the rotation right/left. [-1.0..1.0]public void arcadeDrive(double y, double rotation, boolean squaredInputs)
y
- The value to use for forwards/backwards. [-1.0..1.0]rotation
- The value to use for the rotation right/left [-1.0..1.0]squaredInputs
- If set, decreases the input sensitivity at low speeds.public void curvatureDrive(double y, double rotation, boolean isQuickTurn)
The rotation argument controls the curvature of the robot's path rather than its rate of heading change. This makes the robot more controllable at high speeds. Also handles the robot's quick turn functionality - "quick turn" overrides constant-curvature turning for turn-in-place maneuvers.
y
- The value to use for forwards/backwards. [-1.0..1.0]rotation
- The value to use for the rotation right/left. [-1.0..1.0]isQuickTurn
- If set, overrides constant-curvature turning for
turn-in-place maneuvers.public void tankDrive(double left, double right)
left
- The value to use for left side motors. [-1.0..1.0]right
- The value to use for right side motors. [-1.0..1.0]public void tankDrive(double left, double right, boolean squaredInputs)
left
- The value to use for left side motors. [-1.0..1.0]right
- The value to use for right side motors. [-1.0..1.0]squaredInputs
- If set, decreases the input sensitivity at low speeds.public void stopMotor()
stopMotor
in interface MotorSafety
stopMotor
in class RobotDriveBase
public java.lang.String getDescription()
getDescription
in interface MotorSafety
getDescription
in class RobotDriveBase