Pixhawk software-in-the-loop (SIL) connector for Simulink

Simulink C++ S-function for software-in-the-loop (SIL) simulation with Pixhawk.
241 Downloads
Updated 14 Jan 2023

Pixhawk SIL Connector for Simulink

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

View Pixhawk software-in-the-loop (SIL) connector for Simulink on File Exchange

Requirements

Files

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 (Simulink model running in Windows, PX4 Autopilot running in WSL 2)

  • Download and install QGroundControl for Windows https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html.

  • 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:

    git clone --recursive https://github.com/PX4/PX4-Autopilot
    cd PX4-Autopilot
    git checkout v1.14.0
    git submodule sync --recursive
    git submodule update --init --recursive
    export PX4_SIM_HOST_ADDR=x.x.x.x #(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/.

  • If you already have a build of the PX4-Autopilot source code start PX4 using the following commands:

    export PX4_SIM_HOST_ADDR=x.x.x.x #(the ip of the computer running the Simulink model)
    export PX4_SIM_MODEL=model (iris for v1.13.3 or none_iris for v1.14.0)
    ./bin/px4 -s etc/init.d-posix/rcS

Demonstration of the Pixhawk SIL connector example

Demonstration of the Pixhawk SIL connector example

Pixhawk SIL connector example

Pixhawk SIL connector example

Pixhawk SIL connector sensors

Pixhawk SIL connector example sensors

Additional information available at:

https://fst.aviumtechnologies.com/pixhawk-sil-connector

Cite As

Kiril Boychev (2024). Pixhawk software-in-the-loop (SIL) connector for Simulink (https://github.com/aviumtechnologies/pixhawk-sil-connector/releases/tag/1.4.0), GitHub. Retrieved .

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

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.4.0.0

See release notes for this release on GitHub: https://github.com/aviumtechnologies/pixhawk-sil-connector/releases/tag/1.4.0

1.1.0

See release notes for this release on GitHub: https://github.com/aviumtechnologies/pixhawk-sil-connector/releases/tag/1.1.0

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.