Pixhawk Software-In-The-Loop (SITL) Connector for Simulink
Pixhawk SITL Connector for Simulink
A Simulink S-function for sending and receiving data to and from Pixhawk SITL Simulator
Build on Windows
To build the "pixhawk_sitl_connector.cpp" S-function:
-
Install a supported C++ compiler e.g. the MinGW-w64 Compiler or the MSVC Compiler.
https://www.mathworks.com/support/requirements/supported-compilers.html
-
Unzip the "includes.zip" archive. The archive contains the Asio C++ and MAVLink C libraries.
-
Open and run the "make.m" script. Make sure you run the script from within the folder it resides in.
Note: You may need to link against the ws2_32 library if you are using the MinGW-w64 compiler. E.g. -lws2_32.
-
If the build is successful you should see an "pixhawk_sitl_connector.mexw64" file in the current folder.
Example use on Windows - QGroundControl running in Windows and PX4 software running in Windows Subsystem for Linux (WSL)
- Download and install QGroundControl http://qgroundcontrol.com/downloads/
- Build the PX4 software in WSL https://docs.px4.io/v1.12/en/simulation/
- 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=192.168.1.11
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 (https://github.com/KBoychev/pixhawk-sitl-connector/releases/tag/1.0.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.