Package trclib.command
Class CmdPurePursuitDrive
java.lang.Object
trclib.command.CmdPurePursuitDrive
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final double
private static final double
private static final double
private final TrcEvent
private final TrcPurePursuitDrive
-
Constructor Summary
ConstructorsConstructorDescriptionCmdPurePursuitDrive
(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.CmdPurePursuitDrive
(TrcDriveBase driveBase, TrcPidController.PidCoefficients xPosPidCoeff, TrcPidController.PidCoefficients yPosPidCoeff, TrcPidController.PidCoefficients turnPidCoeff, TrcPidController.PidCoefficients velPidCoeff) 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
This method starts the Pure Pursuit drive with the specified poses in the drive path.void
This method starts the Pure Pursuit drive with the specified poses in the drive path.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.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.void
This method starts the Pure Pursuit drive with the specified poses read either from the built-in resources or from a file.void
This method starts the Pure Pursuit drive with the specified poses in the drive path.void
This method starts the Pure Pursuit drive with the specified drive path.void
This method starts the Pure Pursuit drive with the specified drive path.void
This method starts the Pure Pursuit drive with the specified drive path.void
This method starts the Pure Pursuit drive with the specified drive path.
-
Field Details
-
DEF_FOLLOWING_DISTANCE
private static final double DEF_FOLLOWING_DISTANCE- See Also:
-
DEF_POS_TOLERANCE
private static final double DEF_POS_TOLERANCE- See Also:
-
DEF_TURN_TOLERANCE
private static final double DEF_TURN_TOLERANCE- See Also:
-
purePursuitDrive
-
event
-
-
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 toleranceturnTolerance
- 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
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
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
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
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
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
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
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 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.
-