[sfwa]

X-Plane playback

After recording our first sets of in-flight data and developing the UKF to the point where it could be run on real datasets, we needed some way to assess the accuracy of the UKF output. In the absence of independent attitude estimates, we decided a reasonable approach was playback of the UKF estimates through X-Plane; by logging the flight path and comparing the current attitude to the direction and velocity, it’d be possible to obtain an intuitive feel for whether or not the UKF estimates were in the ballpark.

Screenshot of X-Plane playback based on UKF position and attitude estimates

After some research we determined the most straightforward way to send our estimates to X-Plane was via the ExtPlane plug-in, which exposes a text protocol allowing X-Plane datarefs to be set and retrieved. The only functionality we lacked was the ability to set the plane position in lat/long/alt co-ordinates (X-Plane runs its own local EUS co-ordinate system referenced to a particular lat/long); we solved that by adding support for a WorldToLocal call to the ExtPlane protocol.

In order to disable physics and play back a series of position and attitude values, ExtPlane needs a bit of configuration:

sub sim/operation/override/override_planepath
set sim/operation/override/override_planepath \
    [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
sub sim/flightmodel/position/psi
sub sim/flightmodel/position/theta
sub sim/flightmodel/position/phi
sub sim/flightmodel/position/local_x
sub sim/flightmodel/position/local_y
sub sim/flightmodel/position/local_z
extplane-set update_interval 0.01

Daniel had previously set up a model of the X8 in the X-Plane editor, so we used that for playback (although the physics engine is disabled, so it’s a purely cosmetic choice). After some initial glitches while the scenery loaded (prior to the lat/long/alt set, we were on the other side of the world), playback looked fairly smooth at ∼100fps, with every 10th UKF estimate displayed.

Screenshot of X-Plane playback based on UKF position and attitude estimates showing UAV path over several minutes

We had to do quite a bit of manual tuning of measurement and process noise covariance values to get reasonable results, but being able to visualise attitude and position from the filter made the task much more straightforward than attempting to tune based on static charts, or developing some sort of automated optimisation mechanism based on innovation values or similar.

github.com/sfwa twitter.com/sfwa_uav youtube.com/user/sfwavideo