Main Content

MAVLink Connectivity for QGC, On-board Computer and Simulink Plant

Introduction

During the HIL simulation, both QGroundControl(QGC) and the plant model must communicate with the Pixhawk hardware over serial. However, only one of these applications can hold the serial port and communicate with the PX4 hardware during the HIL Simulation. Hence, the application which communicates with the Pixhawk hardware must also bridge the MAVLink communication between the Pixhawk and the other applications such as onboard computer workflow.

In PX4 HITL Workflow, the simulator (Gazebo or jMAVSim) acts as a bridge to share MAVLink data between Pixhawk and QGroundControl.

To replace the plant dynamics with the Simulink Plant for HIL simulation, an internal bridge to share the MAVLink data with the other applications is required. MAVLink connectivity provides a way to route MAVLink data stream from Pixhawk hardware to the mission planning software QGroundControl(QGC), On-board computer hardware, Simulink Plant, and vice versa in HITL workflow.

PX4 HITL Workflow with Simulink plant and MAVLink Bridge Blocks

The following diagram illustrates high level interface between multiple components used in PX4 HITL workflow.

HITL workflow

MAVLink Bridge Blocks

MAVLink Bridge Source

The MAVLink Bridge Source block reads MAVLink data stream from the Pixhawk board connected to the serial port and routes it to the Simulink plant model and the configured UDP/TCP objects. This block allows you to configure Serial, UDP, and TCP connections.

Ports

Output

expand all

This port outputs the MAVLink data stream.

Data Types: uint8

This port outputs the length of the data stream for the current time setup.

Data Types: uint16

Parameters

expand all

Select a serial port to connect to the Pixhawk board. If the required ports are not available in the list, select Specify manually and enter the serial port in the Serial Port (specify manually) field.

Enter the maximum output data stream length.

Click Add to add the destination UDP/TCP connections for data routing. The existing connections ('UDP','127.0.0.1','14550') are used for connecting to QGC.

Specify the time interval at which the block reads values from the serial connections and routes it to the added UDP/TCP connections.

MAVLink Bridge Sink

The MAVLink Bridge Sink block reads the MAVLink data from the source UDP/TCP ports, merges it with input data and writes to Pixhawk hardware connected to Serial port

Ports

Input

expand all

This port takes MAVLink data stream (uint8) as input.

Data Types: unit8

Parameters

expand all

Select a serial port for connecting to the Pixhawk board. If the required ports are not available in the list, select Specify manually and enter the serial port in the Serial Port (specify manually) field.

Note

You must select / specify the same serial port in MAVLink Bridge Source and MAVLink Bridge Sink blocks.

Click Add to add the source UDP/TCP connections for data routing. The existing connections ('UDP','127.0.0.1','14550') are used for connecting to QGC.