Class CmdTimedDrive

java.lang.Object
trclib.command.CmdTimedDrive
All Implemented Interfaces:
TrcRobot.RobotCommand

public class CmdTimedDrive extends Object implements 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.
  • Field Details

    • dashboard

      private final TrcDashboard dashboard
    • tracer

      private final TrcDbgTrace tracer
    • driveBase

      private final TrcDriveBase 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

      private final TrcEvent event
    • timer

      private final TrcTimer 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 interface TrcRobot.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 interface TrcRobot.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 interface TrcRobot.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.