px4官网调参指南 多旋翼无人机PID调参指南
譯文部分:
多旋翼無人機PID調參指南
不用碳化纖維或增強碳化纖維槳調整多軸,不使用損壞的槳片。
出于安全考慮,系統默認增益都設置的比較小。請增加增益以便獲取更好的控制響應。
本指導方案適用于所有的多軸飛行器。比例,積分,微分控制(PID)是最廣泛的控制技術。對于典型的預估性控制而言,PID控制實質上優于執行性控制技術,比如,線性二次型調節器(Linear Quadratic Regulator) 與線性二次高斯(linear quadratic gaussian),因為這些技術都或多或少的需要系統的精確模型,所以得不到廣泛的使用。PX4的目的是在個人電腦上實現設備的盡可能快速的控制,因為不是所有的被控對象的系統模型都是可獲得的,因此PID調參是非常有意義的,并且PID控制適用于所有情況。
介紹
PX4采用雙閉環PID控制,其外環為角度(angle)控制,角度值是由濾波與姿態解算后得到的歐拉角,有延遲且存在誤差,所以單純的單閉環無法實現姿態控制過程。所以需要引入內環,內環選擇角速度(rate)控制,角速度由陀螺儀直接測量得到,誤差小,響應快,延遲短。所以,綜上,整個控制系統外環選擇純比例控制,沒有I,D,所以參數只有三個方向的P;內環選擇PID控制器,參數有P,I,D三個量;同時方向控制上還引入了前饋控制,所以還有一個參數為MC_YAW_FF
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps4638.tmp.jpg
PX4地面站外環執行的飛行器角度控制 ,依靠的參數有:
Roll control (MC_ROLL_P)
Pitch control (MC_PITCH_P)
Yaw control (MC_YAW_P)
內環使用三個獨立的PID控制器實現飛行器姿態控制:
Roll rate control (MC_ROLLRATE_P, MC_ROLLRATE_I, MC_ROLLRATE_D)
Pitch rate control (MC_PITCHRATE_P, MC_PITCHRATE_I, MC_PITCHRATE_D)
Yaw rate control (MC_YAWRATE_P, MC_YAWRATE_I, MC_YAWRATE_D)
外環輸出以機身期望姿態比例為準(如果機身期望姿態為水平狀態但是當前橫滾方向有三十度的傾角,那么此時控制器將以每次60度輸出)。內環速率控制改變電機轉速以便飛行器以期望角速率旋轉。
實質上增益具有直觀的物理意義,比如,如果參數MC_ROLL_P增益為6,那么飛行器將以3弧度(170度)補償0.5弧度(30度)的偏差。如果內環MC_ROLLRATE_P增益為0.1,那么內環輸出為3乘0.1=0.3(外環輸出輸入給內環,進過PID控制后輸出,若只有P=0.1,輸入3,那么輸出0.3)這意味著飛行器將降低一側電機的轉速,增加另一側電機的轉速使其恢復水平狀態。
同樣的,對于MC_YAW_FF參數,用于控制多大的用戶輸入用于前饋補償給偏航速率控制器。0意味著非常慢的控制。控制器只能在檢測到偏航位置誤差時才開始修正。1意味著快速的響應,但是有超調,控制將執行的非常快速,誤差總是保持在0附近。
電機幅值限制
正如上面的例子所展示的,在某些情況下會出現某種可能使得電機得到一個比其上限還要大的輸入或者一個比0還要小的輸入。如果這種情況發生,電機違背控制模型產生的升力可能會使飛行器翻筋斗。為了防止這種情況發生,PX4中加入了油門限幅。如果其中一個電機的轉速偏離安全范圍,系統總體推力將被變低以便控制器輸出的相關比率達到一個期望值。其結果會是電機轉速不會增加甚至降低,但是永遠不會翻。
第一步 準備
首先設置所有參數到初始值。
1 設置所有的MC_XXX_P到0(roll,pitch,yaw)
2 除了MC_ROLLRATE_P與MC_PITCHRATE_P之外的所有MC_XXXRATE_P,I,D歸零。
3 設置MC_ROLLRATE_P與MC_PITCHRATE_P到一個很小的值,比如0.02
4 設置MC_YAW_FF到0.5
所有參數緩慢增加,每次增加約百分之20到30,在最后調試時甚至可以降低到百分之10,。
注意:過大的增益(甚至僅僅比理想值多1.5到2倍)都可能導致大的抖動。
第二步 穩定俯仰和翻滾速率
P增益調節
參數:MC_ROLLRATE_P, MC_PITCHRATE_P
如果飛行器結構對稱,那么ROLL與PITCH的概念應該等價,如果不對稱,則應該分開討論。
把飛行器拿在手中,中油門上下,到剛好平衡重力。向俯仰或翻滾方向上稍做傾斜,觀察反應。(我不明白這個是怎么實現的,用手托著吧,飛行器平穩時升力最大,不會飛起來,那么有偏角了升力減小,更不會飛起來。但是這也太危險了吧,建議用細繩拉住兩顆電機,不要用手)飛行器應該溫和的抵抗傾斜過程,但保持傾斜角之后不會嘗試恢復水平姿態。如果出現震蕩,降低P。如果反應正確但非常慢,調大P直到開始出現抖動。重新調回P到稍稍有一點抖動甚至不再抖動(大概回調百分之十),到稍稍超調,典型值一般為0.1。
D增益調節
參數:MC_ROLLRATE_D, MC_PITCHRATE_D
如果參數處于某一值時,飛行器稍微抖動并且P值已經適量的減少。從0.01開始緩慢增加RATE_D直到消除最后一點震蕩。如果此時飛行器又一次出現抖動,那就是D值過大。(一定會出現由抖動到平穩的過程,D值再大才會再次抖動,所以調參是不能著急,一點點增加,不然可能錯過理想值)一般通過調節P與D就可以得到比較良好的電機響應。RATE_D的典型值一般在0.01–0.02
在QGoundControl可以鎖定pitch與roll的速率。一定不能出現震蕩,但是百分之十到二十的超調是允許的。
I增益調節
如果飛行器可以實現定點但是定點的位置與期望存在誤差,那么增加MC_ROLLRATE_I 和MC_PITCHRATE_I(上面一句的翻譯是個人想法,原句是never reach the setpoint but have an offset。我覺得它的意思是實現了懸停,但是此時的點不是想要的點,所以說,按照個人想法,I值并沒有什么用處,我不會在乎懸停之后的誤差)以增益MC_ROLLRATE_P的值得百分之五到百分之十開始向上增加。
第三步 穩定翻滾與俯仰角度
參數 MC_RATE_P, MC_RATE_P
把飛行器拿在手中,中油門上下,到剛好平衡重力。向俯仰或翻滾方向上稍做傾斜,觀察反應。飛行器應該緩慢回到水平。如果出現抖動,減小P。如果反應正確但非常慢,調大P直到開始出現抖動。最佳的反應應該是超調10%–20%后得到良好的響應。
在QGoundControl可以鎖定pitch與roll。姿態角度超調不要超過10%–20%.
第四步 穩定航向速率
P增益調節
參數:MC_YAWRATE_P
設置很小的MC_YAWRATE_P,比如0.1。
把飛行器拿在手中,中油門上下,到剛好平衡重力。轉動飛行器方向軸,觀察反應。電機聲音應該發生改變,飛行器應該阻礙方向變化。但是這個響應應該弱于俯仰與橫滾方向,這是正常現象。如果飛行器出現抖動,減小MC_YAWRATE_P。如果響應非常劇烈甚至在小幅轉動(full throttle spinning vs idle spinning propellers不懂這句什么意思),減小P。典型值大概為0.2–0.3。(四軸因為其結構,導致航向上的不靈敏,yaw-p要小于pitch與roll)
在航向的速率控制中,如果響應非常強烈或出現震蕩,會影響俯仰和橫滾方向的響應。統籌調節pitch,roll,yaw達到平衡。
第五步 穩定航向角
把飛行器拿在手中,中油門上下,到剛好平衡重力。轉動飛行器方向軸,觀察反應。飛行器應該緩慢的回到初始方向。如果飛行器出現抖動,減小P。當響應正確但速度慢,增加P直到反應達到穩定,但不要出現震蕩。典型值大概為2–3。
在QGoundControl觀察ATTITUDE.yaw。超調不應該超過2%–5%.小于pitch與
Roll。(個人認為,航向上不用太較真啦,不影響另外兩個就好)
前饋補償調節
參數 MC_YAW_FF
這個參數不太重要,并且可以在飛行過程中調節。但是不理想的參數會使響應變慢或過快。應該調節MC_YAW_FF使飛行器得到良好的響應過程。其有效范圍0–1,典型值大概為0.8–0.9。(有時為了航拍效果考慮,可以再改小MC_YAW_FF,以便得到平滑的響應過程)
在QGoundControl觀察ATTITUDE.yaw。超調不應該超過2%–5%.小于pitch與
Roll。
外文部分:
Multirotor PID Tuning Guide
NEVER do multirotor tuning with carbon fiber or carbon fiber reinforced blades. NEVER use damaged blades.
For SAFETY reason, the default gains are set to small value. You HAVE TO increase the gains before you can expect any control responses.
This tutorial is valid for all multi rotor setups (AR.Drone, PWM Quads / Hexa / Octo setups). Proportional, Integral, Derivative controllers are the most widespread control technique. There are substantially better performing control techniques (LQR/LQG) from the model predictive control, since these techniques require a more or less accurate model of the system, they not as widely used. The goal of all PX4 control infrastructure is move as soon as possible on MPC, since not for all supported systems models are available, PID tuning is very relevant (and PID control sufficient for many cases).
Introduction
The PX4 multirotor_att_control app executes an outer loop of orientation controller, controlled by parameters:
Roll control (MC_ROLL_P)
Pitch control (MC_PITCH_P)
Yaw control (MC_YAW_P)
And an inner loop with three independent PID controllers to control the attitude rates:
Roll rate control (MC_ROLLRATE_P, MC_ROLLRATE_I, MC_ROLLRATE_D)
Pitch rate control (MC_PITCHRATE_P, MC_PITCHRATE_I, MC_PITCHRATE_D)
Yaw rate control (MC_YAWRATE_P, MC_YAWRATE_I, MC_YAWRATE_D)
The outer loop’s output are desired body rates (e.g. if the multirotor should be level but currently has 30 degrees roll, the control output will be e.g. a rotation speed of 60 degrees per second). The inner rate control loop changes the rotor motor outputs so that the copter rotates with the desired angular speed.
The gains actually have an intuitive meaning, e.g.: if the MC_ROLL_P gain is 6.0, the copter will try to compensate 0.5 radian offset in attitude (~30 degrees) with 6 times the angular speed, i.e. 3 radians/s or ~170 degrees/s. Then if gain for the inner loop MC_ROLLRATE_P is 0.1 then thrust control output for roll will be 3 * 0.1 = 0.3. This means that it will lower the speed of rotors on one side by 30% and increase the speed on the other one to induce angular momentum in order to go back to level.
There is also MC_YAW_FF parameter that controls how much of user input need to feed forward to yaw rate controller. 0 means very slow control, controller will start to move yaw only when sees yaw position error, 1 means very responsive control, but with some overshot, controller will move yaw immediately, always keeping yaw error near zero.
Motor Band / Limiting
As the above example illustrates, under certain conditions it would be possible that one motor gets an input higher than its maximum speed and another gets an input lower than zero. If this happens, the forces created by the motors violate the control model and the multi rotor will likely flip. To prevent this, the multi rotor mixers on PX4 include a band-limit. If one of the rotors leaves this safety band, the total thrust of the system is lowered so that the relative percentage that the controller did output can be satisfied. As a result the multi rotor might not climb or loose altitude a bit, but it will never flip over. The same for lower side, even if commanded roll is large, it will be scaled to not exceed commanded summary thrust and copter will not flip on takeoff at near-zero thrust.
Step 1: Preparation
First of all set all parameters to initial values:
Set all MC_XXX_P to zero (ROLL, PITCH, YAW)
Set all MC_XXXRATE_P, MC_XXXRATE_I, MC_XXXRATE_D to zero, except MC_ROLLRATE_P and MC_PITCHRATE_P
Set MC_ROLLRATE_P and MC_PITCHRATE_P to a small value, e.g. 0.02
Set MC_YAW_FF to 0.5
All gains should be increased very slowly, by 20%-30% per iteration, and even 10% for final fine tuning. Note, that too large gain (even only 1.5-2 times more than optimal!) may cause very dangerous oscillations!
Step 2: Stabilize Roll and Pitch Rates
P Gain Tuning
Parameters: MC_ROLLRATE_P, MC_PITCHRATE_P.
If copter is symmetrical, then values for ROLL and PITCH should be equal, if not - then tune it separately.
Keep the multi rotor in your hand and increase the thrust to about 50%, so that the weight is virtually zero. Tilt it in roll or pitch direction, and observe the response. It should mildly fight the motion, but it will NOT try to go back to level. If it oscillates, tune down RATE_P. Once the control response is slow but correct, increase RATE_P until it starts to oscillate. Cut back RATE_P until it does only mildly oscillate or not oscillate any more (about 10% cutback), just over-shoots. Typical value is around 0.1.
D Gain Tuning
Parameters: MC_ROLLRATE_D, MC_PITCHRATE_D.
Assuming the gains are in a state where the multi rotor oscillated and RATE_P was slightly reduced. Slowly increase RATE_D, starting from 0.01. Increase RATE_D to stop the last bit of oscillation. If the motors become twitchy, the RATE_D is too large, cut it back. By playing with the magnitudes of RATE_P and RATE_D the response can be fine-tuned. Typical value is around 0.01…0.02.
In QGroundControl you can plot roll and pitch rates (ATTITUDE.rollspeed/pitchspeed). It must not oscillate, but some overshot (10-20%) is ok.
I Gain Tuning
If the roll and pitch rates never reach the setpoint but have an offset, add MC_ROLLRATE_I and MC_PITCHRATE_I gains, starting at 5-10% of the MC_ROLLRATE_P gain value.
Step 3: Stabilize Roll and Pitch Angles
P Gain Tuning
Parameters: MC_RATE_P, MC_RATE_P.
Set MC_ROLL_P and MC_PITCH_P to a small value, e.g. 3
Keep the multi rotor in your hand and increase the thrust to about 50%, so that the weight is virtually zero. Tilt it in roll or pitch direction, and observe the response. It should go slowly back to level. If it oscillates, tune down P. Once the control response is slow but correct, increase P until it starts to oscillate. Optimal responce is some overshot (~10-20%). After getting stable respone fine tune RATE_P, RATE_D again.
In QGroundControl you can plot roll and pitch (ATTITUDE.roll/pitch) and control (ctrl0, ctrl1). Attitude angles overshot should be not more than 10-20%.
Step 4: Stabilize Yaw Rate
P Gain Tuning
Parameters: MC_YAWRATE_P.
Set MC_YAWRATE_P to small value, e.g. 0.1
Keep the multi rotor in your hand and increase the thrust to about 50%, so that the weight is virtually zero. Turn it around its yaw axis, observe the response. The motor sound should change and the system should fight the yaw rotation. The response will be substantially weaker than roll and pitch, which is fine. If it oscillates or becomes twitchy, tune down RATE_P. If responce is very large even on small movements (full throttle spinning vs idle spinning propellers) reduce RATE_P. Typical value is around 0.2…0.3.
The yaw rate control, if very strong or oscillating, can deteriorate the roll and pitch response. Check the total response by turning around, roll, pitch and yaw.
Step 5: Stabilize Yaw Angle
P Gain Tuning
Parameters: MC_YAW_P.
Set MC_YAW_P to a low value, e.g. 1
Keep the multi rotor in your hand and increase the thrust to about 50%, so that the weight is virtually zero. Rotate it around yaw, and observe the response. It should go slowly back to the initial heading. If it oscillates, tune down P. Once the control response is slow but correct, increase P until the response is firm, but it does not oscillate. Typical value is around 2…3.
Look at ATTITUDE.yaw in QGroundControl. Yaw overshot should be not more than 2-5% (less than for attitude).
Feed Forward Tuning
Parameters: MC_YAW_FF.
This parameter is not critical and can be tuned in flight, in worst case yaw responce will be sluggish or too fast. Play with FF parameter to get comfortable responce. Valid range is 0…1. Typical value is 0.8…0.9. (For aerial video optimal value may be much smaller to get smooth responce.)
Look at ATTITUDE.yaw in QGroundControl. Yaw overshot should be not more than 2-5% (less than for attitude).
總結
以上是生活随笔為你收集整理的px4官网调参指南 多旋翼无人机PID调参指南的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第十章 PX4-Pixhawk-姿态控制
- 下一篇: Pixhawk-串级pid介绍