0
$\begingroup$

I am trying to translate controller diagram of fixed wing px4 attitude control into mathematical form. While going through the controller diagram Fixed-Wing Attitude Controller looking into PX4 github code for pitch control Ref I found the following output,

 _last_output = _bodyrate_setpoint * _k_ff * ctl_data.scaler +
                _rate_error * _k_p * ctl_data.scaler * ctl_data.scaler
                + _integrator;  //scaler is proportional to 1/airspeed

For understanding, I am keeping scaler as one and lateral states as zero. so last output which is elevator deflection looks following.

_last_output = (ctl_data.pitch_setpoint - ctl_data.pitch )*_k_ff  +((ctl_data.pitch_setpoint - ctl_data.pitch) - ctl_data.body_y_rate) * _k_p  + integral((ctl_data.pitch_setpoint - ctl_data.pitch)*dt);

My doubt is if we want to pitch up, (pitch_setpoint-pitch) will be positive, and with all gain values being positive in PX4 controller, RHS is positive, but conventionally we give negative elevator deflection for pitch up. How is this taken care in the PX4 firmware? Can anyone explain or give a clearer picture of how this is possible? I may not be able to format the question very well but I have drawn a similar scenario in the picture attached. Simple pitch feedback loop

$\endgroup$
2
  • $\begingroup$ What sort of vehicle will this autopilot be used for - is it a UAV, a manned aircraft, a quadcopter, or what? $\endgroup$
    – Ralph J
    Jun 1 at 16:41
  • 1
    $\begingroup$ Welcome to aviation stackexchange. While I answered your question, I would like to point out that drones.stackexchange might be a better place to ask these kind of questions, as this a drone autpilot. $\endgroup$
    – U_flow
    Jun 1 at 21:31

1 Answer 1

0
$\begingroup$

Normally deflections of control surfaces are defined such that if they are positive, they generate positive forces which result in negative angular rates. (Except for ailerons which generate differential forces. For consistency they also generate negative rates)

Therefore:

  • A positive elevator deflection generates a negative pitch rate (nose goes down)
  • A positive rudder deflection generates a negative yaw rate (nose goes to the left)
  • A positive aileron deflection generates a negative roll rate (aircraft rolls to the left)

This is in most cases the sign convention for control deflections.

I want to point out that this necessitates a sign flip for a standard PID loop as in your case. For PX4 autopilots a parameter exists which can flip the servo output of a given control channel for exactly this reason. This can be done for example via the QGC software.

$\endgroup$
2
  • $\begingroup$ So, does this sign flip always happen in PX4 if pitch setpoint is more than current pitch? Is it done after the "_last_output" variable is generated? If you could clarify a bit more. $\endgroup$ Jun 2 at 5:00
  • $\begingroup$ If and when the sign flip has to happen, mainly depends of how you installed the servo motor in your aircraft. However, you can reverse the output via the PWM_MAIN_REV parameter. If you want to learn more about how the _last_output variable is propagated through the system, consider this help page docs.px4.io/main/en/concept/architecture.html#flight-stack . But the sign flip is not dependent on the output of the pid loop. It is either configured or not. $\endgroup$
    – U_flow
    Jun 3 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .