Class DriveWrapper

java.lang.Object
me.wobblyyyy.pathfinder.robot.wrappers.DriveWrapper
All Implemented Interfaces:
Drive

public class DriveWrapper
extends java.lang.Object
implements Drive
Wrapper surrounding user-inputted drivetrains that's designed to allow users to invert the X or Y transform values that are fed to their drivetrains.
Since:
0.4.0
Author:
Colin Robertson
  • Field Summary

    Fields
    Modifier and Type Field Description
    private Drive drive
    The wrapper's drivetrain.
    private boolean driveInvertX
    Should transformational X values be swapped?
    private boolean driveInvertY
    Should transformational Y values be swapped?
    private boolean driveSwapXY
    Should X and Y transformations be swapped?
  • Constructor Summary

    Constructors
    Constructor Description
    DriveWrapper​(Drive drive, boolean driveSwapXY, boolean driveInvertX, boolean driveInvertY)
    Create a new drive wrapper.
  • Method Summary

    Modifier and Type Method Description
    void disableUserControl()
    Stop allowing the drivetrain to be controlled by a user.
    void drive​(RTransform transform)
    Drive the robot according to a specified transformation.
    void enableUserControl()
    Allow the drivetrain to be controlled by a user.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • drive

      private final Drive drive
      The wrapper's drivetrain.
    • driveSwapXY

      private final boolean driveSwapXY
      Should X and Y transformations be swapped?
    • driveInvertX

      private final boolean driveInvertX
      Should transformational X values be swapped?
    • driveInvertY

      private final boolean driveInvertY
      Should transformational Y values be swapped?
  • Constructor Details

    • DriveWrapper

      public DriveWrapper​(Drive drive, boolean driveSwapXY, boolean driveInvertX, boolean driveInvertY)
      Create a new drive wrapper.
      Parameters:
      drive - the Drive to use for the wrapper.
      driveSwapXY - should X and Y transforms be swapped?
      driveInvertX - should X transforms be inverted?
      driveInvertY - should Y transforms be inverted?
  • Method Details

    • drive

      public void drive​(RTransform transform)
      Drive the robot according to a specified transformation. Transformations are made up of several components, most notably X, Y, and angle. It's important to note that the angle component of these transformations represents the angle that the robot SHOULD be facing, not by how much the robot needs to turn.
      Specified by:
      drive in interface Drive
      Parameters:
      transform - the robot's desired transformation. It's important to note that this transformation's angle doesn't mean how much the robot should be turning, it means the angle that the robot should currently be facing.
    • enableUserControl

      public void enableUserControl()
      Allow the drivetrain to be controlled by a user.

      User control needs to be enabled in order for the user to actually control the robot manually, such as via a joystick. Although Pathfinder is pretty lovely, sometimes you need to control the robot.

      If this isn't implemented properly, you may see very funky things going on with the motors - spasms, for example. In order to counter this, it's a good idea to... well, actually implement this method properly.

      Specified by:
      enableUserControl in interface Drive
    • disableUserControl

      public void disableUserControl()
      Stop allowing the drivetrain to be controlled by a user.

      In order for Pathfinder to actually function, and in order for the user to not miserably mess up absolutely everything, user control needs to be disabled prior to controlling a motor.

      If this isn't implemented properly, you may see very funky things going on with the motors - spasms, for example. In order to counter this, it's a good idea to... well, actually implement this method properly.

      Specified by:
      disableUserControl in interface Drive