This is a short guide for setting up [ArduPilot](https://ardupilot.org/) on a flying wing. I use an Omnibus F4 that was previously set up for INAV (so motor on 1, elevons on 3/4), so most of this guide will be geared to that. If you use a different controller, your mileage may vary.
You should keep the [full list of ArduPilot parameters](https://ardupilot.org/plane/docs/parameters.html) open, for your reference while tuning.
Copy it from here, save it to a file called `docker_build.sh` in the root of the ArduPilot repo, and run it with `docker_build.sh <your board>`. Output files will be stored in `build/<yourboard>/bin/`, and you can flash them with the [INAV configurator](https://github.com/iNavFlight/inav-configurator/releases) by putting your board in DFU mode and uploading the `arduplane_with_bl.hex` file:
The values in this section are specific to the Omnibus F4, but the settings aren't, so you'll usually need to adjust your outputs to your specific configuration but you probably won't need to skip many of the steps here.
- [ ] Connect Fport to a UART. I chose UART 3 (SERIAL2). If you want to use UART 1, you should set the RC input jumper to PPM on the F4 to disconnect the SBUS inverter from the pin.
- [ ] Set up the OSD (Mission Planner has a very nice UI for that). Keep in mind that ArduPilot's airspeed and windspeed estimation are quite good, so you may want to add those even if you don't have an airspeed sensor. You may also want to set up multiple screens, I use a potentiometer to switch between the four different screens of the OSD:
- [ ] Set up modes, possibly having switches override the mode channel to the mode you want.
What I do is set a given channel as the mode channel, and make that channel always output -100% on the radio. Then, I set up channel overrides for each switch, keeping in mind that overrides in OpenTX are executed in order (so the bottom override has the highest priority).
That way, I set MANUAL/ACRO/FBWA to be lowest priority (on the same switch), then CRUISE to override those, then LOITER, RTL in that order. Finally, I add AUTO to a switch on its own channel.
Keep in mind that whatever mode you have on its own channel might be overridden if you flick a different switch.
Unfortunately, the way the mode system in AP works, there's no good way to have a list of prioritized modes, which would be ideal.
- [ ] Set `ARSPD_FBW_MIN`/`ARSPD_FBW_MAX` to the minimum and maximum airspeed you want auto modes to fly (see the TECS tuning guide below for details).
- [ ] Set `MIN_GNDSPD_CM` so the craft makes an effort to return even under high winds. WARNING: Might make throttle pulse or have other unwanted side-effects.
- [ ] Fly in FBWA and see if you're gaining/losing altitude. Pitch up/down to fly level, check the pitch on the OSD, and use the formula `old_value+pitch*π/180` to get the new value (in radians).
To tune the TECS, a helpful resource is the [TECS tuning guide](https://ardupilot.org/plane/docs/tecs-total-energy-control-system-for-speed-height-tuning-guide.html).
Make sure you have run an autotune beforehand, and continue with the tuning below.
Set the throttle to the maximum throttle percentage from the previous step and start slowly pulling back on pitch until your airspeed equals your "comfortable cruise speed" from the previous step.
Note down:
- [ ] The pitch angle (in degrees).
- [ ] The vertical speed from the variometer (in m/s).
#### Fly down
Set the throttle to 0 and start pushing on the pitch stick until your airspeed equals your "comfortable cruise speed" from the previous step.
Note down:
- [ ] The pitch angle (in degrees).
- [ ] The vertical speed from the variometer (in m/s).
#### Fly down more
Keep the throttle at 0 and pitch down until you reach your desired maximum speed from step 1.
Note down:
- [ ] The pitch angle (in degrees).
- [ ] The vertical speed from the variometer (in m/s).
You're done with this step.
### On the bench
After you have the above measurements, you're ready to tune things.
For the level flight measurements:
- [ ] Set `TRIM_ARSPD_CM` to your "comfortable cruise speed".
- [ ] Set `TRIM_THROTTLE` to your cruise throttle percentage.
- [ ] Set `ARSPD_FBW_MAX` to something a bit less than the maximum airspeed you achieved in level flight.
- [ ] Set `THR_MAX` to the throttle percentage at max speed.
- [ ] Set `ARSPD_FBW_MIN` to the slowest speed you could turn at without stalling (maybe go a bit higher for some margin).