Main Content

controllerPurePursuit

Create controller to follow set of waypoints

Description

The controllerPurePursuit System object™ creates a controller object used to make a differential-drive vehicle follow a set of waypoints. The object computes the linear and angular velocities for the vehicle given the current pose. Successive calls to the object with updated poses provide updated velocity commands for the vehicle. Use the MaxAngularVelocity and DesiredLinearVelocity properties to update the velocities based on the vehicle's performance.

The LookaheadDistance property computes a look-ahead point on the path, which is a local goal for the vehicle. The angular velocity command is computed based on this point. Changing LookaheadDistance has a significant impact on the performance of the algorithm. A higher look-ahead distance results in a smoother trajectory for the vehicle, but can cause the vehicle to cut corners along the path. A low look-ahead distance can result in oscillations in tracking the path, causing unstable behavior. For more information on the pure pursuit algorithm, see Pure Pursuit Controller.

To compute linear and angular velocity control commands:

  1. Create the controllerPurePursuit object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

controller = controllerPurePursuit creates a pure pursuit object that uses the pure pursuit algorithm to compute the linear and angular velocity inputs for a differential drive vehicle.

example

controller = controllerPurePursuit(Name,Value) creates a pure pursuit object with additional options specified by one or more Name,Value pairs. Name is the property name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN. Properties not specified retain their default values.

Example: controller = controllerPurePursuit('DesiredLinearVelocity', 0.5)

Properties

expand all

Desired constant linear velocity, specified as a scalar in meters per second. The controller assumes that the vehicle drives at a constant linear velocity and that the computed angular velocity is independent of the linear velocity.

Data Types: double

Look-ahead distance, specified as a scalar in meters. The look-ahead distance changes the response of the controller. A vehicle with a higher look-ahead distance produces smooth paths but takes larger turns at corners. A vehicle with a smaller look-ahead distance follows the path closely and takes sharp turns, but potentially creating oscillations in the path.

Data Types: double

Maximum angular velocity, specified a scalar in radians per second. The controller saturates the absolute angular velocity output at the given value.

Data Types: double

Waypoints, specified as an n-by-2 array of [x y] pairs, where n is the number of waypoints. You can generate the waypoints from the mobileRobotPRM (Robotics System Toolbox) class or from another source.

Data Types: double

Usage

Description

[vel,angvel] = controller(pose) processes the vehicle's position and orientation, pose, and outputs the linear velocity, vel, and angular velocity, angvel.

example

[vel,angvel,lookaheadpoint] = controller(pose) returns the look-ahead point, which is a location on the path used to compute the velocity commands. This location on the path is computed using the LookaheadDistance property on the controller object.

Input Arguments

expand all

Position and orientation of vehicle, specified as a 3-by-1 vector in the form [x y theta]. The vehicle pose is an x and y position with angular orientation θ (in radians) measured from the x-axis.

Output Arguments

expand all

Linear velocity, specified as a scalar in meters per second.

Data Types: double

Angular velocity, specified as a scalar in radians per second.

Data Types: double

Look-ahead point on the path, returned as an [x y] vector. This value is calculated based on the LookaheadDistance property.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

infoCharacteristic information about controllerPurePursuit object
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Use the info method to get more information about a controllerPurePursuit object. The info function returns two fields, RobotPose and LookaheadPoint, which correspond to the current position and orientation of the robot and the point on the path used to compute outputs from the last call of the object.

Create a controllerPurePursuit object.

pp = controllerPurePursuit;

Assign waypoints.

pp.Waypoints = [0 0;1 1];

Compute control commands using the pp object with the initial pose [x y theta] given as the input.

[v,w] = pp([0 0 0]);

Get additional information.

s = info(pp)
s = struct with fields:
         RobotPose: [0 0 0]
    LookaheadPoint: [0.7071 0.7071]

Extended Capabilities

Version History

Introduced in R2019b