MAVLINKHUD

Overview

The XTRACK parameter group defines the limits for Crosstrack Error management. "Crosstrack" is the perpendicular distance from the vehicle to the planned mission line.

Key Concepts

1. Error Limits (XTRACK_MAX)

Defines the maximum allowed distance (meters) the vehicle can deviate from the path before the autopilot considers the mission "Invalid" or takes emergency action (e.g., stopping or circling).

2. Correction Angle (XTRACK_ANG_LIM)

(Sub/Plane) Limits the angle at which the vehicle is allowed to turn towards the path to correct an error.

  • Purpose: Prevents the vehicle from turning 90 degrees to the path, which could cause a stall or unstable behavior.

Developer Notes

  • Library: libraries/AP_L1_Control.

XTRACK_ANG_LIM

deg
Default 45
Range 10 90

Crosstrack correction angle limit (XTRACK_ANG_LIM)

Description

This parameter sets the maximum angle the vehicle (Submarine) is allowed to turn towards the track line to correct for crosstrack error. A higher value allows for more aggressive course corrections to return to the path quickly, while a lower value results in smoother, shallower intercept trajectories. This is crucial for towed systems or vehicles with high inertia to prevent oscillation around the track.

The Mathematics

The navigation controller limits the heading error correction demand:

$$ \theta\_{error} = \text{Target Bearing} - \text{Current Heading} $$
$$ |\theta\_{correction}| \le \text{XTRACK\_ANG\_LIM} $$

The Engineer's View

Defined in ArduSub/Parameters.cpp. This value is used by the WPNav library (specifically the crosstrack error controller) to clamp the output angle. It prevents the vehicle from turning 90 degrees to the track, which can be undesirable for ROVs with tethers.

Tuning & Behavior

  • Default Value: 45 deg
  • Range: 10 - 90
  • Effect of Increasing: Faster return to track, potential for "S-turning" or oscillation.
  • Effect of Decreasing: Smoother, slower return to track. Better for stability.

XTRACK_MAX

m
Default 10
Range 5 25

Sailing vehicle max cross track error (XTRACK_MAX)

Description

This parameter defines the width of the "Sailing Corridor" for autonomous sailboats. When sailing upwind (into the wind), the boat must zigzag (tack) to reach its destination.

XTRACK_MAX sets the maximum allowable distance the boat can drift from the direct line to the waypoint before it is forced to tack (turn 90 degrees) to get back on course.

The Mathematics

This parameter effectively creates a virtual hallway of width $2 \times XTRACK\_MAX$ centered on the line between the previous and next waypoint.

$$ \text{Trigger Tack IF: } |CrossTrackError| \ge XTRACK\_MAX $$

The logic also checks the wind direction to ensure the tack will actually reduce the error (i.e., turning towards the center line, not away).

The Engineer's View

In Sailboat::calc_heading() (Rover/sailboat.cpp):

  1. The function computes cross_track_error using the navigation library.
  2. It checks if ((fabsf(cross_track_error) >= xtrack_max) && ....
  3. If triggered, should_tack becomes true.
  4. If the boat is on Starboard tack and error is positive (right side of corridor), it tacks to Port.
  5. If on Port tack and error is negative (left side of corridor), it tacks to Starboard.

Tuning & Behavior

  • Default Value: 10 meters
  • Range: 5 to 25 meters
  • Effect of Increasing: The boat will tack less frequently, making longer legs. This is generally more efficient as tacking slows the boat down.
  • Effect of Decreasing: The boat will stay very close to the direct path, tacking frequently. This is useful in narrow channels but inefficient in open water.
  • 0: Disables auto-tacking based on crosstrack error.