Package trclib.command
Class CmdTimedDrive
java.lang.Object
trclib.command.CmdTimedDrive
- All Implemented Interfaces:
TrcRobot.RobotCommand
This class implements a generic timed drive command. The command drives the robot in the given direction
for the given amount of time.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TrcDashboardprivate final doubleprivate final TrcDriveBaseprivate final doubleprivate final TrcEventprivate final TrcStateMachine<CmdTimedDrive.State>private final TrcTimerprivate final TrcDbgTraceprivate final doubleprivate final doubleprivate final double -
Constructor Summary
ConstructorsConstructorDescriptionCmdTimedDrive(TrcDriveBase driveBase, double delay, double driveTime, double xDrivePower, double yDrivePower, double turnPower) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()This method cancels the command if it is active.booleancmdPeriodic(double elapsedTime) This method must be called periodically by the caller to drive the command sequence forward.booleanisActive()This method checks if the current RobotCommand is running.
-
Field Details
-
dashboard
-
tracer
-
driveBase
-
delay
private final double delay -
driveTime
private final double driveTime -
xDrivePower
private final double xDrivePower -
yDrivePower
private final double yDrivePower -
turnPower
private final double turnPower -
event
-
timer
-
sm
-
-
Constructor Details
-
CmdTimedDrive
public CmdTimedDrive(TrcDriveBase driveBase, double delay, double driveTime, double xDrivePower, double yDrivePower, double turnPower) Constructor: Create an instance of the object.- Parameters:
driveBase- specifies the drive base object.delay- specifies delay in seconds before timed drive starts. 0 means no delay.driveTime- specifies the amount of drive time in seconds.xDrivePower- specifies the motor power in the X direction.yDrivePower- specifies the motor power in the Y direction.turnPower- specifies the motor power for turning.
-
-
Method Details
-
isActive
public boolean isActive()This method checks if the current RobotCommand is running.- Specified by:
isActivein interfaceTrcRobot.RobotCommand- Returns:
- true if the command is running, false otherwise.
-
cancel
public void cancel()This method cancels the command if it is active.- Specified by:
cancelin interfaceTrcRobot.RobotCommand
-
cmdPeriodic
public boolean cmdPeriodic(double elapsedTime) This method must be called periodically by the caller to drive the command sequence forward.- Specified by:
cmdPeriodicin interfaceTrcRobot.RobotCommand- Parameters:
elapsedTime- specifies the elapsed time in seconds since the start of the robot mode.- Returns:
- true if the command sequence is completed, false otherwise.
-