Hi,
in this blog post I described how I changed the control loops for the attitude control (STABILIZE Mode) to use PID(T1) in the rate control instead of PI. For me, it was a major improvement of stability on my Tricopter.
Here I would like to discuss the attitude control structure.
From the Wiki and the code I saw that the current control structure (in AC 2.1 software) is like this:
I changed the control structure to this:
In my opinion, this is the best control structure for a attitude control with underlaying rate control that you can do with traditional PID(T1) controllers. Of cause there are other controller types, but lets stick to traditional PID(T1).
I got some questions:
- How was the original controller structure designed?
- Why is the I-term of the attitude control directly connected to the output (green ?* in first pic)?
- Have you tried PID loops? Are there reasons to avoid them in ArduCopter?
Maybe some people with a strong background in feedback control systems can join in. Lets find the best solution to get the stabilized mode really stable!
Regards, Igor
Replies
Hi All
For control difference thrust is what is pertinent. How is differential thrust achieved with a single PID control? I am basically asking if the system is SISO of SIMO? I am recreating a controller in labview whereby a single is isolated for testing purposes. Please can someone help.
Thanks
ArduCopter_2.2ß2XP2_PIDT1 complete set of flight test
I´ve performed a complete set of test (7 batteries) on this code in my 1kg Quad. Really good in all.
PID´s are close the same than my small quad (see previous post). Really easy tunning at first shot. I think this code is quite robust in terms of different platforms, since pids are close the same.
http://vimeo.com/35715703
Angel
What happend to this thread. Did 4 pages of posts go missing?
ArduCopter_2.2ß2XP2_PIDT1 code
Reading the code I have some doubds:
1) In a simplified view of the code, we can see that:
get_stabilize_pitch(int32_t target_angle)
current_rate = (omega.y * DEGX100);
rate = g.pi_stabilize_pitch.get_p(error); // *b*
error = rate - current_rate;
rate = g.pid_rate_pitch.get_pid(error, G_Dt);
That is: we apply the new control "get_pid" to the error comming from a initial estimation done with p-term (line *b*). Is that right?
2) At the end, we pipe i-term to the output:
return (int)rate + iterm;
but I guess is alwways zero, since _kI = 0 in this pid tunning. Is that right?
Angel
Just tested indoor the code (Marco release) in my small Quad. After tunning (as Igor told) I´ve got:
Rate R/P _P = 0.1, Rate R/P _D = 0.015, Rate R/P _I = 0.05 Stab_P/R P= 6, Stab_P/R I= 0
First feeling flying is quite good. At take-off, there are some initial 5 seconds that oscillates. Then, it dissapear and goes perfect. The same effect is seen when keeping the copter by hand: initially there is a very "hard" feeling during 5 sec. After that, its "softed" and behaves normally.
See this short video: http://vimeo.com/35586306
Jason could identified this effect in the code:
if ((millis() - takeoff_timer) > 5000){
// we must be in the air by now
takeoff_complete = true;
land_complete = false;
}else{
// reset these I terms to prevent awkward tipping on takeoff
reset_rate_I();
reset_stability_I();
}
Apart of that small bug, stab looks very well. I´ll fly outdoor today.
Angel
I just noticed in your function block diagram, you are using the actual angular rate from the gyros, where previously we were using the angular rate which is derived from the accelerometers (rate of change of vector). Is that right? That's a pretty fundamental change.
I'm trying to get up to speed on this thread. Is there an implementation that I can grab and fly?
BTW, the history of the control loop for stabilize is the NG control loop. The PI-P(rate) loop was developed by Jose a while back. I added the second I, but we don't use it generally. The I term was re-reouted because it failed to meet the balancing tests. I hung a battery off of one arm and the loop could not compensate. The current loop can compensate very quickly and 100%.
I added the multi-wii dampening term as an experiment. Yes, look at the code, credit was given. I wasn't in love with it in the end and it was a memory hog, so I modified it with a decimation filter. It is a little nicer now in B3/4.
I'm always looking for better control loops so please post a link to the new implementation.
Thanks,
Jason
I noticed something else in the code:
The error that is feed into the controllers is limited and the output is also limited. This should be a feature of the controller, not somewhere else in the code.
Limiting the error makes no sense to me, because you need to know the real error in the controller. Why is the error limited?
Limiting the output is a good idea, but you have to do it inside the controller and you have to stop integrating while the output is limited because the original value is over the limit. This is called PID with "anti windup". It would be a small improvement.
And of cause you can limit the integrated value, which is already implemented.
If someone wants to try the version I leave you with the modified guidelines of Igor, follow the instructions on its own blog post.
The package is a version of Jean-Louis 2.2ß2xp2 with the additions proposed by Igor (PIDT1, like Mikrokopter), I have eliminated many unnecessary things (multiple configuration and unused backup file).
Make your changes to the config and get a complete backup of your parameters before install this "test release", write with Arduino and then restore your parameters... now it's time to read the "pid tuning" part in the Igor's blog post! :-)
Unfortunately AeroSim does take its internal pid control mechanisms, then with simulator is not easy to find a good compromise, but the loiter is clearly better, with and without wind.
For this reason I believe that you will surely have the best tests and tuning in flight, if you decide to try follow perfectly the Igor's recommendations!
This archive is provided without any warranty, I do not assume any responsibility even if the simulator has never given any problems, so watch out and test it only with the sim (at the moment)!
Enjoy
Marco
ArduCopter2.2ß2XP2_AeroSim_PIDT1.zip
Hi Igor, I have applied all the changes you have suggested about "PIDT1" in AC 2.2b2xp (version revised by Jean-Louis) and I must say that loiter on the simulator is much more accurate, although it is very difficult to do a good pid tuning with the D term in the rate/stab.
I think this thing has a reason to exist, because we're trying like crazy to keep our quad standing in loiter dropping the parameters of exasperation, and then not being able to drive them in normal flight.
I read that Jason has something similar already implemented but not released, I hope that something comes out soon.
In attachment the loiter recorded with AeroSim: in the first 30 seconds zero wind and no side drift or circle, then suddenly active "crosswind" and the quad recovers quickly the original point at 1:07 and keeps the position... that is, it works!
Need better tuning and test in real flight but... welcome back "D term"! :P
Thanks!
Marco
REC-120120012706.bin