Class TrcMecanumDriveBase

All Implemented Interfaces:
TrcExclusiveSubsystem

public class TrcMecanumDriveBase extends TrcSimpleDriveBase
This class implements a platform independent mecanum drive base. A mecanum drive base consists of 4 motor driven wheels. It extends the TrcSimpleDriveBase class so it inherits all the SimpleDriveBase methods and features.
  • Field Details

    • moduleName

      private final String moduleName
  • Constructor Details

    • TrcMecanumDriveBase

      public TrcMecanumDriveBase(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor, TrcGyro gyro)
      Constructor: Create an instance of the 4-wheel mecanum 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.
    • TrcMecanumDriveBase

      public TrcMecanumDriveBase(TrcMotor lfMotor, TrcMotor lbMotor, TrcMotor rfMotor, TrcMotor rbMotor)
      Constructor: Create an instance of the 4-wheel mecanum 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.
  • Method Details

    • supportsHolonomicDrive

      public boolean supportsHolonomicDrive()
      This method checks if it supports holonomic drive.
      Overrides:
      supportsHolonomicDrive in class TrcDriveBase
      Returns:
      true if this drive base supports holonomic drive, false otherwise.
    • holonomicDrive

      public void holonomicDrive(String owner, double x, double y, double rotation, boolean inverted, double gyroAngle, double driveTime, TrcEvent event)
      This method implements holonomic drive where x controls how fast the robot will go in the x direction, and y controls how fast the robot will go in the y direction. Rotation controls how fast the robot rotates and gyroAngle specifies the heading the robot should maintain.
      Overrides:
      holonomicDrive in class TrcDriveBase
      Parameters:
      owner - specifies the ID string of the caller for checking ownership, can be null if caller is not ownership aware.
      x - specifies the x power.
      y - specifies the y power.
      rotation - specifies the rotating power.
      inverted - specifies true to invert control (i.e. robot front becomes robot back).
      gyroAngle - specifies the gyro angle to maintain.
      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.
      Overrides:
      getOdometryDelta in class TrcSimpleDriveBase
      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.