Aviumtechnologies

Pixhawk SIL Connector for Simulink

Simulink C++ S-function for software-in-the-loop simulation with Pixhawk.

View pixhawk-sitl-connector on File Exchange pixhawk-sil-connector GitHub repository

Requirements

  • Windows Subsystem for Linux (WSL)
  • MATLAB & Simulink (MATLAB R2022a or earlier)
  • MinGW-w64 or MSVC C/C++ Compiler
  • QGroundControl
  • PX4-Autopilot source code

Files

SILConnector.h
pixhawk_sil_connector.cpp
make.m
includes.zip (contains the Asio C++ and MAVLink C libraries)

Build instructions

  • Install MATLAB-supported compiler
    https://mathworks.com/support/requirements/supported-compilers.html.
  • Download the "pixhawk_sil_connector.cpp" and "make.m" files and the "includes.zip" archive.
  • Unzip the "includes.zip archive".
  • Run "make.m" to create a "pixhawk_sil_connector.mexw64" (Windows), "pixhawk_sil_connector.mexa64" (Linux), "pixhawk_sil_connector.mexmaci64" (macOS) file.

Note: If you are using a compiler other than MSVC (e.g. MinGW64) you need to add the "-lws2_32" flag to the "mex" command in the "make.m" file.

Use instructions

  • Download and install QGroundControl
    http://qgroundcontrol.com/.
  • Create a new "Comm Link" in QGroundControl via the "Application Settings" page. The type of the link must be UDP, thed port 18570, and the server address must be the ip address of the WLS 2 instance. You can use the "ip addr" command to find the ip of the WSL 2 instance. Note that the ip of the WSL isntance will change every time you relaunch the instance.
  • Open and run "pixhawk_sil_connector_example.slx".
  • Build the PX4-Autopilot source code in WSL 2 using the following commands:
    export PX4_SIM_HOST_ADDR=<the ip of the computer running the Simulink model>
    make px4_sitl none_iris
                        

    https://docs.px4.io/master/en/dev_setup/building_px4.html
    https://docs.px4.io/main/en/simulation/.

Example use of the Pixhawk SIL connector

Pixhawk SIL setup

Pixhawk SIL setup

Pixhawk SIL connector example Pixhawk SIL connector example sensors

Pixhawk SIL connector example