I've been away on vacation for the last week and a half, but I was able to port Arducopter to Flash and do some simulations. This has helped me rewrite the navigation control laws, simple mode, and Loiter to all use a streamlined set of control loops. This not only has saved code space, but the end result is a quad that flies like it's on rails.
Loiter and WP navigation are now the same code and use a rate based solution from the GPS. The heading and ground speed values are parsed into X(long) and Y(lat) components. This gives me a far more accurate estimation of position than just using the Mediatek's lat and long outputs. The controller takes the position error, desired speed, and minimum speed and outputs pitch and roll commands. I've noticed a marked improvement in Loiter hold. Basically it's glued to one spot. I'll need to do more testing in windy conditions, so stay tuned.
Altitude hold uses the same controller design and manages the speed of altitude change. Landing and altitude changes are much more controlled and I've not seen the quad loose altitude on RTL like it did in the past.
The Throttle, Roll/Pitch, and Yaw control loops have all be separated to give you the option of redefining any of the modes. In the zip file below, Alt hold has been redefined (in APM_Config,h) to use SIMPLE mode for Roll/Pitch. Loiter has been redefined to use Manual throttle.
The Flash based simulator uses nearly identical code to Arducopter. Here's the work in progress of the sim:
The code itself is available for download here and is considered alpha to me. WP's are being tested tomorrow. Only RTL, SIMPLE, ALT HOLD have been tested so far. Crosstrack correction is currently disabled. Everything should work, but be careful. Anything could happen. I've only crashed 4 times today ;)
Jason
Updated:
Comments
I tested the RTL and Loiter modes today on V 38 to get a comparison.
The RTL went up ~50 Ft and held with a altitude hold of 3 ft of variance. There was a NW 9 Mph breeze.
It turned in and out of the wind direction about 3 times then started a interesting head holding circle that was around a 100 Ft diameter going around 20 Mph. I let it fly around about 4 times watching in amazement and ready to grab it in stabilization mode at any time. The Loiter mode worked well at lower altitudes. After switching from loiter to simple the copter took off upward and to the south at a great rate of speed. Putting it in stabilization mode gave back the sticks and it was brought in. I am tempted to try the V 40. I just wish the grasses were a little higher like in spring time.
Nice, Malcolm! The elevator dips/oscillations that were evident in your last video are virtually gone. Very smooth!
Very quickly as martin (www.buildyourowndrone.co.uk) myself are still testing off to the field again in a few mins but here is a video of the code with my traditional heli. So far its like flying a different helicopter, the first Loiter test with tried it just stayed still. 2nd test is the video, it seemed to build up an error. Will post more as soon as i get home.
Right now the modes are defined in the APM_Config.h file. They could be moved to the Misison planner once we come up with an interface that makes sense. Or they could be just compile time options.
I've solved the Yaw in RTL issue that was plaguing me yesterday. I wanted to Yaw slowly in AUTO modes so I scaled down, KP. Not a god idea, since my frame was tweaked. It would yaw to the right on it's own and overcome the control limit, then spin 180. This induced a lot of control issue in RTL. Now I have a slew control on the Yaw commands so when your in AUTO/RTL the copter will Yaw to the target in a more controlled manner.
I had same small crashes until i notice that.
Looking forward to test this. Not shure I like the idea of simple control in altitude hold or manual throttle in loiter.. hm, perhaps I missunderstood..
Had some informative flight's today. More bug fixes coming soon. RTL had a weird Yaw issue. That' will be fixed soon.
AH indoors should work great.
Jason
Does this also mean that AH indoors isen't possible anymore??
Ok, just did as suggested earlier. Put the quad outside and wait for a GPS 3D fix.
Firts flight: Lifted off, and stable as usual. Great work there. Then switched to AH. Quad descends to just above the ground and sometimes hitting it:-(
Altitude is controled by throttle. At firts you have to get the hang of it. Ones at the desired alt its stayes there. This is a bit weird because I liked when I had the desired height in stable mode and then switch to AH it was much faster (v37 that is). Otherwise rock solid and reacts to objects through the sonar.
Then switched to loiter. If your throttle isen't in the middle the quad goes up or down so you have to be quick to get the desired altitude. I had no real indication that it was in loiter because the quaddidn't quite stay in the desired position.This could be some tweaking offcourse. Does the loiter radius parameter in the MP have effect when not flying a mission???
In my opinion the altitude control in AH and loiter was better in v37. AH hold is very good now. For me, in loiter I liked the fact that position and altitude is maintained as in the previous versions.
Another thing I noticed is that the altitude itself doesn't stay solid when for example the quad has landed and stays still. It goes down to negative
Second flight: lifted off and checked altitude on MP. Altitude isen't correct, its lower than reality. When clicking the homealtitude it is set to 0. When I land its a couple of metres negative.
Then swithed to AH again. It suddenly goes up for no reason and stops at avery high altitude, lets say 15m, then you hear the motors turning faster and altitude is maintained.Then it descends fast and I have to switch back to STB.
I can see there are a lot of improvements. Hope this helps a bit.