Class TrcHolonomicPurePursuitDriveV2
A path consists of an array of waypoints, specifying position, velocity, and optionally heading. All other properties of the TrcWaypoint object may be ignored.The path may be low resolution, as this automatically interpolates between waypoints. If you want the robot to maintain heading, call setMaintainHeading(true) and it will ignore all the heading values. Otherwise, call setMaintainHeading(false), ensure that the heading tolerance and pid coefficients are set, and it will follow the heading values specified by the path.
A somewhat similar idea is here: ... or ...
Note that this paper is for non-holonomic robots. This means that all the turning radius stuff isn't very relevant. Technically, we could impose limits on the turning radius as a function of robot velocity and max rot vel, but that's unnecessarily complicated, in my view. Additionally, it does point injection instead of interpolation, and path smoothing, which we don't do, since a nonzero proximity radius will naturally smooth it anyway.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcHolonomicPurePursuitDriveV2
(String instanceName, TrcDriveBase driveBase, double proximityRadius, double posTolerance, double turnTolerance, double velTolerance, TrcPidController.PidCoefficients turnPidCoeff, TrcPidController.PidCoefficients velPidCoeff, double accelFF) Constructor: Create an instance of the object.TrcHolonomicPurePursuitDriveV2
(String instanceName, TrcDriveBase driveBase, double proximityRadius, double posTolerance, double velTolerance, TrcPidController.PidCoefficients velPidCoeff, double accelFF) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
If the controller is currently active, cancel the path following operation.boolean
isActive()
Checks if the robot is currently following a path.void
setMoveOutputLimit
(double limit) Sets the movement output power limit.void
setPositionTolerance
(double posTolerance) Set the position tolerance to end the path.void
setPositionToleranceAndProximityRadius
(double posTolerance, double proximityRadius) Set both the position tolerance and proximity radius.void
setProximityRadius
(double proximityRadius) Set the proximity radius for the pure pursuit controller.void
setRotOutputLimit
(double limit) Sets the rotation output power limit.void
setTraceLevel
(TrcDbgTrace.MsgLevel msgLevel, boolean logRobotPoseEvents, boolean tracePidInfo, boolean verbosePidInfo) This method sets the trace level for logging trace messages.void
setTraceLevel
(TrcDbgTrace.MsgLevel msgLevel, boolean logRobotPoseEvents, boolean tracePidInfo, boolean verbosePidInfo, TrcRobotBattery battery) This method sets the trace level for logging trace messages.void
setTurnPidCoefficients
(TrcPidController.PidCoefficients pidCoefficients) Sets the pid coefficients for the turn controller.void
setTurnTolerance
(double turnTolerance) Set the turn tolerance to end the path.void
setVelocityPidCoefficients
(TrcPidController.PidCoefficients pidCoefficients) Sets the pid coefficients for the position controller.void
setVelTolerance
(double velTolerance) Set the velocity tolerance.void
Start following the supplied path using a pure pursuit controller.void
Start following the supplied path using a pure pursuit controller.void
Start following the supplied path using a pure pursuit controller.void
This method starts the Pure Pursuit drive with the specified poses in the drive path.void
start
(TrcEvent onFinishedEvent, double timeout, TrcPose2D startingPose, boolean incrementalPath, TrcPose2D... poses) This method starts the Pure Pursuit drive with the specified poses in the drive path.void
start
(TrcEvent onFinishedEvent, TrcPose2D startingPose, boolean incrementalPath, TrcPose2D... poses) This method starts the Pure Pursuit drive with the specified poses in the drive path.toString()
This method returns the instance name.
-
Field Details
-
tracer
-
-
Constructor Details
-
TrcHolonomicPurePursuitDriveV2
public TrcHolonomicPurePursuitDriveV2(String instanceName, TrcDriveBase driveBase, double proximityRadius, double posTolerance, double turnTolerance, double velTolerance, TrcPidController.PidCoefficients turnPidCoeff, TrcPidController.PidCoefficients velPidCoeff, double accelFF) Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.driveBase
- specifies the reference to the drive base.proximityRadius
- specifies the distance between the robot and next following point.posTolerance
- specifies the position tolerance.turnTolerance
- specifies the turn tolerance.velTolerance
- specifies the velocity tolerance.turnPidCoeff
- specifies the turn PID coefficients.velPidCoeff
- specifies the velocity PID coefficients.accelFF
- specifies the acceleration Feed Forward value.
-
TrcHolonomicPurePursuitDriveV2
public TrcHolonomicPurePursuitDriveV2(String instanceName, TrcDriveBase driveBase, double proximityRadius, double posTolerance, double velTolerance, TrcPidController.PidCoefficients velPidCoeff, double accelFF) Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.driveBase
- specifies the reference to the drive base.proximityRadius
- specifies the distance between the robot and next following point.posTolerance
- specifies the position tolerance.velTolerance
- specifies the velocity tolerance.velPidCoeff
- specifies the velocity PID coefficients.accelFF
- specifies the acceleration Feed Forward value.
-
-
Method Details
-
toString
This method returns the instance name. -
setTraceLevel
public void setTraceLevel(TrcDbgTrace.MsgLevel msgLevel, boolean logRobotPoseEvents, boolean tracePidInfo, boolean verbosePidInfo, TrcRobotBattery battery) This method sets the trace level for logging trace messages.- Parameters:
msgLevel
- specifies the message level.logRobotPoseEvents
- specifies true to log robot pose events, false otherwise.tracePidInfo
- specifies true to enable tracing of PID info, false otherwise.verbosePidInfo
- specifies true to trace verbose PID info, false otherwise.battery
- specifies the battery object to get battery info for the message.
-
setTraceLevel
public void setTraceLevel(TrcDbgTrace.MsgLevel msgLevel, boolean logRobotPoseEvents, boolean tracePidInfo, boolean verbosePidInfo) This method sets the trace level for logging trace messages.- Parameters:
msgLevel
- specifies the message level.logRobotPoseEvents
- specifies true to log robot pose events, false otherwise.tracePidInfo
- specifies true to enable tracing of PID info, false otherwise.verbosePidInfo
- specifies true to trace verbose PID info, false otherwise.
-
setTurnTolerance
public void setTurnTolerance(double turnTolerance) Set the turn tolerance to end the path. Units need to be consistent.- Parameters:
turnTolerance
- The angle error at which the controller will stop itself.
-
setVelTolerance
public void setVelTolerance(double velTolerance) Set the velocity tolerance. The velocity must be less than this value for the controller to finish.- Parameters:
velTolerance
- Positive velocity.
-
setPositionToleranceAndProximityRadius
public void setPositionToleranceAndProximityRadius(double posTolerance, double proximityRadius) Set both the position tolerance and proximity radius.- Parameters:
posTolerance
- specifies the distance at which the controller will stop itself.proximityRadius
- specifies the distance between the robot and next following point.
-
setPositionTolerance
public void setPositionTolerance(double posTolerance) Set the position tolerance to end the path. Units need to be consistent.- Parameters:
posTolerance
- The distance at which the controller will stop itself.
-
setProximityRadius
public void setProximityRadius(double proximityRadius) Set the proximity radius for the pure pursuit controller.- Parameters:
proximityRadius
- specifies the distance between the robot and next following point.
-
setTurnPidCoefficients
Sets the pid coefficients for the turn controller. This will work in the middle of an operation as well.- Parameters:
pidCoefficients
- The new PID coefficients for the heading controller.
-
setVelocityPidCoefficients
Sets the pid coefficients for the position controller. This will work in the middle of an operation as well. Note that velocity controllers should have an F term as well.- Parameters:
pidCoefficients
- The new PIDF coefficients for the velocity controller.
-
setMoveOutputLimit
public void setMoveOutputLimit(double limit) Sets the movement output power limit.- Parameters:
limit
- specifies the output power limit for movement (X and Y).
-
setRotOutputLimit
public void setRotOutputLimit(double limit) Sets the rotation output power limit.- Parameters:
limit
- specifies the output power limit for rotation.
-
start
Start following the supplied path using a pure pursuit controller. The velocity must always be positive, and the path must start at (0,0). Heading is absolute and position is relative in the starting robot reference frame.- Parameters:
path
- The path to follow. Must start at (0,0).onFinishedEvent
- When finished, signal this event.timeout
- Number of seconds after which to cancel this operation. 0.0 for no timeout.
-
start
Start following the supplied path using a pure pursuit controller. The velocity must always be positive, and the path must start at (0,0). Heading is absolute and position is relative in the starting robot reference frame.- Parameters:
path
- The path to follow. Must start at (0,0).onFinishedEvent
- When finished, signal this event.
-
start
Start following the supplied path using a pure pursuit controller.- Parameters:
path
- The path to follow. Must start at (0,0). Velocity is per second.
-
start
public void start(TrcEvent onFinishedEvent, double timeout, TrcPose2D startingPose, boolean incrementalPath, TrcPose2D... poses) This method starts the Pure Pursuit drive with the specified poses in the drive path.- Parameters:
onFinishedEvent
- When finished, signal this event.timeout
- specifies the maximum time allowed for this operation, 0.0 for no timeout.startingPose
- specifies the starting pose at the beginning of the path.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(TrcEvent onFinishedEvent, TrcPose2D startingPose, boolean incrementalPath, TrcPose2D... poses) This method starts the Pure Pursuit drive with the specified poses in the drive path.- Parameters:
onFinishedEvent
- When finished, signal this event.startingPose
- specifies the starting pose at the beginning of the path.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:
startingPose
- specifies the starting pose at the beginning of the path.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()Checks if the robot is currently following a path.- Returns:
- True if the pure pursuit controller is active, false otherwise.
-
cancel
public void cancel()If the controller is currently active, cancel the path following operation. Otherwise, do nothing. If there is an event to signal, mark it as cancelled.
-