Class TrcSimpleDriveBase

java.lang.Object
trclib.drivebase.TrcDriveBase
trclib.drivebase.TrcSimpleDriveBase
All Implemented Interfaces:
TrcExclusiveSubsystem
Direct Known Subclasses:
TrcMecanumDriveBase, TrcSwerveDriveBase

public class TrcSimpleDriveBase extends TrcDriveBase
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.
  • Field Details

    • moduleName

      private final String moduleName
    • lfMotor

      protected final TrcMotor lfMotor
    • rfMotor

      protected final TrcMotor rfMotor
    • lbMotor

      protected final TrcMotor lbMotor
    • rbMotor

      protected final TrcMotor rbMotor
    • lcMotor

      protected final TrcMotor lcMotor
    • rcMotor

      protected final TrcMotor 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

      public TrcSimpleDriveBase(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor)
      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

      public TrcSimpleDriveBase(TrcMotor leftMotor, TrcMotor rightMotor, TrcGyro gyro)
      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

      public TrcSimpleDriveBase(TrcMotor leftMotor, TrcMotor rightMotor)
      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

      public void setInvertedMotor(TrcSimpleDriveBase.MotorType motorType, boolean inverted)
      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 class TrcDriveBase
      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 class TrcDriveBase
      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.