Waypoint Follower
Follow waypoints for UAV

Libraries:
      UAV Toolbox / 
      Algorithms
   
Description
The Waypoint Follower block generates a lookahead point, desired course, desired yaw, and cross track. The block accepts a UAV pose, a set of waypoints and a lookahead distance.
Specify the UAV type parameter to select your UAV type. Use the StartFrom parameter to specify the waypoint start behaviour. Specify the Transition radius source parameter to select between a uniform and varying transition radius for each waypoint.
Examples
Approximate High-Fidelity UAV Model with UAV Guidance Model Block
Prototype and tune a waypoint following navigation system by using a reduced-order model for UAV.
Tuning Waypoint Following Controller for Fixed-Wing UAV
Design and tune a waypoint following controller for a fixed-wing UAV by using the Guidance Model and Waypoint Follower blocks.
Ports
Input
Current UAV pose, specified as a [x y z chi] vector. This pose
              is used to calculate the lookahead point based on the input to the
                LookaheadDistance port. [x y z] is the
              current position in meters. chi is the current course in radians.
              The course input is used only when the waypoints are empty. The UAV course is the
              angle of direction of the velocity vector relative to north measured in
              radians.
Example: 
              [0.5;1.75;-2.5;pi]
Data Types: single | double
Set of waypoints for the UAV to follow, specified as a matrix with number of rows, n, equal to the number of waypoints. The number of columns depend on the Show Yaw input variable and the Transition radius source parameter.
Each row in the matrix has the first three elements as an [x y
                z] position in the sequence of waypoints.
If Show Yaw input variable is checked, specify the desired
              yaw angle, yaw, as the fourth element in radians.
If Show Yaw input variable is unchecked, and
                Transition radius source is external, the
              transition radius is the fourth element of the vector in meters.
If Show Yaw input variable is checked, and
                Transition radius source is external, the
              transition radius is the fifth element of the vector in meters.
The block display updates as the size of the waypoint matrix changes.
Data Types: single | double
Lookahead distance along the path, specified as a positive numeric scalar in meters.
Data Types: single | double
Output
Lookahead point on path, returned as an [x y z] position vector
              in meters.
Data Types: single | double
Desired course, returned as numeric scalar in radians in the range of
                [-pi, pi]. The UAV course is the angle of direction of the
              velocity vector relative to north measured in radians. For fixed-wing type UAV, the
              values of desired course and desired yaw are equal.
Data Types: single | double
Desired yaw, returned as numeric scalar in radians in the range of [-pi,
                pi]. The UAV yaw is the forward direction of the UAV regardless of the
              velocity vector relative to north measured in radians. The desired yaw is computed
              using linear interpolation between the yaw angle for each waypoint. For fixed-wing
              type UAV, the values of desired course and desired yaw are equal.
Data Types: single | double
Lookahead distance flag, returned as 0 or 1.
                0 indicates lookahead distance is not saturated,
                1 indicates lookahead distance is saturated to minimum lookahead
              distance value specified.
Data Types: uint8
Cross track error from UAV position to path, returned as a positive numeric scalar in meters. The error measures the perpendicular distance from the UAV position to the closest point on the path.
Dependencies
This port is only visible if Show CrossTrackError output port is checked.
Data Types: single | double
Status of waypoint navigation, returned as 0 or
                1. When the follower has navigated all waypoints, the block
              outputs 1. Otherwise, the block outputs
              0.
Dependencies
This port is only visible if Show UAV Status output port is checked.
Data Types: uint8
Parameters
Type of UAV, specified as either fixed-wing or
              multirotor.
This parameter is non-tunable.
Waypoint start behavior, specified as either first or
              closest. 
When set to first, the UAV flies to the first path segment
            between waypoints. If the set of waypoints input in Waypoints
            changes, the UAV restarts at the first path segment.
When set to closest, the UAV flies to the closest path segment
            between waypoints. When the waypoints input changes, the UAV recalculates the closest
            path segment.
This parameter is non-tunable.
Source of transition radius, specified as either internal or
              external. If specified as internal, the
            transition radius for each waypoint is set using the Transition radius
              (r) parameter in the block mask. If specified as
              external, specify each waypoints transition radius independently
            using the input from the Waypoints port.
When the UAV is within the transition radius, the block transitions to following the next path segment between waypoints.
This parameter is non-tunable.
Transition radius for waypoints, specified as a positive numeric scalar in meters.
When the UAV is within the transition radius, the block transitions to following the next path segment between waypoints.
This parameter is non-tunable.
Minimum lookahead distance, specified as a positive numeric scalar in meters.
When input to the LookaheadDistance port is less than the
            minimum lookahead distance, the LookaheadDistFlag is returned as
              1 and the lookahead distance value is specified as the  value of
            minimum lookahead distance.
This parameter is non-tunable.
The location of Lookahead point at the end of waypoint navigation. If enabled, the lookahead point remains stationary at the last waypoint. If disabled, the lookahead point continues to traverse the straight-line path connecting the last two waypoints.
This parameter is non-tunable.
Dependencies
To enable this parameter, set UAV type to
                multirotor
Accept yaw inputs for waypoints when selected. If selected, the Waypoints input accepts yaw inputs for each waypoint.
Output cross track error from the CrossTrackError port.
This parameter is non-tunable.
Output UAV waypoint status from the Status port.
This parameter is non-tunable.
- Interpreted execution— Simulate model using the MATLAB® interpreter. This option shortens startup time but has a slower simulation speed than- Code generation. In this mode, you can debug the source code of the block.
- Code generation— Simulate model using generated C code. The first time you run a simulation, Simulink® generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time but the speed of the subsequent simulations is comparable to- Interpreted execution.
This parameter is non-tunable.
Tunable: No
More About
When following a set of waypoints, the waypoint follower may ignore the first waypoint depending on the pose of the UAV. Each consecutive pair of waypoints forms a path segment, and the waypoint follower transitions to the next path segment if the UAV position satisfies at least one of these conditions:
- The UAV is inside the transition region of the waypoint at the end of a segment. 
- The UAV is inside the 3D hyperplane region of the waypoint at the end of a segment 
This behavior helps to ensure the UAV follows an achievable path.

The hyperplane condition is satisfied if:
(p-w1)T (w2-w1) ≥ 0
p is the UAV position, and w1 and w2 are sequential waypoint positions.
If you find this behavior limiting, consider adding more waypoints based on your initial pose to force the follower to navigate towards your initial waypoint.
References
[1] Park, Sanghyuk, John Deyst, and Jonathan How. "A New Nonlinear Guidance Logic for Trajectory Tracking." AIAA Guidance, Navigation, and Control Conference and Exhibit, 2004.
Extended Capabilities
C/C++ Code Generation
 Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2018bYou can now configure the lookahead point to remain stationary at the final waypoint by
        enabling the Hover at last waypoint parameter. This parameter is only
        available when you set UAV Type as
        multirotor.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

