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.
Just connected the + from one lipo cell to the + IN sonar for a quick test to eliminate ESC 5V power problem.
And behold, it works great!!!!!
Log attached. Sonar is 99,5% smooth just one or two spikes that I didn't even notice during flight.
So the problem is certainly the ESCpower. I need to get a BEC soon ;-)
One question though. If I am in AH and push the THR up or down, the quad will change height untill I center the THR stick. Does the quad have to stay at the new altitude or go back to the firts AH height when selected.
If you checked the logyou can see that it returns.
Or is this a SF setting????
So you supplied it with only 3.7V and it worked? Interesting. Maybe it's actually running off 3.3V instead of 5...
Anyway, good news.
Datasheet says it has to be between 3,3 and 5V.
Whats your view on the AH change with THR?
I'm not positive on the AH. I believe it's supposed to hold the new altitude setpoint, at least that's what mine seemed to do. I haven't used it much though. And I don't know if there's a setting.
This isn't the issue in my case either. I'm using a 7805 linear voltage regulator to power the APM with a lot of capacitor filtering.
I don't think it's the Xbee in my case, as I did have it plugged in the whole time. It was not linked to the ground station, but it would have been transmitting pips as always. And besides, the really noisy sonar I had on my flight was exactly the same condition, Xbee plugged in but not linked to ground. My Xbee is on the nose of the airframe, and the sonar is at the very back, about 12" away.
For sure people need to be aware of all the other causes you suggest.
I put a little list on the wiki page. If we find solutions that work, we can put them in.
Olivier suggested trying a cone to help with accoustic noise, which I will probably try.
One to also add for all electronic is to make sure that if you mount them onto a carbon fiber frame to make sure there is good insulation between the boards and wires and the frame. The frame is conductive and it can short out you boards etc if strapped directly to the frame without any insulation.
When I had problems with the sonar I ended up putting a microphone foam cap (or whatever the name is in english ) around the sonar, as well as the RC filter, shield and heating. I think that helped a lot removing acoustical noice. I have a std Jdrones quad.
If it turns out to be vibration then an easy solution would be to have a better mount for the sonar with some shock absorption. Acoustic you think is coming from your prop wash? Are there any special covers for the sonar that work like a pop filter on a microphone for noisy environments? Maybe need to try some very fine materials to cover it.
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).
Made the update to D term, thanks.
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.