This is a work in progress. I've tried to address some fine tuning and performance issues.
Denny R. had made a comment about the inertia of bigger props causing issues. I've added a low pass filter to smooth the positive acceleration of the props to see if we can get at this issue. It may require tuning up Rate_P for a few folks, but I saw little issue in multiple flights.
Crosstrack had a small math error that decreased the resolution of it. I've fixed that and upped the default gains to get better tracking.
Made WP hit radius 1 by default. even 3m is too much for quads. (If you pass a WP you will move on to the next)
The Loiter method is tuned a little better by default, and now uses GPS offsets when flying less than 1.5m/s. Code experimentation will continue on this front. Thanks to Emile and afernan for their help!
A fix in the Z Accel startup was added to get an averaged result.
Added the ability to enter Loiter with Optflow enabled. - still a work in progress, not for everyday use just yet.
This alpha is on GIT now and is for user's who want to test code. As always, you need to use the "relaxpatch" version of Arduino you can find in the downloads section.
Update: We've found and patched some small type bugs in the latest and updated some GPS drivers in the Library. Be sure to pull the latest code and check http://apm.tridgell.net/ for the status of each build run against the SIL sim server.
I pushed a version on to GIT that addresses a number of issues.
- the low speed GPS XY calculations were incorrect and have been fixed
- Nav_Rate I term has been removed in loiter control - it's too easy to get two iterms working out of phase
- A second derivative has been added to Roll and Pitch. I found it removed wobbles nicely - Can be adjusted in the planner as STAB_D with a default of .25 (just enough)
- Smoothing has been applied to the motor commands in a way that really quiets down the alt hold pulsing without much effect on latency
- Yaw now has a dynamic constraint and I've upped the yaw gain.
- The motors output now have an LP filter on them so that the accelerate just a tad slower than the deceleration. This is a test to see if it helps big Octo's and Hexa's
- The Rate_I term is now zero'd for first five seconds after takeoff to keep balance.
- Loiter gains are lightened up a bit
- Nav_Rate_P is lower to remove back and forth sped related hunting in loiter
- Compass is enabled by default
- New I2C Library now included which should solve I2C related lockouts
- optflow is still a work in progress.
This update is based on flights today in a very windy environment.
It occurred to me that we're handling the WP nav I terms incorrectly and I reworked the WP navigation to share the same I terms from the Loiter. Even though they use different error input, etc, they turn out to both deal with wind in the same way. I have not Flown WPs with this new code, but heavily tested it in the sim and It's really rocking in hard wind. Transitions from Loiter flight and Nav flight are very smooth. Please let me know if you have luck.
This is a quick patch based on a bad crash Marco had. My theory was an I term that built up during wind that needed to be reset, but wasn't. It's a corner case but It bit Marco pretty bad. Please re-pull if you have R4 running to go to R5. And please, please be careful. This is alpha code not for general testing, but for development. Don't fly it on anything you would feel bad about crashing.
Update R7:Added an auto-land timer for RTL. If you don't change modes for 20s after the copter arrives at home, it will begin to auto-land. If you have failsafe and no GPS, you will immediately begin auto-landing.
Minor tweaks and cleanup
Made climb rate controller for landing universal for all altitude changes
Updated Loiter controller - Works great in the sim, thanks Afernan.
I'm curious that the PID is so high as default when I read on the forums that most are resetting it from 4.600 to lower around P 3.600 for Stab Roll and Pitch. What variables of the craft should be taken into consideration whether the settings are higher or lower? I would assume weight and power and their ratio relatively?
For example mine is Coaxial X8 and flight weight about 2.3kgs . I calculated max thrust to about 7.5kg with the current motor/prop config so have put the optimum flight weight at about 4kg max.
For higher power to weight ratio is it better to have a lower PID for Pitch and Roll for a medium response?
Small custom quad 650gr rtf
good behavior in general. I' ve needed to low Loiter_P to 1.5 and Loiter_I to 0.01. Higher values produce oscillation not damped. I need more D factor for this small copter: to be tested.
Autoland. Still the problem of final cut down. Stays kissing the ground without landing. I do propose the R7 approach.
Simple mode does not work properly
More observations on flying 2.1.1r10, stock 3DR quad, APM 2.0 board.
Finally, getting much closer. Some fortuitous advice from DaveyWaveyBunsenBurner led me to dramatically reduce the Loiter P setting (even though his experience turned out to be with an APM 1 board) and that set me on the right track. It seems to me that a sweet spot is around Loiter P=0.86, I=0.005, but I still had quite a lot of altitude variation - one Loiter track had quite dramatic 2-3m bounces. Marco Robustini then advised me to adjust the Stab/Rate PIDs. Close to sunset, in very low/no wind, I flew a few times with the Stab Roll/Pitch down to 4 and I down to 0.03 (pure guesswork on my part). Due to not having time to setup my laptop etc, I did no more configuration than that, but just flew it for 3 batteries. It seemed a lot smoother, especially in altitude, and I am now getting a reasonably good loiter performance. Attached is a .kmz of a track that was between 5 and 6 minutes worth, where most of the track is within a 6x7m box with an altitude variation of less than 1m.
The great news is that I am now getting a reasonable and repeatable Loiter performance in low/no wind. I say reasonable, because I simply don't know what the art of the possible is for a 3DR/APM2 combination. The bad news is that there are now more variables to worry about when trying to achieve that perfection, and I have no idea as to what the interactions are between all of them. My nightmare scenario would be to have to revisit all the parameters every time I find a sweet spot with one combination. Any advice or guidance from the development team would be most welcome.
My PID settings below for anybody else with an APM 2 board/3DR or similar:
2012-01-13 05-21 31.kmz
More observations on flying 2.1.1r10, stock 3DR, APM 2 board.
RTL now works for me, I think that I must not have been giving it enough time to respond before. In 2.1.0 Alpha I normally get a violent response, in r10 it is really quite slow to start moving back. I have not been brave enough to test the Auto Land for real yet.
Camera stabilisation is definitely still not working. On other discussions, it appeared that I may have been plugging the servos into the wrong output channels, but it looks like it is a problem with the board, reported on the other discussion.
More seriously, I still cannot get Loiter to work. In low or no winds at the moment, I am still getting big circles and occasionally violent pitch changes when flicking flight modes. I am using a Loiter P of around 2 (fiddling makes little difference), and tried Marco Robustini's suggestions of I as 0.020, but whatever I do I still get big circles even if I make I zero. Altitude Hold does not look as good as 2.1.0 Alpha. If this release is about to go to Mission Planner, then surely someone somewhere is flying this successfully, in different wind conditions with tuned PIDs for a stock 3DR with an APM 2 board. If they are, then please could they promulgate those PIDs. At the moment, I just feel as if I am chasing my tail. I know Loiter can work very well as it has happened for me on the odd occasion, but right now it is not repeatable.
ArduCopter V2.2 (not alpha) on GIT for tester/reckless... in the evening my video of the flight tests.
EDIT: tested with AeroSim and is unflyable (dunno in the reality, I do not risk), there's big obvious bug in the alt_hold control, don't fly at the moment in the reality with this release, see video.
I make a premise: could be just my problem, but for safety we believe, I await confirmation by JL or Angel, like me who use assiduously the sim for test new release.
Using the default parameters the quad going up and down violently in Loiter/RTL/Auto with the throttle stick at the center, if significantly lowering the "Throttle Rate P" (0,1) and "Altitude_Hold P" (0,050) i've very little improvement, but the bug is already present.
I think the problem is here, in the calc of "rate D term", line 190:
rate_d = ((rate_d + climb_rate)>>1) * 1; // replace with gain
I've replace "* 1" with "* .1" and now work fine, but dunno if is correct.
RTL here doesn't work, the quad surpass the Home point and doesn't try to return, autoland in away location.
With autolanding same problem, but now the jump is too low, need to try in reality.
Please Jason if you possible in the future check first with AeroSim at least where you change the code before put on GIT, many users here use the GIT version without first simulate and this can be risky.
Two way: closing the GIT who is out of the dev/tester list, or better control in the sim before release it, I agree that it is at the risk of the user, but prevention is better than cure (IMHO).
I did a methodical test in my basement to track down the source of the sonar noise. It does NOT appear to be electrical. (And just to clarify for everybody, I have the RC filter, shielded wire and heat on my sonar already, and when I flew last the log show absolutely terrible noise on my sonar. This is on a big trad-heli.)
2.1.1.r10 HIL test on AeroSim
LOITER simply perfect, even better with wind.
AUTOLAND worked for me, including disarming at the end.
SIMPLE mode NOT worked well (nor in r9): tested in HIL and REAL. See what the controls do...
If the real flight confirms the loiter for me as for Marco, we are really close to the end (of this step)
Could I get some guidance on the attached log file please?
I'm running r10 but loiter keeps "stirring" into a big circle. I had this with R6 too but 2.0.50 was a good loiter.
I have recalibrated everything several times, checked motor alignment etc. Is there something else I can try?
The attached log is quite short, I will try to get a better example tomorrow.
2012-01-12 07-44 5.log
can´t load r10 code. After "Done uploading" with Arduino (as usual) it remains beeping long time with leds off. I´ve repeated many times the process and nothing (done with r9 and work well).
anyone has this problem?
FLIGHT TEST WITH ARDUCOPTER 2.1.1R10 - LOITER AND AUTOLANGING (APM 1.4)
I struggled to find a good setup of the PID, and still have excessive wobbling during descents, i tried in every way, especially by acting on STAB / RATE P&R "I" but to no avail, always wobbling.
Is a problem related to an excessive drop in the rpm engine in Stabilize, taking it a little more gas during the descent the effect is greatly reduced, obviously.
I think you should turn off the engine at zero throttle but have a much higher rpm of around 5<->30 % of the throttle excursion in Stabilize, like in Loiter mode but more aggressive for better and fastest control in fly.
Is almost perfect in zero wind, max 2 meters of drift at worst, only 1 meter on average... nice work guy, thanks to Mr Afernan for porting the code from ArduPirates NG, and to Mr Jason for having improved!
We await the report of who has tried it with wind, but usually works better because the corrections are almost always given in one direction, avoiding the circle effect.
About autolanding: mmmm... the same bad results I had with AeroSim, identical, the same behavior... the quad kissing the ground then drift and jump, like if the loiter control after the first ground touch is totally disabled.
Even when the quad hits the ground loiter function should remain active (I do not think so, it would move that way), of course, the engines will drop further regime to avoid those jumps.
Strangely Jean-Louis with X-Plane does not have this problems, at this point I think is better AeroSim as realism to test this type of functions... now when i land correctly in AeroSim i try again in the reality! :-)