Class CmdPidDrive

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

public class CmdPidDrive extends Object implements TrcRobot.RobotCommand
This class implements a generic PID control drive command. It is agnostic to the PID controller sensors. The caller provides the PID drive object that has all PID controllers which means the caller controls what sensors are controlling the X, Y and turn PID controllers. For example, the caller can provide a PID drive object that uses the encoders to control the X and Y PID controllers and a gyro for the turn PID controller. The caller can also use the encoders to control the X and Y PID controllers but a camera to control the turn PID controller.
  • Constructor Details

    • CmdPidDrive

      public CmdPidDrive(TrcDriveBase driveBase, TrcPidDrive pidDrive, boolean useSensorOdometry)
      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.
      useSensorOdometry - specifies true to use the sensor odometry, false to use drive base odometry.
    • CmdPidDrive

      public CmdPidDrive(TrcDriveBase driveBase, TrcPidDrive pidDrive)
      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(double delay, double drivePowerLimit, TrcPidController.PidCoefficients tunePidCoeff, TrcPose2D... pathPoints)
      This method starts the specified PID drive run.
      Parameters:
      delay - specifies delay in seconds before PID drive starts. 0 means no delay.
      drivePowerLimit - specifies the power limit to be applied for the PID controlled drive.
      tunePidCoeff - specifies PID coefficients for tuning PID controllers, can be null if not in tune mode.
      pathPoints - specifies one or more points on the path.
    • 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.