Loiter Mode

Loiter Mode automatically attempts to maintain the current location, heading and altitude. The pilot may fly the copter in Loiter mode as if it were in a more manual flight mode but when the sticks are released, the vehicle will slow to a stop and hold position.

A good GPS lock, low magnetic interference on the compass and low vibrations are all important in achieving good loiter performance.

Controls

The pilot can control the copter’s position with the control sticks.

  • Horizontal location can be adjusted with the the Roll and Pitch control sticks with the default maximum horizontal speed being 5m/s (see Tuning section below on how to adjust this). When the pilot releases the sticks the copter will slow to a stop.
  • Altitude can be controlled with the Throttle control stick just as in AltHold mode
  • The heading can be set with the Yaw control stick

The vehicle can be armed in Loiter mode but only once the GPS has 3D lock and the HDOP has dropped below 2.0. More details on LED patterns here.

Tuning

../_images/Loiter_Tuning.png

Loiter mode incorporates the altitude controller from AltHold mode. Details for tuning AltHold are on this wiki page.

For Copter-3.6 (and higher)

  • LOIT_SPEED : max horizontal speed in cm/s (i.e. 1250 = 12.5m/s)
  • LOIT_ACC_MAX : max acceleration in cm/s/s. Higher values cause the copter to accelerate and stop more quickly
  • LOIT_ANG_MAX : max lean angle in centi-degrees (i.e. 3000 = 30deg). By default this value is zero which causes the ANGLE_MAX parameter’s value to be used
  • LOIT_BRK_ACCEL: max acceleration in cm/s/s while braking (i.e. pilot has moved sticks to center). Higher values will stop the vehicle more quickly
  • LOIT_BRK_DELAY: the delay in seconds before braking starts once the pilot has centered the sticks
  • LOIT_BRK_JERK: max change in acceleration in cm/s/s/s while braking. Higher numbers will make the vehicle reach the maximum braking angle more quickly, lower numbers will cause smoother braking
  • PSC_POSXY_P : (shown as “Position XY (Dist to Speed)” at the top right of the screen shot above) converts the horizontal position error (i.e difference between the desired position and the actual position) to a desired speed towards the target position. It is generally not required to adjust this
  • PSC_VELXY_P (shown as “Velocity XY (Vel to Accel)”) converts the desired speed towards the target to a desired acceleration. The resulting desired acceleration becomes a lean angle which is then passed to the same angular controller used by Stabilize mode. It is generally not required to adjust this

For Copter-3.5 (and lower)

  • WPNAV_LOIT_SPEED <WPNAV_LOIT_SPEED> : max horizontal speed in cm/s. I.e. 500 = 5m/s. By default, the maximum acceleration is 1/2 of the Loiter speed (i.e. 2.5m/s/s).
  • WPNAV_LOIT_MAXA <WPNAV_LOIT_MAXA> : max acceleration in cm/s/s. Higher values cause the copter to accelerate and stop more quickly.
  • WPNAV_LOIT_MINA <WPNAV_LOIT_MINA> : min acceleration in cm/s/s. Higher values stop the copter more quickly when the stick is centered, but cause a larger jerk when the copter stops.
  • WPNAV_LOIT_JERK <WPNAV_LOIT_JERK>: max change in acceleration in cm/s/s/s. Higher numbers will make the vehicle more responsive, lower numbers will make it smoother.
  • POS_XY_P <POS_XY_P> : (shown as “Position XY (Dist to Speed)” at the top right of the screen shot above) converts the horizontal position error (i.e difference between the desired position and the actual position) to a desired speed towards the target position. It is generally not required to adjust this.
  • VEL_XY_P <VEL_XY_P> (shown as “Rate Loiter P, I and D”) converts the desired speed towards the target to a desired acceleration. The resulting desired acceleration becomes a lean angle which is then passed to the same angular controller used by Stabilize mode. It is generally not required to adjust this.

Common Problems

  1. When using Copter-3.5 (or lower) the vehicle slows to a stop very slowly after the pilot releases the sticks (aka “freight train stop”). This can be resolved by increasing WPNAV_LOIT_MAXA <WPNAV_LOIT_MAXA> (to perhaps 500), WPNAV_LOIT_MINA <WPNAV_LOIT_MINA> (to perhaps 100) and WPNAV_LOIT_JERK <WPNAV_LOIT_JERK> (to perhaps 4000).
  2. The vehicle circles (aka “toiletbowls”). This is normally caused by a compass problem the most likely being magnetic interference from the power cables under the flight controller. Running compassmot or purchasing a GPS+compass module normal resolves this. Other possibilities include bad compass offsets set during the live calibration process or incorrect compass orientation.
  3. The vehicle takes off in the wrong direction as soon as loiter is engaged. The cause is the same as #2 except that the compass error is greater than 90deg. Please try the suggestions above to resolve this.
  4. The vehicle is loitering normally and then suddenly takes off in the wrong direction. This is generally caused by a GPS Glitch. There is no 100% reliable protection against these which means the pilot should always be ready to take-over manual control. Beyond that ensuring a good GPS HDOP before take-off is always good and it may help to reduce the GPSGLITCH_RADIUS and/or GPSGLITCH_ACCEL parameters (see GPS glitch wiki page for details) to tighten up on the glitch detection.

Display HDOP on Mission Planner

The HDOP value can be made clearly visible through the mission planner’s Quick screen by double clicking and then selecting “gpshdop” from the large grid of checkboxes.

../_images/Loiter_DisplayHDOP.jpg

Verifying Loiter performance with dataflash logs

Viewing the loiter’s horizontal performance is best done by downloading a dataflash log from your flight, then open it with the mission planner and graph the NTUN message’s DesVelX vs VelX and DesVelY vs VelY. In a good performing copter the actual velocities will track the desired velocities as shown below. X = latitude (so positive = moving North, negative = South), Y = longitude (positive = East, negative = West).

../_images/Loiter_TuningCheck.png

Checking altitude hold performance is the same as for AltHold mode.

OF_LOITER Mode (Deprecated)

OF_LOITER has been deprecated. In older version of Copter (i.e. 3.2.1 and earlier) it was a special version of Loiter mode used the Optical Flow device to maintain position. Newer versions of Copter (3.3.3 and higher) use the PX4Flow sensor in regular Loiter.