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 TrcDashboard
private final double
private final TrcDriveBase
private final double
private final TrcEvent
private final TrcStateMachine<CmdTimedDrive.State>
private final TrcTimer
private final TrcDbgTrace
private final double
private final double
private 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 TypeMethodDescriptionvoid
cancel()
This method cancels the command if it is active.boolean
cmdPeriodic
(double elapsedTime) This method must be called periodically by the caller to drive the command sequence forward.boolean
isActive()
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:
isActive
in 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:
cancel
in 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:
cmdPeriodic
in 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.
-