px4官网调参指南 多旋翼无人机PID调参指南
譯文部分:
多旋翼無人機(jī)PID調(diào)參指南
不用碳化纖維或增強(qiáng)碳化纖維槳調(diào)整多軸,不使用損壞的槳片。
出于安全考慮,系統(tǒng)默認(rèn)增益都設(shè)置的比較小。請?jiān)黾釉鲆嬉员惬@取更好的控制響應(yīng)。
本指導(dǎo)方案適用于所有的多軸飛行器。比例,積分,微分控制(PID)是最廣泛的控制技術(shù)。對于典型的預(yù)估性控制而言,PID控制實(shí)質(zhì)上優(yōu)于執(zhí)行性控制技術(shù),比如,線性二次型調(diào)節(jié)器(Linear Quadratic Regulator) 與線性二次高斯(linear quadratic gaussian),因?yàn)檫@些技術(shù)都或多或少的需要系統(tǒng)的精確模型,所以得不到廣泛的使用。PX4的目的是在個(gè)人電腦上實(shí)現(xiàn)設(shè)備的盡可能快速的控制,因?yàn)椴皇撬械谋豢貙ο蟮南到y(tǒng)模型都是可獲得的,因此PID調(diào)參是非常有意義的,并且PID控制適用于所有情況。
介紹
PX4采用雙閉環(huán)PID控制,其外環(huán)為角度(angle)控制,角度值是由濾波與姿態(tài)解算后得到的歐拉角,有延遲且存在誤差,所以單純的單閉環(huán)無法實(shí)現(xiàn)姿態(tài)控制過程。所以需要引入內(nèi)環(huán),內(nèi)環(huán)選擇角速度(rate)控制,角速度由陀螺儀直接測量得到,誤差小,響應(yīng)快,延遲短。所以,綜上,整個(gè)控制系統(tǒng)外環(huán)選擇純比例控制,沒有I,D,所以參數(shù)只有三個(gè)方向的P;內(nèi)環(huán)選擇PID控制器,參數(shù)有P,I,D三個(gè)量;同時(shí)方向控制上還引入了前饋控制,所以還有一個(gè)參數(shù)為MC_YAW_FF
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps4638.tmp.jpg
PX4地面站外環(huán)執(zhí)行的飛行器角度控制 ,依靠的參數(shù)有:
Roll control (MC_ROLL_P)
Pitch control (MC_PITCH_P)
Yaw control (MC_YAW_P)
內(nèi)環(huán)使用三個(gè)獨(dú)立的PID控制器實(shí)現(xiàn)飛行器姿態(tài)控制:
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)
外環(huán)輸出以機(jī)身期望姿態(tài)比例為準(zhǔn)(如果機(jī)身期望姿態(tài)為水平狀態(tài)但是當(dāng)前橫滾方向有三十度的傾角,那么此時(shí)控制器將以每次60度輸出)。內(nèi)環(huán)速率控制改變電機(jī)轉(zhuǎn)速以便飛行器以期望角速率旋轉(zhuǎn)。
實(shí)質(zhì)上增益具有直觀的物理意義,比如,如果參數(shù)MC_ROLL_P增益為6,那么飛行器將以3弧度(170度)補(bǔ)償0.5弧度(30度)的偏差。如果內(nèi)環(huán)MC_ROLLRATE_P增益為0.1,那么內(nèi)環(huán)輸出為3乘0.1=0.3(外環(huán)輸出輸入給內(nèi)環(huán),進(jìn)過PID控制后輸出,若只有P=0.1,輸入3,那么輸出0.3)這意味著飛行器將降低一側(cè)電機(jī)的轉(zhuǎn)速,增加另一側(cè)電機(jī)的轉(zhuǎn)速使其恢復(fù)水平狀態(tài)。
同樣的,對于MC_YAW_FF參數(shù),用于控制多大的用戶輸入用于前饋補(bǔ)償給偏航速率控制器。0意味著非常慢的控制。控制器只能在檢測到偏航位置誤差時(shí)才開始修正。1意味著快速的響應(yīng),但是有超調(diào),控制將執(zhí)行的非常快速,誤差總是保持在0附近。
電機(jī)幅值限制
正如上面的例子所展示的,在某些情況下會(huì)出現(xiàn)某種可能使得電機(jī)得到一個(gè)比其上限還要大的輸入或者一個(gè)比0還要小的輸入。如果這種情況發(fā)生,電機(jī)違背控制模型產(chǎn)生的升力可能會(huì)使飛行器翻筋斗。為了防止這種情況發(fā)生,PX4中加入了油門限幅。如果其中一個(gè)電機(jī)的轉(zhuǎn)速偏離安全范圍,系統(tǒng)總體推力將被變低以便控制器輸出的相關(guān)比率達(dá)到一個(gè)期望值。其結(jié)果會(huì)是電機(jī)轉(zhuǎn)速不會(huì)增加甚至降低,但是永遠(yuǎn)不會(huì)翻。
第一步 準(zhǔn)備
首先設(shè)置所有參數(shù)到初始值。
1 設(shè)置所有的MC_XXX_P到0(roll,pitch,yaw)
2 除了MC_ROLLRATE_P與MC_PITCHRATE_P之外的所有MC_XXXRATE_P,I,D歸零。
3 設(shè)置MC_ROLLRATE_P與MC_PITCHRATE_P到一個(gè)很小的值,比如0.02
4 設(shè)置MC_YAW_FF到0.5
所有參數(shù)緩慢增加,每次增加約百分之20到30,在最后調(diào)試時(shí)甚至可以降低到百分之10,。
注意:過大的增益(甚至僅僅比理想值多1.5到2倍)都可能導(dǎo)致大的抖動(dòng)。
第二步 穩(wěn)定俯仰和翻滾速率
P增益調(diào)節(jié)
參數(shù):MC_ROLLRATE_P, MC_PITCHRATE_P
如果飛行器結(jié)構(gòu)對稱,那么ROLL與PITCH的概念應(yīng)該等價(jià),如果不對稱,則應(yīng)該分開討論。
把飛行器拿在手中,中油門上下,到剛好平衡重力。向俯仰或翻滾方向上稍做傾斜,觀察反應(yīng)。(我不明白這個(gè)是怎么實(shí)現(xiàn)的,用手托著吧,飛行器平穩(wěn)時(shí)升力最大,不會(huì)飛起來,那么有偏角了升力減小,更不會(huì)飛起來。但是這也太危險(xiǎn)了吧,建議用細(xì)繩拉住兩顆電機(jī),不要用手)飛行器應(yīng)該溫和的抵抗傾斜過程,但保持傾斜角之后不會(huì)嘗試恢復(fù)水平姿態(tài)。如果出現(xiàn)震蕩,降低P。如果反應(yīng)正確但非常慢,調(diào)大P直到開始出現(xiàn)抖動(dòng)。重新調(diào)回P到稍稍有一點(diǎn)抖動(dòng)甚至不再抖動(dòng)(大概回調(diào)百分之十),到稍稍超調(diào),典型值一般為0.1。
D增益調(diào)節(jié)
參數(shù):MC_ROLLRATE_D, MC_PITCHRATE_D
如果參數(shù)處于某一值時(shí),飛行器稍微抖動(dòng)并且P值已經(jīng)適量的減少。從0.01開始緩慢增加RATE_D直到消除最后一點(diǎn)震蕩。如果此時(shí)飛行器又一次出現(xiàn)抖動(dòng),那就是D值過大。(一定會(huì)出現(xiàn)由抖動(dòng)到平穩(wěn)的過程,D值再大才會(huì)再次抖動(dòng),所以調(diào)參是不能著急,一點(diǎn)點(diǎn)增加,不然可能錯(cuò)過理想值)一般通過調(diào)節(jié)P與D就可以得到比較良好的電機(jī)響應(yīng)。RATE_D的典型值一般在0.01–0.02
在QGoundControl可以鎖定pitch與roll的速率。一定不能出現(xiàn)震蕩,但是百分之十到二十的超調(diào)是允許的。
I增益調(diào)節(jié)
如果飛行器可以實(shí)現(xiàn)定點(diǎn)但是定點(diǎn)的位置與期望存在誤差,那么增加MC_ROLLRATE_I 和MC_PITCHRATE_I(上面一句的翻譯是個(gè)人想法,原句是never reach the setpoint but have an offset。我覺得它的意思是實(shí)現(xiàn)了懸停,但是此時(shí)的點(diǎn)不是想要的點(diǎn),所以說,按照個(gè)人想法,I值并沒有什么用處,我不會(huì)在乎懸停之后的誤差)以增益MC_ROLLRATE_P的值得百分之五到百分之十開始向上增加。
第三步 穩(wěn)定翻滾與俯仰角度
參數(shù) MC_RATE_P, MC_RATE_P
把飛行器拿在手中,中油門上下,到剛好平衡重力。向俯仰或翻滾方向上稍做傾斜,觀察反應(yīng)。飛行器應(yīng)該緩慢回到水平。如果出現(xiàn)抖動(dòng),減小P。如果反應(yīng)正確但非常慢,調(diào)大P直到開始出現(xiàn)抖動(dòng)。最佳的反應(yīng)應(yīng)該是超調(diào)10%–20%后得到良好的響應(yīng)。
在QGoundControl可以鎖定pitch與roll。姿態(tài)角度超調(diào)不要超過10%–20%.
第四步 穩(wěn)定航向速率
P增益調(diào)節(jié)
參數(shù):MC_YAWRATE_P
設(shè)置很小的MC_YAWRATE_P,比如0.1。
把飛行器拿在手中,中油門上下,到剛好平衡重力。轉(zhuǎn)動(dòng)飛行器方向軸,觀察反應(yīng)。電機(jī)聲音應(yīng)該發(fā)生改變,飛行器應(yīng)該阻礙方向變化。但是這個(gè)響應(yīng)應(yīng)該弱于俯仰與橫滾方向,這是正常現(xiàn)象。如果飛行器出現(xiàn)抖動(dòng),減小MC_YAWRATE_P。如果響應(yīng)非常劇烈甚至在小幅轉(zhuǎn)動(dòng)(full throttle spinning vs idle spinning propellers不懂這句什么意思),減小P。典型值大概為0.2–0.3。(四軸因?yàn)槠浣Y(jié)構(gòu),導(dǎo)致航向上的不靈敏,yaw-p要小于pitch與roll)
在航向的速率控制中,如果響應(yīng)非常強(qiáng)烈或出現(xiàn)震蕩,會(huì)影響俯仰和橫滾方向的響應(yīng)。統(tǒng)籌調(diào)節(jié)pitch,roll,yaw達(dá)到平衡。
第五步 穩(wěn)定航向角
把飛行器拿在手中,中油門上下,到剛好平衡重力。轉(zhuǎn)動(dòng)飛行器方向軸,觀察反應(yīng)。飛行器應(yīng)該緩慢的回到初始方向。如果飛行器出現(xiàn)抖動(dòng),減小P。當(dāng)響應(yīng)正確但速度慢,增加P直到反應(yīng)達(dá)到穩(wěn)定,但不要出現(xiàn)震蕩。典型值大概為2–3。
在QGoundControl觀察ATTITUDE.yaw。超調(diào)不應(yīng)該超過2%–5%.小于pitch與
Roll。(個(gè)人認(rèn)為,航向上不用太較真啦,不影響另外兩個(gè)就好)
前饋補(bǔ)償調(diào)節(jié)
參數(shù) MC_YAW_FF
這個(gè)參數(shù)不太重要,并且可以在飛行過程中調(diào)節(jié)。但是不理想的參數(shù)會(huì)使響應(yīng)變慢或過快。應(yīng)該調(diào)節(jié)MC_YAW_FF使飛行器得到良好的響應(yīng)過程。其有效范圍0–1,典型值大概為0.8–0.9。(有時(shí)為了航拍效果考慮,可以再改小MC_YAW_FF,以便得到平滑的響應(yīng)過程)
在QGoundControl觀察ATTITUDE.yaw。超調(diào)不應(yīng)該超過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).
總結(jié)
以上是生活随笔為你收集整理的px4官网调参指南 多旋翼无人机PID调参指南的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第十章 PX4-Pixhawk-姿态控制
- 下一篇: Pixhawk-串级pid介绍