Class CmdPurePursuitDrive

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

public class CmdPurePursuitDrive extends Object implements TrcRobot.RobotCommand
This class implements a generic Pure Pursuit Drive command. It allows the caller to specify the drive path by calling start with an array of Waypoint poses.
  • Field Details

  • Constructor Details

    • CmdPurePursuitDrive

      public CmdPurePursuitDrive(TrcDriveBase driveBase, double followingDistance, double posTolerance, double turnTolerance, TrcPidController.PidCoefficients xPosPidCoeff, TrcPidController.PidCoefficients yPosPidCoeff, TrcPidController.PidCoefficients turnPidCoeff, TrcPidController.PidCoefficients velPidCoeff)
      Constructor: Create an instance of the object.
      Parameters:
      driveBase - specifies the drive base object.
      followingDistance - specifies the following distance.
      posTolerance - specifies the position tolerance
      turnTolerance - specifies the turn tolerance.
      xPosPidCoeff - specifies the PID coefficients for X position PID controller.
      yPosPidCoeff - specifies the PID coefficients for Y position PID controller.
      turnPidCoeff - specifies the PID coefficients for turn PID controller.
      velPidCoeff - specifies the PID coefficients for velocity PID controller.
    • CmdPurePursuitDrive

      public CmdPurePursuitDrive(TrcDriveBase driveBase, TrcPidController.PidCoefficients xPosPidCoeff, TrcPidController.PidCoefficients yPosPidCoeff, TrcPidController.PidCoefficients turnPidCoeff, TrcPidController.PidCoefficients velPidCoeff)
      Constructor: Create an instance of the object.
      Parameters:
      driveBase - specifies the drive base object.
      xPosPidCoeff - specifies the PID coefficients for X position PID controller.
      yPosPidCoeff - specifies the PID coefficients for Y position PID controller.
      turnPidCoeff - specifies the PID coefficients for turn PID controller.
      velPidCoeff - specifies the PID coefficients for velocity PID controller.
  • Method Details

    • start

      public void start(TrcPath path, double timeout, Double maxVel, Double maxAccel)
      This method starts the Pure Pursuit drive with the specified drive path.
      Parameters:
      path - specifies the drive path with waypoints.
      timeout - specifies the maximum time allowed for this operation.
      maxVel - specifies the maximum velocity if applying trapezoid velocity profile, null if not.
      maxAccel - specifies the maximum acceleration if applying trapezoid velocity profile, null if not.
    • start

      public void start(TrcPath path, Double maxVel, Double maxAccel)
      This method starts the Pure Pursuit drive with the specified drive path.
      Parameters:
      path - specifies the drive path with waypoints.
      maxVel - specifies the maximum velocity if applying trapezoid velocity profile, null if not.
      maxAccel - specifies the maximum acceleration if applying trapezoid velocity profile, null if not.
    • start

      public void start(TrcPath path, double timeout)
      This method starts the Pure Pursuit drive with the specified drive path.
      Parameters:
      path - specifies the drive path with waypoints.
      timeout - specifies the maximum time allowed for this operation.
    • start

      public void start(TrcPath path)
      This method starts the Pure Pursuit drive with the specified drive path.
      Parameters:
      path - specifies the drive path with waypoints.
    • start

      public void start(double timeout, boolean incrementalPath, Double maxVel, Double maxAccel, Double maxDecel, TrcPose2D... poses)
      This method starts the Pure Pursuit drive with the specified poses in the drive path.
      Parameters:
      timeout - specifies the maximum time allowed for this operation.
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      maxVel - specifies the maximum velocity if applying trapezoid velocity profile, null if not.
      maxAccel - specifies the maximum acceleration if applying trapezoid velocity profile, null if not.
      poses - specifies an array of waypoint poses in the drive path.
    • start

      public void start(double timeout, boolean incrementalPath, Double maxVel, Double maxAccel, Double maxDecel, String path, boolean loadFromResources)
      This method starts the Pure Pursuit drive with the specified poses read either from the built-in resources or from a file.
      Parameters:
      timeout - specifies the maximum time allowed for this operation.
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      maxVel - specifies the maximum velocity if applying trapezoid velocity profile, null if not.
      maxAccel - specifies the maximum acceleration if applying trapezoid velocity profile, null if not.
      maxDecel - specifies the maximum deceleration if applying trapezoid velocity profile, null if not.
      path - specifies the file system path or resource name.
      loadFromResources - specifies true if the data is from attached resources, false if from file system.
    • start

      public void start(double timeout, boolean incrementalPath, String path, boolean loadFromResources)
      This method starts the Pure Pursuit drive with the specified poses read either from the built-in resources or from a file.
      Parameters:
      timeout - specifies the maximum time allowed for this operation.
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      path - specifies the file system path or resource name.
      loadFromResources - specifies true if the data is from attached resources, false if from file system.
    • start

      public void start(boolean incrementalPath, Double maxVel, Double maxAccel, Double maxDecel, TrcPose2D... poses)
      This method starts the Pure Pursuit drive with the specified poses in the drive path.
      Parameters:
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      maxVel - specifies the maximum velocity if applying trapezoid velocity profile, null if not.
      maxAccel - specifies the maximum acceleration if applying trapezoid velocity profile, null if not.
      maxDecel - specifies the maximum deceleration if applying trapezoid velocity profile, null if not.
      poses - specifies an array of waypoint poses in the drive path.
    • start

      public void start(double timeout, boolean incrementalPath, TrcPose2D... poses)
      This method starts the Pure Pursuit drive with the specified poses in the drive path.
      Parameters:
      timeout - specifies the maximum time allowed for this operation.
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      poses - specifies an array of waypoint poses in the drive path.
    • start

      public void start(boolean incrementalPath, TrcPose2D... poses)
      This method starts the Pure Pursuit drive with the specified poses in the drive path.
      Parameters:
      incrementalPath - specifies true if appending point is relative to the previous point in the path, false if appending point is in the same reference frame as startingPose.
      poses - specifies an array of waypoint poses in the drive 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.