In his outstanding presentation referenced in the Copter documentation, @priseborough discusses the possibility of creating a script to help with the somewhat cumbersome tuning process for wind estimation and baro compensation on multirotors.
I took a stab at such a script this month and came up with something that seems to be working for autotuning the momentum drag coefficient.
Wind is estimated based on GPS course and AHRS velocity during a downwind, level attitude drift in guided mode. Thereās no direct/clean way to manipulate yaw in the current Lua bindings, so Iām using guided mode to set attitude targets during the weathervaning phase. For best results, wind conditions should be fairly consistent, and the copter should be allowed to drift downwind until it is facing upwind and drifting at constant velocity (at wind speed). EK3_DRAG_BCOEF_X and Y must have already been computed and saved.
To use the script, first edit the top few environmental parameters with current temperature, baro pressure, and relative humidity. Load the script onto the SD card and be sure that scripting is enabled. Set an aux RC channel to RC_OPTION=300, preferably on a momentary switch. Upon boot, you should see a GCS message declaring the script ready, along with the computed air density value. Thereafter:
- Tune your copter well beforehand, and be sure the airfield is well clear for maneuvering.
- As discussed in the presentation, youāll need at least 50m clear of obstacles, and preferably a few hundred meters in all directions.
- Take off and hover in loiter, position hold, or altitude hold with the transmitter sticks neutral.
- Hold the assigned aux switch for at least one second and release it.
- The copter will begin drifting with the wind, aligning the nose upwind.
- Push the pitch stick full forward to accelerate into the wind.
- When maximum speed is achieved, release all sticks to neutral.
- After decelerating, the copter will be switched to loiter mode and is ready for further tuning or flying.
- Hold the aux switch for less than one second and release to set the orientation to LEFT.
- Repeat the long press, drift, and upwind run for each orientation, being sure to only accelerate directly into the wind using pure (single axis) pitch or roll RC stick inputs each time.
The weathervaning (drifting) phase can be canceled at any time by toggling the aux switch, moving the throttle, or changing flight modes.
Youāll see GCS text output that looks something like this:
Complete! Momentum drag coefficient = 0.117
Measuring momentum drag
Awaiting level attitude, max airspeed 13.6 m/s
Max speed achieved, center sticks
Wind estimated 110 at 1.5 m/s
Weathervaning (NOSE into wind)
After landing and disarming, the average of all runs will be saved to EK3_DRAG_MCOEF.
If you wish to check results, arm and take off again. Watch for periodic AHRS wind messages and compare them against observed wind or enter the weathervaning phase and cancel it to get a wind measurement independent of the drag coefficients.
I couldāve used custom parameters for temp, baro pressure, and relative humidity, but since this script will probably only be run once and then discarded, I thought that was unnecessary.
Definitely open to feedback!
copter-weathervane_draft-rev3.lua (13.7 KB)