# Multicopter Setpoint Tuning (Trajectory Generator)

This document provides an overview of the multicopter tuning parameters that change the user experience: how fast the vehicle reacts to stick movements or direction changes in missions, the maximum allowed velocity, etc. (i.e. the parameters that affect the value of a desired setpoint rather than those that affect how well the vehicle tracks the setpoint). The algorithm that generates those setpoints is called a "trajectory generator".

This guide is for advanced users/experts.

Follow the instructions in the Multicopter PID Tuning Guide before doing any of the tuning described here. Do not use these tuning parameters to fix bad tracking or vibration!

## Overview

The input to the P/PID controller is a desired setpoint that the vehicle should attempt to track. PID Tuning ("Lower level" tuning) aims to reduce the error between the desired setpoint and the estimate of the vehicle state. Poor P/PID Gains can lead to instability.

The desired setpoint passed to the P/PID controller is itself calculated from a demanded setpoint based on a stick position (in RC modes) or from a mission command. Setpoint value ("higher level") tuning is used to specify the mapping between the demanded setpoint and the desired setpoint. Poorly tuned setpoint values cannot result in instability, but may result in either very jerky or very unresponsive reactions to setpoint changes.

The demanded setpoint can change very quickly (e.g. if a user moves stick from zero to maximum value as a "step"). Vehicle flight characteristics are better if the corresponding desired setpoint changes as a "ramp".

The setpoint-value tuning parameters can be split into two groups: tuning parameters for position mode and tuning parameters for mission mode. Some parameters will have an effect on both modes.

## Definitions

The position controller (diagram here) consists of an outer P position-control loop and an inner PID velocity-control loop. Depending on the control (flight) mode either both loops are active or just the velocity control loop.

For the remainder of this topic the term position-control represents the case where both loops are active while velocity-control refers to the case when only the velocity control loop is in use.

## Implementations

Two different implementations are available for each mode and can be selected using the parameters MPC_POS_MODE and MPC_AUTO_MODE.

• Slew-rate (MPC_POS_MODE=1, MPC_POS_MODE=2, MPC_AUTO_MODE=0) - Used when quick response is more important than smooth motion (e.g.: inspection, aggressive flight with position hold, fast missions).

• This is a simple implementation where the jerk and acceleration is limited using slew-rates.
• In manual mode, it allows asymmetric profiles based on user intention (smooth acceleration and quick stop).
• The jerk and acceleration limits are not hard constraints.
• Jerk-limited (MPC_POS_MODE=3, MPC_AUTO_MODE=1) - Used when smooth motion is required (e.g.: filming, mapping, cargo).

• Generates symmetric smooth S-curves where the jerk and acceleration limits are always guaranteed.

The jerk-limited (smooth) type is used by default for all frames in both manual and auto modes; this may not be suitable for vehicles/use-cases that require a faster response - e.g. racer quads.