image thumbnail

Pixhawk Software-In-The-Loop (SITL) Connector for Simulink

version 1.0.0 (3.35 MB) by Kiril Boychev
A C++ S-function that uses the Asio C++ and MAVLink C libraries to send and receive data from the Pixhawk software-in-the-loop (SITL) simula


Updated 23 Jun 2022

From GitHub

View license on GitHub

Pixhawk SITL Connector for Simulink

Pixhawk SITL Connector Simulink model

A Simulink S-function for sending and receiving data to and from Pixhawk SITL Simulator

View pixhawk-sitl-connector on File Exchange

Build on Windows

To build the "pixhawk_sitl_connector.cpp" S-function:

Example use on Windows - QGroundControl running in Windows and PX4 software running in Windows Subsystem for Linux (WSL)

  • Download and install QGroundControl
  • Build the PX4 software in WSL
  • Open the "pixhawk_sitl_connector_example.slx" model
  • Open QGroundControl
  • In QGroundControl go to the "Application Settings > Comm Links" tab. Click the "Add" button to create a new "Comm Link". You can use "WSL" as the name. The type must be "UDP" and the port must be 18570. In the "Server Addresses" filed add the IP of your WLS instance. You can find your WLS instance IP with the "ip addr" command. Note that every time you start a new WLS instance the IP of the WLS instance will be different.
  • Run the "pixhawk_sitl_connector_example.slx" model. The model will wait in the initialization phase. This is normal as the model is waiting to accept a connection for the PX4 software.
  • Open a WLS instance and execute the following commands inside the PX4-Autopilot folder:
   export PX4_SIM_HOST_ADDR=
   export PX4_HOME_LAT=42.841448
   export PX4_HOME_LON=24.770727
   export PX4_HOME_ALT=0.5
   export PX4_ID=0
   make px4_sitl none_plane

Note: Use the host IP for PX4_SIM_HOST_ADDR. The host is your Windows OS, so use the IP of your Windows machine.

Cite As

Kiril Boychev (2022). Pixhawk Software-In-The-Loop (SITL) Connector for Simulink (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with R2022a
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.