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.
Cool, I'll give it a go. Is it safe to used Arduino 1.0 yet? I get some warnings when I try to verify the code in Arduino 022.
Thanks for the links. Got it loaded, but now it won't recognise my radio when I try to set it up. My radio is fine and the PPM light is blinking on the APM when I turn on the Tx. Might try uploading a few more times to see if that fixes it.
something is wrong with this version you posted even after changin line in apm config for apm2 still the sensors on apm2 board go nuts and are not working. With the version you posted yesterday for me it was al working after changing apmconfig. So something changed.
Ruben: if you have an APM2 board you should just be using this one line in APM_Config.h:
#define CONFIG_APM_HARDWARE APM_HARDWARE_APM2
The other line (#define APM2_BETA_HARDWARE) is just for the dev team, who have some earlier prototype boards.
Please download the latest zip file and try again.
Now , I want edit about lagging control. Because , It can't some control.
I can´t upload the 2.1.1r2 from the download site (tryed many times). Once installed (no errors aparently) APM remains dead beeping constantly, No connect, no CLI. Going back to 2.1.0 alpha, all comes to life.
I tried only for check if is ok and here APM start correctly.
Afernan, have you commented the two lines about APM2?
//#define CONFIG_APM_HARDWARE APM_HARDWARE_APM2
Anyway now there's the new i2c library (revised) on git, you must refresh all and test this one.
The must important "workaround" is about the bus lockup if you loose the connection with the compass... and with "loose" i don't mean "i2c shortcut".
I tried today the latest git release.
Gracias Marco: now it´s solved (I miss that two lines).
I´m just test in HILL the new code with defaults PIs on a "quasi-standard" quad (about 1Kg).
In loiter with light wind I´ve got always the circles (like in my real one). Now the GPS is working and connecting MP and Simulator. See the nice circles (10m diameter). The nav direction (black line) is always tangential to the circle, so it´s obvious the result. I´ve changed all possible combinations of PI´s in loiter and WP´s but I only obtain diferent elipse/circles shapes. I´m convinced it´s a problem of the control estrategy selected.
I know, the loiter strategy correction is still to be fixed again.
We must abandon the idea of using only the GPS nav/lot for this mode, we aim at other strategies, such as the use of accelerometers (not only for the gyro offset and drift), but this requires considerable computing power and highly accurate sensors, these have a lot of noise in the air with the motors vibrations, besides not being easy to implement.
The new InvenSense MPU6000 of APM2 could be help for this, but would cut off users who still fly with the APM1.
Do you felt a kind of delayed commands with roll/pitch manual correction in stabilize?
And if your answer is yes, this behavior has increased the stability of quads in your opinion?
That's awesome. I can't imagine loiter getting much better than that if it's just based on GPS. I'm guessing that the slow wandering that was apparent was due to the GPS signal wandering more than it was caused by APM.