Class DriveWrapper
- All Implemented Interfaces:
Drive
public class DriveWrapper extends java.lang.Object implements Drive
- 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
The wrapper's drivetrain. -
driveSwapXY
private final boolean driveSwapXYShould X and Y transformations be swapped? -
driveInvertX
private final boolean driveInvertXShould transformational X values be swapped? -
driveInvertY
private final boolean driveInvertYShould transformational Y values be swapped?
-
-
Constructor Details
-
DriveWrapper
Create a new drive wrapper.- Parameters:
drive
- theDrive
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
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. -
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 interfaceDrive
-
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 interfaceDrive
-