Autopilot airspeed scaling inconsistent?

In ecl attitude_fw 3 axis PID controller (eg: ecl github) I find the following code (~line 140)

/* Apply PI rate controller and store non-limited output */
_last_output = _bodyrate_setpoint * _k_ff * ctl_data.scaler +
	       _rate_error * _k_p * ctl_data.scaler * ctl_data.scaler
	       + integrator_constrained;  //scaler is proportional to 1/airspeed

It seems that the Kp term is scaled via airspeed^2 while Kff and Ki are only scaled using airspeed. (scaler = airspeed_trim/airspeed_current)

I think the scaling of airspeed^2 make sense to account dynamic pressure effects, so is Kff and KI scaling inconsistent or I am missing something?

Some background here. https://github.com/PX4/Firmware/issues/1267

It’s great to review this stuff. We should add more documentation to the controllers themselves.

Ok thanks! I’ll look into that.

Also, do you know if integrator reset is called during mode changes? (e.g. changing between manual flight and stabilized flight mode). At the moment, the code only resets the integrator in FixedwingPositionControl.cpp and only during takeoff and not mode switches.

No, I don’t believe it’s reset during mode changes. Then in manual the controllers aren’t even running.

Shouldn’t it reset during mode switches? If there is a long time between mode changes (e.g. stabilized -> manual -> stabilized), the integrator still contains previous accumulated error terms from the first stabilized flight segment which has probably no relation to the current stabilized flight segment.

I deal primarily with manual and stabilized mode (for my own implementation), I’m not sure if a integrator_reset affects other operation modes (e.g position_control etc).

Yes that sounds reasonable. Personally I don’t touch manual mode after everything is working. You could add a reset here. https://github.com/PX4/Firmware/blob/master/src/modules/fw_att_control/fw_att_control_main.cpp#L1197

Interested in making the change and opening a pull request?

Sure, but I wanted to understand more to make sure it doesn’t impact the rest of the flight modes.

I guess i can implement where you suggested to only cater to switching to and from manual flight mode.

Thanks again!

These ECL controllers in fw_att_control are always running and active except in manual mode. Right now pure manual mode happens to pass through the attitude controller, but should probably bypass it entirely. When switching between stabilized, altitude control, position, or full auto we don’t need to worry about the reset.