GithubHelp home page GithubHelp logo

jedidiahtetteh / inav-x-plane-hitl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from romanlut/inav-x-plane-hitl

0.0 0.0 0.0 335.22 MB

Hardware-in-the-loop plugin for X-Plane for INAV flight controller firmware

License: MIT License

Shell 0.01% C++ 53.67% C 44.83% Lua 1.16% Makefile 0.28% Batchfile 0.04% Dockerfile 0.02%

inav-x-plane-hitl's Introduction

INAV X-Plane HITL plugin

Hardware-in-the-loop plugin for X-Plane 11 & 12 for INAV Flight Controller firmware:

IMAGE ALT TEXT HERE

Hardware-in-the-loop (HITL) simulation, is a technique that is used in the development and testing of complex real-time embedded systems.

X-Plane is a flight simulation engine series developed and published by Laminar Research https://www.x-plane.com/

INAV-X-Plane-HITL is plugin for X-Plane for testing and developing INAV flight controller firmware https://github.com/iNavFlight/inav.

Motivation

I believe that good testing and debugging tools are key points to achieve software stability.

It is not Ok when people debug autopilot by running with RC Plane on the field ๐Ÿ˜ƒ

I hope this plugin can help to improve INAV firmware.

While not been a main purpose, plugin can be used to improve pilot skils or getting familiar with INAV settings.

How it works

X-Plane https://www.x-plane.com/ is flight simulator with accurate physics simulation.

X-Plane is extendable with plugins. This plugin connects to Flight Controller through USB cable and passes gyroscope, accelerometer, barometer, magnethometer, GPS and Pitot tube data from X-Plane, which replace data from physical sensors.

FC sends back yaw/pitch/roll controls which are passed to X-Plane.

X-Plane 11 or X-Plane 12?

Simulation requires at least 50, or even better 100, solid FPS without freezing. While X-Plane 12 has better visual appearance, X-Plane 11 is still recommented choice due to better performance. Also INAV Surfwing flying characteristic seems to be worse in X-Plane 12.

Setup (Windows)

Plugin is Aircraft plugin.

The contents of release\Aircraft folder should be placed in the Aircraft folder of X-Plane: X-Plane11\Aircraft\.

This action will add INAV Surfwing flying wing model with this plugin.

IMPORTANT:: You have to flash Simulator-enabled INAV firmware. Take precompiled binaries from release https://github.com/RomanLut/INAV-X-Plane-HITL/releases/ (INAV 5.0.0 with simulator support), or build yourself from branch: https://github.com/RomanLut/inav/tree/simulator_v1.0 (INAV 5.0.0 with simulator support), or build yourself from master branch of official INAV repository . Official INAV firmware releases do not include simulator support currently. It will be included in INAV 6.

Installation steps

  • Install X-Plane 11 demo from: https://www.x-plane.com/desktop/try-it/older/ . Demo allows to fly for 15 minutes in Seattle region. Than you have to restart the game.
  • download Aircraft.zip from last release https://github.com/RomanLut/INAV-X-Plane-HITL/releases/
  • If upgrading from previous version, delete folder X-Plane 11\Aircraft\Extra Aircraft\NK_FPVSurfwing\
  • Unzip, copy Aircraft folder to X-Plane 11\Aircraft folder in X-Plane installation location.
  • Connect Flight Controller to PC using USB Cable. Make sure FC is flashed with simulator-enabled firmware https://github.com/RomanLut/INAV-X-Plane-HITL/releases/
  • Configure FC (see Flight Controller configuration below)
  • Start X-Plane 11
  • Select "Show extra aircraft from older versions" to see INAV Surfwing
  • Select INAV Surfwing, start flight
  • When scenery is loaded, select Plugins->INAV HITL->Link->Connect to flight controller. Plugin should automatically detect serial port.
  • Flight using RC Controller, setup PIDs etc.

Note: Use "Internal View/Forward with No Display" for full immersion FPV flights:

Setup (Linux)

For Linux, all steps are analogous to Windows.

Setup (MacOs)

Sorry, MacOs in not supported currently (assistance needed to build plugin for MacOs, see development.md).

Flight controller configuration

Flight controller should be fully configured like for the real flight. There is no need to configure mixer and motors output.

Configure Platform type: Flying wing for INAV Sufwing in INAV Configurator.

It is possible to use plugin with any other airplane (copy HITL plugin from NK_FRVSurfWing\plugins\INAV-X-Plane-HITL to corresponding Aircraft subfolder of other airplane).

Platforms other than "Airplane" are not supported.

Note: If FC is mounted on UAV, you can use profiles to have different PIDs for simulated airplane. Motor and Servo outputs are disabled in simulation mode.

Note: There is no need to connect battery, if receiver is powered from USB connection.

Pids and rates

