This project establishes a robust connection between X-Plane and PX4 SITL (Software In The Loop) to simulate drone flight in the X-Plane environment. Our goal is to deliver a realistic simulation experience where PX4 can control various drones within X-Plane, and with our continuous improvements, it's getting better all the time.
Curious about the new features in the PX4 X-Plane Plugin v2.0.0? Check out this demo video where I walk you through the simplified setup process, showcase the multi-airframe support, and test various drones like the Ehang 184, Alia 250, Cessna 172, and Bayraktar TB2. Whether you're a student, researcher, or industry professional, this quick overview will get you up and running in no time!
👉 Watch the full demo and installation guide here!
- Sensor Improvements: Fixed many sensor problems and inconsistencies.
- Multi-Airframe Support: Native support for multiple airframes including:
- Ehang 184
- Alia 250
- Cessna 172
- Bayraktar TB2
- In-Menu Airframe Selection: Change airframes directly from the X-Plane menu.
- Automated Setup Script: A full automation script that sets everything up for you in WSL or Linux environments. This serves as a temporary fix until the changes are merged into the official PX4 repository.
- Detailed Configuration Instructions: The
config.ini
file includes instructions for building custom airframes. - Pre-Loaded Parameters: Parameters are automatically loaded in PX4 build commands. However, if you need to load them manually, they are still available in the config folder.
Check out the new features in the v2.0.0 release. YouTube video tutorial for version 2.0 will be released soon!
For setup guidance and demonstrations, visit our YouTube playlist, which includes detailed tutorials and showcases the plugin in action!
We bridge X-Plane and PX4 using the Simulator MAVLink API, which facilitates the exchange of sensor and actuator data, providing a rich and accurate simulation environment.
The following table illustrates the message flow:
Message | Direction | Description |
---|---|---|
MAV_MODE:MAV_MODE_FLAG_HIL_ENABLED | NA | Mode flag when using simulation. All motors/actuators are blocked, but internal software is fully operational. |
HIL_ACTUATOR_CONTROLS | PX4 to Sim | PX4 control outputs (to motors, actuators). |
HIL_SENSOR | Sim to PX4 | Simulated IMU readings in SI units in NED body frame. |
HIL_GPS | Sim to PX4 | The simulated GPS RAW sensor value. |
HIL_OPTICAL_FLOW | Sim to PX4 | Simulated optical flow from a flow sensor (e.g., PX4FLOW or optical mouse sensor). |
HIL_STATE_QUATERNION | Sim to PX4 | Contains the actual "simulated" vehicle position, attitude, speed, etc. This can be logged and compared to PX4's estimates for analysis and debugging. |
HIL_RC_INPUTS_RAW | Sim to PX4 | The RAW values of the RC channels received. |
- Performance: Ensure X-Plane runs at high FPS for optimal EKF performance.
- Temporary Fix: This plugin is a temporary fix until merged with the official PX4 repository. For now, we use a forked version of PX4 with custom airframes and modifications.
- Bug Reports: If you find any bug, please report it on the GitHub issues page.
For full step-by-step instructions, follow the Version 2 Documentation.
This automated script is optimized for using with WSL (Windows Subsystem for Linux), where X-Plane runs on Windows, and PX4 SITL runs on Linux (WSL). It should also work natively on Ubuntu and other Linux distributions.
To quickly set up PX4 with X-Plane using WSL (Ubuntu 22.04), follow this simple step:
-
Run the setup script directly from your terminal:
First, make sure you are in your WSL Ubuntu terminal (launch it from PowerShell), then enter the following command in your WSL terminal:
cd ~ && curl -O https://raw.githubusercontent.com/alireza787b/px4xplane/master/setup/setup_px4_sitl.sh && bash setup_px4_sitl.sh
- Time Required: The installation process may take some time, depending on your system and configuration, especially the first time.
- Prompts: During installation, you will encounter several prompts asking you to customize the setup. You can either read and decide on each prompt or just let the defaults take effect (the script will automatically proceed with default settings if you don't respond).
- Once setup is complete, use the
px4xplane
command to run the simulation from anywhere in your terminal.
To remove the global paths and the px4xplane
command:
px4xplane --uninstall
For advanced users, manually clone and set up the environment using the forked PX4 repository:
-
Clone the repository:
git clone https://github.com/alireza787b/PX4-Autopilot-Me.git --recursive cd PX4-Autopilot-Me
-
Set up the environment:
bash ./Tools/setup/ubuntu.sh
-
Configure PX4 SITL:
- In Windows Terminal, check your IP address (e.g.,
172.21.144.1
):ipconfig
- In the WSL Terminal, inside the PX4-Autopilot directory, set the PX4 simulation hostname with your IP:
export PX4_SIM_HOSTNAME=172.21.144.1
- In Windows Terminal, check your IP address (e.g.,
-
Build the desired airframes:
make px4_sitl xplane_ehang184
Other airframes include:
xplane_alia250
xplane_cessna172
xplane_tb2
Refer to the official PX4 WSL setup documentation for more details, but use the forked repository instead of the official PX4 repo until the changes are merged.
If you need to define new airframes for your simulation, follow the detailed guide here:
👉 How to Define Custom Airframes in PX4-XPlane
This guide will walk you through the process of setting up custom configurations, mapping PX4 channels to X-Plane datarefs, and integrating new airframes into your simulations. Whether you're using existing X-Plane models or creating new ones in Plane Maker, this guide has you covered.
Feel free to reach out to me in the issue section if you need help. Having experienced contributors is greatly appreciated!
This project is licensed under the MIT License. See the LICENSE
file for more details.