Create controller to follow set of waypoints
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
DesiredLinearVelocity properties to update the velocities based on 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.
Starting in R2016b, instead of using the
to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For
y = step(obj,x) and
y = obj(x) perform
To compute linear and angular velocity control commands:
controllerPurePursuit object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
a pure pursuit object that uses the pure pursuit algorithm to compute the linear and
angular velocity inputs for a differential drive vehicle.
controller = controllerPurePursuit
creates a pure pursuit object with additional options specified by one or more
controller = controllerPurePursuit(Name,Value)
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.
controller = controllerPurePursuit('DesiredLinearVelocity', 0.5)
DesiredLinearVelocity— Desired constant linear velocity
0.1(default) | scalar in meters per second
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.
LookaheadDistance— Look-ahead distance
1.0(default) | scalar in meters
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.
MaxAngularVelocity— Maximum angular velocity
1.0(default) | scalar in radians per second
Maximum angular velocity, specified a scalar in radians per second. The controller saturates the absolute angular velocity output at the given value.
Waypoints, specified as an n-by-2 array of
y] pairs, where n is the number of waypoints. You can
generate the waypoints from the
mobileRobotPRM (Robotics System Toolbox) class or from another
pose— Position and orientation of vehicle
[x y theta]
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
vel— Linear velocity
Linear velocity, specified as a scalar in meters per second.
angvel— Angular velocity
Angular velocity, specified as a scalar in radians per second.
lookaheadpoint— Look-ahead point on path
Look-ahead point on the path, returned as an
[x y] vector. This
value is calculated based on the
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
info method to get more information about a
controllerPurePursuit object. The
info function returns two fields,
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.
pp = controllerPurePursuit;
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]
Usage notes and limitations:
Use in a MATLAB Function block is not supported.
For additional information about code generation for System objects, see System Objects in MATLAB Code Generation (MATLAB Coder)