Package trclib.drivebase
Class TrcSimpleDriveBase
java.lang.Object
trclib.drivebase.TrcDriveBase
trclib.drivebase.TrcSimpleDriveBase
- All Implemented Interfaces:
TrcExclusiveSubsystem
- Direct Known Subclasses:
TrcMecanumDriveBase
,TrcSwerveDriveBase
This class implements a platform independent simple drive base. The SimpleDriveBase class implements a drive train
that may consist of 2 to 6 motors. It supports tank drive, curve drive and arcade drive with motor stalled detection
and inverted drive mode. It also supports gyro assisted drive to keep robot driving straight.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class trclib.drivebase.TrcDriveBase
TrcDriveBase.DriveOrientation, TrcDriveBase.MotorPowerMapper, TrcDriveBase.MotorsState, TrcDriveBase.Odometry, TrcDriveBase.OdometryType
Nested classes/interfaces inherited from interface trclib.robotcore.TrcExclusiveSubsystem
TrcExclusiveSubsystem.OwnershipParams
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TrcMotor
protected final TrcMotor
protected final TrcMotor
private final String
protected final TrcMotor
protected final TrcMotor
protected final TrcMotor
Fields inherited from class trclib.drivebase.TrcDriveBase
angleScale, motorPowerMapper, odometry, stallStartTime, stallVelThreshold, tracer, xScale, yScale
-
Constructor Summary
ConstructorsConstructorDescriptionTrcSimpleDriveBase
(TrcMotor leftMotor, TrcMotor rightMotor) Constructor: Create an instance of a 2-wheel drive base.TrcSimpleDriveBase
(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor) Constructor: Create an instance of a 4-wheel drive base.TrcSimpleDriveBase
(TrcMotor lfMotor, TrcMotor lcMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rcMotor, TrcMotor rbMotor) Constructor: Create an instance of a 6-wheel drive base.TrcSimpleDriveBase
(TrcMotor lfMotor, TrcMotor lcMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rcMotor, TrcMotor rbMotor, TrcGyro gyro) Constructor: Create an instance of a 6-wheel drive base.TrcSimpleDriveBase
(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor, TrcGyro gyro) Constructor: Create an instance of a 4-wheel drive base.TrcSimpleDriveBase
(TrcMotor leftMotor, TrcMotor rightMotor, TrcGyro gyro) Constructor: Create an instance of a 2-wheel drive base. -
Method Summary
Modifier and TypeMethodDescriptionprotected TrcDriveBase.Odometry
getOdometryDelta
(TrcOdometrySensor.Odometry[] prevOdometries, TrcOdometrySensor.Odometry[] currOdometries) This method is called periodically to calculate the delta between the previous and current motor odometries.void
setInvertedMotor
(TrcSimpleDriveBase.MotorType motorType, boolean inverted) This method inverts direction of a given motor in the drive train.void
setWheelBaseWidth
(double width) This method sets the wheel base width of the robot drive base.void
tankDrive
(String owner, double leftPower, double rightPower, boolean inverted, double driveTime, TrcEvent event) This method implements tank drive where leftPower controls the left motors and right power controls the right motors.Methods inherited from class trclib.drivebase.TrcDriveBase
arcadeDrive, arcadeDrive, arcadeDrive, arcadeDrive, arcadeDrive, clearReferenceOdometry, curveDrive, curveDrive, curveDrive, curveDrive, curveDrive, disableAntiTipping, enableAntiTipping, enableAntiTipping, getAntiTippingPower, getDriveGyroAngle, getDriveOrientation, getFieldPosition, getFieldVelocity, getGyroAssistPower, getHeading, getMotors, getNumMotors, getPositionRelativeTo, getPositionRelativeTo, getReferenceOdometry, getRelativePosition, getRelativeVelocity, getTurnRate, getVelocityRelativeTo, getXPosition, getXVelocity, getYPosition, getYVelocity, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, holonomicDrive_Polar, isAntiTippingEnabled, isGyroAssistEnabled, isStalled, isSynchronizeOdometriesEnabled, popReferenceOdometry, printMotorsState, pushReferenceOdometry, resetOdometry, resetOdometry, resetOdometry, setBrakeMode, setDriveBaseOdometry, setDriveBaseOdometry, setDriveBaseOdometry, setDriveOrientation, setDriveTime, setFieldPosition, setFieldPosition, setGyroAssistEnabled, setInvertedMotor, setMotorPowerMapper, setOdometryEnabled, setOdometryEnabled, setOdometryScales, setOdometryScales, setOdometryScales, setReferenceOdometry, setSensitivity, setStallVelocityThreshold, setSynchronizeOdometriesEnabled, stop, stop, supportsHolonomicDrive, tankDrive, tankDrive, tankDrive, tankDrive, tankDrive
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface trclib.robotcore.TrcExclusiveSubsystem
acquireExclusiveAccess, acquireOwnership, cancelExclusiveAccess, getCurrentOwner, hasOwnership, releaseExclusiveAccess, releaseOwnership, validateOwnership
-
Field Details
-
moduleName
-
lfMotor
-
rfMotor
-
lbMotor
-
rbMotor
-
lcMotor
-
rcMotor
-
-
Constructor Details
-
TrcSimpleDriveBase
public TrcSimpleDriveBase(TrcMotor lfMotor, TrcMotor lcMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rcMotor, TrcMotor rbMotor, TrcGyro gyro) Constructor: Create an instance of a 6-wheel drive base.- Parameters:
lfMotor
- specifies the left front motor of the drive base.lcMotor
- specifies the left center motor of a 6-wheel drive base.lbMotor
- specifies the left back motor of the drive base.rfMotor
- specifies the right front motor of the drive base.rcMotor
- specifies the right center motor of a 6-wheel drive base.rbMotor
- specifies the right back motor of the drive base.gyro
- specifies the gyro. If none, it can be set to null.
-
TrcSimpleDriveBase
public TrcSimpleDriveBase(TrcMotor lfMotor, TrcMotor lcMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rcMotor, TrcMotor rbMotor) Constructor: Create an instance of a 6-wheel drive base.- Parameters:
lfMotor
- specifies the left front motor of the drive base.lcMotor
- specifies the left center motor of a 6-wheel drive base.lbMotor
- specifies the left back motor of the drive base.rfMotor
- specifies the right front motor of the drive base.rcMotor
- specifies the right center motor of a 6-wheel drive base.rbMotor
- specifies the right back motor of the drive base.
-
TrcSimpleDriveBase
public TrcSimpleDriveBase(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor, TrcGyro gyro) Constructor: Create an instance of a 4-wheel drive base.- Parameters:
lfMotor
- specifies the left front motor of the drive base.lbMotor
- specifies the left back motor of the drive base.rfMotor
- specifies the right front motor of the drive base.rbMotor
- specifies the right back motor of the drive base.gyro
- specifies the gyro. If none, it can be set to null.
-
TrcSimpleDriveBase
Constructor: Create an instance of a 4-wheel drive base.- Parameters:
lfMotor
- specifies the left front motor of the drive base.lbMotor
- specifies the left back motor of the drive base.rfMotor
- specifies the right front motor of the drive base.rbMotor
- specifies the right back motor of the drive base.
-
TrcSimpleDriveBase
Constructor: Create an instance of a 2-wheel drive base.- Parameters:
leftMotor
- specifies the left motor of the drive base.rightMotor
- specifies the right motor of the drive base.gyro
- specifies the gyro. If none, it can be set to null.
-
TrcSimpleDriveBase
Constructor: Create an instance of a 2-wheel drive base.- Parameters:
leftMotor
- specifies the left motor of the drive base.rightMotor
- specifies the right motor of the drive base.
-
-
Method Details
-
setWheelBaseWidth
public void setWheelBaseWidth(double width) This method sets the wheel base width of the robot drive base.- Parameters:
width
- specifies the wheel base width.
-
setInvertedMotor
This method inverts direction of a given motor in the drive train.- Parameters:
motorType
- specifies the motor in the drive train.inverted
- specifies true if inverting motor direction.
-
tankDrive
public void tankDrive(String owner, double leftPower, double rightPower, boolean inverted, double driveTime, TrcEvent event) This method implements tank drive where leftPower controls the left motors and right power controls the right motors.- Specified by:
tankDrive
in classTrcDriveBase
- Parameters:
owner
- specifies the ID string of the caller for checking ownership, can be null if caller is not ownership aware.leftPower
- specifies left power value.rightPower
- specifies right power value.inverted
- specifies true to invert control (i.e. robot front becomes robot back).driveTime
- specifies the amount of time in seconds after which the drive base will stop.event
- specifies the event to signal when driveTime has expired, can be null if not provided.
-
getOdometryDelta
protected TrcDriveBase.Odometry getOdometryDelta(TrcOdometrySensor.Odometry[] prevOdometries, TrcOdometrySensor.Odometry[] currOdometries) This method is called periodically to calculate the delta between the previous and current motor odometries.- Specified by:
getOdometryDelta
in classTrcDriveBase
- Parameters:
prevOdometries
- specifies the previous motor odometries.currOdometries
- specifies the current motor odometries.- Returns:
- an Odometry object describing the odometry changes since the last update.
-