If anyone has comments, additions, modifications to this, please post!!! I would like it to become a detailed guide for fixed wing GPS flight mode setup.It's been a long time, forgive me if any of this is wrong.
You are running a "recent" version of next. That is what the +r782 means. In case you need to know...
Most of my experience is with 16.09 (that is +r0) and with similar sized, aileron equipped airplanes. I suspect that next acts like 16.09 in regard to what you are doing and what I am familiar with.
Be aware that Position Hold (and RTB at base=takeoff location) basically just flies straight toward the desired location and when it passes it, it turns around and flies toward it again. I think this is also what it does when trying to gain altitude, like at the beginning of RTB when it is supposed to climb ReturnToBaseAltitudeOffset higher. If Position Hold can't even hold altitude, much less climb, then it's not going to climb at the beginning of RTB?
The altitude code: I recall that I had to tune the altitude PID I recall the throttle constantly going from 0% to 100% to 0%. It's been a while, so I don't remember if this was also associated with sharp waypoint turns. On one of my planes I recall just setting the thrust limits to reasonable values (gentle climb and gentle descent) and the oscillation was stopped or reduced. I don't recommend that though. I suggest that you read threads listed later about tuning the altitude PID.
The altitude code is a bit counter intuitive. It acts like a big airplane's altitude code. It is designed so that it's number 1 concern is to not stall out if the motors fail. To climb it adds power (it doesn't directly pull up elevator). If it is going "faster than desired" THEN it adds up elevator. A nose heavy airplane helps so that when you add power it climbs (not just flying faster and remaining level).
The turning / banking code just banks. It only adds up elevator when it sees the nose drop. Properly tuning the PID will tend to minimize the time the nose is dropped, but not fix it perfectly. The best thing for this is to configure it to make slow, wide turns where it has less reason to drop the nose and more time to correct when it does. Don't adjust things to make it turn sharper until you have it flying well. I hacked the code I am flying to immediately add some elevator at the time it banks. It's just a hack based on bank angle and math. A correct change would also use the airspeed (and/or a setting) to work correctly for any aircraft.
Be aware that the current code and default settings make fairly wide turns. like multiple football fields wide...
If you haven't correctly set up your speeds (min and max in 2 places), etc. you will get errors. As I recall, in waypoint flight, (by default) this makes it constantly go back to the first waypoint.
I presume that your main interest is waypoint, RTB, and other GPS modes; not in making the airplane easy to fly for a beginner.
One way to manually tune a PID is (my adaptation of the wikipedia page on PID
https://en.wikipedia.org/wiki/PID_controller#Ziegler%E2%80%93Nichols_method ):
- this is best done on one channel at a time, e.g. just roll, while leaving the other channels set to default or some other working (not oscillating) value
- leave P default and set I and D to zero
- tune just P until it just starts to oscillate
- cut P in half and leave it there
- tune I to minor oscillation and back it off slightly from there (no oscillation or "ringing")
- leave D set to zero
I have an EasyStar and still have 2 new kits in the box.
I have changed over to Bixler 1.x's because they have ailerons (and fly very well). On the EasyStar I increased the size of the rudder control surface by gluing on a balsa extension. This was originally called the credit card mod; I guess because someone glued a credit card on long ago.
Tuning a fixed wing the way I do it requires you to be able to fly, which is not good for beginners, but here it is:
- Set Attitude -> Settings -> Attitude Estimation Algorithm to GPS Navigation (INS13) (requires good GPS and mag setup and calibration)
- Set System ->Settings -> AirspeedSettings.AirspeedSensorType to GroundSpeedBasedWindEstimation
- Airplane balance should be a little nose heavy. Nose heavy requires a little up trim to fly level and that up trim causes a climb at higher throttle settings.
- Start with Manual flight mode on all controls. Trim the airplane for level flight. Leave it in Manual mode for now.
- While flying, decide what feels good for cruise speed and set your elevator trim so that cruise speed does not climb or descend. Don't use full throttle for cruise speed. Half way between the slowest safe flight and full throttle is probably a good setting. Trimmed (elevator) cruise speed should be low enough that just adding throttle makes it climb.
- Some settings are only accessible in the System page. Setup is in Settings (and telemetry, like your current speed is in DataObjects). The normal configuration stuff (in the Configuration pages) is just a pretty wrapper for the System page. It's best to use the Configuration pages instead of the System page as they have better instructions and sometimes impose numeric limits. On the System page, press the red up arrow a the top of the window to save the currently highlighted setting that you just changed. Beware that some settings that seem like they should be in % are actually entered as numbers between 0.0 and 1.0, not between 0 and 100.
- Use telemetry (System -> DataObjects -> GPSPositionSensor.Groundspeed or AirspeedSensor.CalibratedAirspeed) on a calm day to get the actual numeric value of cruise speed (in meters per second) of straight and level flight (mild turns). You will use that number. It's a good idea to get your min speed (just safely above stall) and max speed (full throttle level) too. Also get the throttle stick positions (numeric values) for min, cruise, and max speeds from System -> DataObjects -> ManualControlCommand
- While you have these numbers handy, set FWPFSettings.HorizontalVelMax/Min and .ThrustLimit.Min/Neutral/Max
- Adjust the control linkages so that you can put the transmitter trims back in the center. You generally don't want to use trims except as a temporary thing. Trimming in Manual mode messes stabilized modes and stabilized modes don't need trim (Rate should NEVER need trim and Atti should be trimmed with Attitude -> Settings -> RotateVirtual).
- For a 3 channel (rudder elevator throttle), from now on, pretend that the rudder is actually ailerons and that you don't even have a movable rudder.
- For 4+ channel setups (aileron elevator throttle and rudder) Always leave the rudder stabilization set to Manual. Never put stabilization on the rudder function. A stabilized rudder requires coordinated turns which the autopilot does not do. (Your rudder function isn't actually connected to anything.)
- Be aware that switching from a Manual flight mode to an Attitude flight mode (and a lesser extent Rate mode?) has a windup issue. For the first few seconds after switching, it will be (perhaps badly) out of trim. A work around is to go to zero throttle (which zeros the windup), switch the flight mode, then throttle back up. another work around as I recall and as documented in a post... is to use a Stabilized# mode set to be all Manual instead of using Manual mode directly.
- Don't bother with this now but later consider reducing the (I think) Rate PID ILimit (for roll and pitch) (System -> Settings -> StabilzationSettingsBank#) to reduce PID windup during Attitude mode hand launch. Note that the windup looks like it occurs in the Rate section since the Attitude section has a zero I term by default. Fly along in Manual mode for a while, then switch to Attitude mode. It will go crazy for a few seconds. This is what you are trying to fix.
- Tune rate PIDs (Configuration Stabilization InnerLoop) while flying in Rate mode (AETR=Rate Rate Manual Manual), at cruise speed.
- For a test: Increase the rate PIDs (P) till it almost oscillates at cruise speed. Fly it and increase the throttle significantly above cruise speed. It should definitely oscillate. Put PIDs back to good values.
- Set StabilizationSettings.ScaleToAirspeed to your cruise speed number (the speed you tuned the PID at). Now, increasing throttle should NOT oscillate any more.
- Tune attitude PIDs (OuterLoop) while flying in Attitude mode
- You haven't set up your min/max speeds yet, so GPS mode flight will set some error flags. Look at FWPFSettings (HorizontalVelMax/Min) and SystemSettings (AirSpeedMax/Min) for places where you should consider setting reasonable speed values.
- I suggest a Waypoint mode test flight at this time. Perhaps 4 waypoints in a LARGE square way above the trees. If it keeps going back to the first waypoint, you are getting errors (over/under speed, etc.). You can bypass the errors by setting Error Destination to -1 for all waypoints. You can use 3 waypoints, but if you use only 2, you can't tell if it is getting an error and restarting at waypoint 1 or if it is completing successfully and restarting the waypoint set (it loops the waypoints over and over by default).
- Understand and possibly adjust FWPFSettings SafetyMargins and SafetyCutoffLimits so that GPS flight doesn't throw alarms (which will abort your waypoint flights and by default send you back to the first waypoint over and over).
- For a climbing / descending test, maybe do some waypoints that have noticeable altitude differences but not more than your airplane does just by increasing throttle; say a 15 degree climb/descent.
- Look here for some clues about getting the altitude/airspeed tuned. You may need to adjust your Rotate Virtual (Attitude page). I'm making a wild guess that your pitch angle should be zero at 100% throttle level flight because FWPFSettings has default PitchLimit.Neutral of +5 degrees.
https://forum.librepilot.org/index.php?topic=3518.msg24240#msg24240https://forum.librepilot.org/index.php?topic=4769.msg32097#msg32097- Once waypoints are working well, RTB should also work.