Package trclib.archive
Class CmdWaltzTurn
java.lang.Object
trclib.archive.CmdWaltzTurn
- All Implemented Interfaces:
TrcRobot.RobotCommand
This class implements a waltz turn command sequence. It is useful for avoiding a pushing match with our
opponent. If our opponent is trying to engage a pushing match with us, the driver can push a button and
cause the robot to pivot left or right 180 degrees and continue on with the robot driving in reverse.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final TrcDashboard
private final TrcDriveBase
private boolean
private final TrcEvent
private final TrcPidDrive
private TrcPidDrive.TurnMode
private final TrcStateMachine<CmdWaltzTurn.State>
private final TrcDbgTrace
-
Constructor Summary
ConstructorsConstructorDescriptionCmdWaltzTurn
(TrcDriveBase driveBase, TrcPidDrive pidDrive) 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.void
start
(boolean clockwiseTurn, boolean driveInverted) This method is called to start the command sequence doing a clockwise or counter-clockwise waltz turn.
-
Field Details
-
dashboard
-
tracer
-
driveBase
-
pidDrive
-
event
-
sm
-
prevTurnMode
-
clockwiseTurn
private boolean clockwiseTurn -
driveInverted
private boolean driveInverted
-
-
Constructor Details
-
CmdWaltzTurn
Constructor: Create an instance of the object.- Parameters:
driveBase
- specifies the drive base object.pidDrive
- specifies the PID drive object to be used for PID controlled drive.
-
-
Method Details
-
start
public void start(boolean clockwiseTurn, boolean driveInverted) This method is called to start the command sequence doing a clockwise or counter-clockwise waltz turn.- Parameters:
clockwiseTurn
- specifies true for a clockwise turn, false for counter-clockwise turn.driveInverted
- specifies the current inverted drive state of the robot.
-
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.
-