Tuning Controllers Using FlightPlot

This guide describes how to use FlightPlot to tune controller (altitude, position, attitude). FlightPlot is able to simulate behavor of multirotor (mass, controlled by propellers with some moment of inertia and with some latency) controlled by two (position and rate) PID controllers.

Multirotor Altitude Controller Tuning

First of all, parameters of mechanical system should be determined. The easiest way to do this is to make test flight with some safe (but maybe not perfect) parameters. Test pattern should be the following:

  • Takeoff, switch to SEATBELT and hold altitude few seconds
  • Rapidly move throttle stick to maximum, multirotor will climb up
  • After ~5m return throttle stick to center rapidly
  • Hold new altitude for few seconds
  • Land

In this short test all necessary data for tuning collected. Altitude should look like on the plot:

Note, that difference between altitude setpoint LPSP.Z and estimated altitude LPOS.Z can be ~1m, it's normal. Don't forget to set Scale to -1 to show downside Z as altitude. Offset can be ajusted to move initial altitude to zero (it will be useful for future steps).

We also need vertical speed for analysis, add it (don't forget to set Scale to -1):

Now add simulator. Simulator has a lot of parameters, but values for most of it match parameters values of FMU's controller.

  • Att Acc Scale - scale of simulated acceleration, not very useful now, set to 0.0 to disable
  • Ctrl D == MPC_Z_D - differencial gain for position PID controller
  • Ctrl Limit == MPC_Z_VEL_MAX - limit for position PID controller, i.e. limit for vertical speed
  • Ctrl P == MPC_Z_P - proportional gain for position PID controller, “desired vertical speed for 1m altitude error”
  • Ctrl Rate D == MPC_Z_VEL_D - differencial gain for rate PID controller
  • Ctrl Rate D SP == false - to match FMU's altitude controller
  • Ctrl Rate I == MPC_Z_VEL_I - integral gain for rate PID controller, how fast controller will adjust hovering throttle estimate
  • Ctrl Rate Limit == MPC_THR_MIN & MPC_THR_MAX - limit rate PID controller output. Note that “hovering output” for simulated controller is always 0.0, i.e. model not taking in account gravity, while in real controller it's non-zero hovering throttle. If (MPC_THR_MIN + MPC_THR_MAX) / 2 = hovering_throttle, then Ctrl Rate Limit should be set to (MPC_THR_MAX - MPC_THR_MIN) / 2. But actually, fine tuned altitude controller should not be saturated, and Ctrl Rate Limit can be set to 0.0 (disable limit) for first tests.
  • Ctrl Rate P == MPC_Z_VEL_P - proportional gain for rate PID controller, the most significant parameter for controller
  • Drag - simulated drag, drag_force = - Drag * velocity, depends on frame and can be estimated, start with value 0.5
  • Start SP - simulated setpoint movement, set to match test flight
  • Start SP Rate - simulated setpoint movement, set to match test flight, should be equal to MPC_Z_VEL_MAX if throttle stick moved to maximal value during flight test
  • Start Time - time when simulated setpoint movement should be started
  • Thrust Delay - delay caused by FMU+IO latency, for PX4FMUv1+PX4IO it's approx. 0.02s, can be estimated from test flight
  • Thrust K - acceleration/thrust coefficient, for copter with linear thrust responce should be approx. g/hovering_throttle, e.g. for copter with hovering throttle 0.5 it will be ~20.0, can be estimated from test flight
  • Thrust T - time constant for throttle responce, how much time copter need to spin up or slow down propellers, for 10'' props it should be ~0.01, depends on propeller size, motor etc., can be estimated from test flight
  • Use Rate SP - bypass position controller and set rate controller setpoint directly, useful for debug, should be false for now
Translations of this page:

Quick Links

QR Code: URL of current page