Package org.hyperonline.hyperlib.driving
Class ArcadeDriveParams
- java.lang.Object
-
- org.hyperonline.hyperlib.driving.ArcadeDriveParams
-
- All Implemented Interfaces:
DriveParameters
public class ArcadeDriveParams extends java.lang.Object implements DriveParameters
A class which represents arcade drive. Arcade drive uses two values: move and rotate. Move determines forwards-and-backwards motion, while rotate determines rotational motion. This drive mode is useful for writing autonomous methods which attempt to track a target, or hold a gyro angle. It can also be used to drive directly from the joystick. This class simply wrapsDifferentialDrive.arcadeDrive(double, double, boolean)
. This class is immutable. That means you must construct a new instance each time you want to change the power to the drivetrain.
-
-
Constructor Summary
Constructors Constructor Description ArcadeDriveParams(double move, double rotate, boolean squareInputs)
Construct a newArcadeDriveParams
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drive(edu.wpi.first.wpilibj.drive.DifferentialDrive driveTrain, double currentGyro)
Drive the robot.double
move()
Get the move parameterdouble
rotate()
Get the rotate parameterboolean
squareInputs()
Get the squareInputs parameter
-
-
-
Constructor Detail
-
ArcadeDriveParams
public ArcadeDriveParams(double move, double rotate, boolean squareInputs)
Construct a newArcadeDriveParams
.- Parameters:
move
- The amount to move forwards or backwardsrotate
- The amount to rotatesquareInputs
- Whether to square the inputs. This is desirable if the input is coming from a joystick, as it creates a "soft deadzone". If coming from another source, like a PID controller, this should befalse
.
-
-
Method Detail
-
drive
public void drive(edu.wpi.first.wpilibj.drive.DifferentialDrive driveTrain, double currentGyro)
Drive the robot. This method should not call any "stateful" methods of the drivetrain (anything that starts with "set") to allow one to switch between modes easily. TODO: pass a wrapper of DifferentialDrive, which only allows certain methods TODO: remove currentGyro. This is pretty irrelevant, and can be obtained in other ways.- Specified by:
drive
in interfaceDriveParameters
- Parameters:
driveTrain
- ADifferentialDrive
object representing the drivetrain of the robot.currentGyro
- The current gyro heading, if a gyro exists. Nothing should use this right now, so just pass in 0.0 if you're not sure.
-
move
public double move()
Get the move parameter- Returns:
- the move parameter
-
rotate
public double rotate()
Get the rotate parameter- Returns:
- the rotate parameter
-
squareInputs
public boolean squareInputs()
Get the squareInputs parameter- Returns:
- the squareInputs parameter
-
-