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 unfortunately had a crash before I finished tuning my quad last night but on an APM 1.0 board I was beginning to have more success bring Loiter P down to 1 or below in addition to reducing Loiter I to 0.020. Try decreasing your loiter P bit by bit.
OK, will do, thanks. Are you using a stock 3DR?
No, I'm using three custom frames of varying descriptions, but the one I was flying yesterday is reasonably close dimension and weight wise to a 3DR standard.
What I was able to see was that lowering the P value caused a less pronounced circling, I was lowering it and lowering it but then I stacked it (my bad, not the code).
I speak from personal experience, first fine tuning "Acro" mode and keep it handy on a switch, in emergency go to this mode immediately, most of the time you save your quad from eccessive wobbling.
Absolutely agree with you.
Knowing how to fly ACRO saves lives
Thanks for the input - am definitely getting closer to a fit in low or no wind. Still fiddling with the PIDs, getting through batteries faster than I can charge them. Will post results later. Cheers, Bill
@Bill: when you play with loiter always considers that the "Stabilize/Rate PID" interact anyway.
APM2 have a different gyro/accelerometer/baro, probably Loiter now works well only with the APM1, need some tuning in the code for the new sensor.
Marco, thanks for that. On my last few sunset/night flights I reduced the Stab parameters as well. Seemed to help.
The problem that gives me is that I now have more variables to worry about. Having found a relative sweet spot for the Loiter PIDs, I now need to experiment with the Stab/Rate PIDs as well. It is not clear to me what the interactions are now with all the changes to the code. I think that the wiki is out of date and without guidance or a clearer understanding of the strategies and interactions from the developer team, it could be hard work getting the 3DR/APM 2 board combination to achieve what it should technically be capable of.
From a code point of view, I sincerely hope that apart from some config settings, and PID settings where those are separate, that the code should not be board specific, otherwise the developers will have a development and maintenance nightmare.
More on my recent r10 experiences shortly.
Maybe your circling problem is back to issue discussed long ago: Magnetometer alignment and declination setting. Have you looked at that?
Robert, thanks. I had anyway checked my compass dec settings. Oddly enough, in my experience it seems to make much less difference than in the limited period when I was using an APM 1 board.
In any case, I think that I have got a lot closer to a reasonable solution, more shortly. Bill
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:
Not sure if you noticed, but 2.2 was released to supersede 2.1.1r10