See recommended starting pids for INAV SurfWing (Platform: Flying wing) nkfpvsurfwing.md

Sensors simulation

Plugin will simulate sensors, enabled in FC's configuration.

In minimal case, you need FC with some kind of receiver attached.

No real barometer and GPS sensors are required.

FC with analog OSD is highly recommended. If FC does not have OSD chip, there will be no OSD in simulator.

There are two modes of simulation:

  • simplified simulation: attitude is passed from X-Plane.
  • full simulation: attitude is estimated from sensors data

Due to slow update rate (update rate can not be larger then X-Plane FPS) and no synchronization beetween INAV cycles and X-Plane FPS, full emulation mode will show noticeable problems with estimation ( drifting horizon ). Simplified emulation is recommended for debugging code not related to IMU.

Sensors not listed below are not simulated. Please disable in INAV configuration.

Accelerometer and gyroscope

Real acceleromerer should be calibrated in INAV Configurator. Accelerometer orientation settings are not relevant for simulation.

Barometer

Barometer will be simulated if enabled in INAV Configurator. If real barometer is not present, select "FAKE" type.

GPS

GPS functionality will be emulated if enabled in INAV Configurator. It is not required to have real GPS sensor connected.

X-Plane simulated world is build based on real world map data. GPS coordinates in game correspond to real locations.

Simulated GPS Fix can be switched in menu:

Magnetometer

Magnetometer is simulated if selected in INAV configurator. It is not required to connect real sensor. Select QMC5883 if there is no real sensor present. Calibration is not required.

Battery sensor

For convience, it is possible to simulate 3S battery presense:

  • infinite 3s battery
  • discharged 3s battery
  • a battery which lasts a period of time on full throtle, 2x time on 50% throtle etc.

Pitot

If enabled in menu, airspeed from X-Plane will replace readings of pitot.

Pitot should be enabled in INav Configurator.

It is possible to use VIRTUAL pitot device.

Note: VIRTUAL pitot is not supported on 411 and 722 CPUs (you will not be able to arm).

Note: VIRTUAL pitot will fail initialize if GPS sensor is disabled in configuration.

OSD

OSD is rendered in X-Plane exactly as configured in INAV Configurator.

It is highly recommended to use Flight Controller with OSD to see system messages on screen.

The following requirements should be met to have OSD drawn in X-Plane:

  • OSD should be configured as AUTO, PAL or NTSC type in "OSD" tab in INAV Configurator.
  • OSD should be enabled in "Configuration->Other features->OSD" in INAV Configurator.
  • OSD chip should be present on Flight Controller (MAX7456). OSD will not work without MAX7456 compatible chip. OSD will not work if HD Zero, DJI or Pixel OSD selected in configuration.

The following options are present in menu:

  • None: disable OSD rendering
  • AUTO: number of OSD lines is provided by FC
  • PAL: force rendering of 16 OSD lines
  • NTSC: force rendering of 13 OSD lines
  • Smoothing: Nearest: Use nearest pixels for characters rendering
  • Smoothing: Linear: Use linear smoothing for characters rendering

OSD is using Bold font from INAV Configurator. It is possible to replace font (\plugins\INAV-X-Plane-HITL\64\assets\osd_font.png) with other font from INAV Configurator https://github.com/iNavFlight/inav-configurator/tree/master/resources/osd

Beeper

For convience, it is possible to mute beeper in simulation mode:

Analog Video link quality simulation

Plugin will simulate analog video link quality acccording to setting. Home point is independent from FC home point. Home point is set to position on ARM.

Flight path drawing

Plugin can draw flight path on X-Plane map.

Coordinates can be extracted from:

  • Latitude/Longitude from OSD - extracted from OSD. Note that these number have low accuracy and are not updated synchronously. Path will have jittering under zoom.
  • debug[0]/debug[1] as Latitude/Longitude - assumed that coordinates are provided in debug[0]/debug[1] variables by custom INAV build (int32_t, int32_t).

Other menu options:

Path is drawn on "INAV HITL" layer:

Teleporting to GPS coordinates

An option in Map menu allows to teleport plane to any GPS location from clipboard.

Right click in Google Maps, then click on the coordinates to copy them to clipboard:

Then select Plugin->INAV HITL->Map->Teleport to location (from clipboard)

This works Ok for small distances. If you teleport to the other side of the Earth, you may find yourself in the empty space. Try to teleport again, it usually works.

Servo autotrim

Autotrim and servo autotrim have no effect in simulation (TODO).

Development

See development.md

Special thanks

Many thanks to:

  • Sergii Sevriugin for initial implementation and a lot of testing
  • NKDesign for NK FPV SurfWing RC plane for X-Plane
  • b14ckyy for Surfwing 3D model

Links

inav-x-plane-hitl's People

Contributors

romanlut avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.