Main Content

Visualize 3D Scenarios in Unreal Engine with PX4 Host Target Simulation

This example shows how to use the UAV Toolbox Support Package for PX4® Autopilots to demonstrate 3D scenario Simulation with PX4 Host Target Simulation. For visualization, you can use this example model along with other models running in Simulation-In-Hardware (SIH) . This example is compatible with all existing SITL examples.

Prerequisites

Model

For visualization, you can use this example model along with PX4 based flight controller models. It is recommended to open this model in a separate MATLAB instance to avoid slow performance and potential latency in visualization.

The controller model you use with this model must have Simulink selected as the vehicle visualization option. Verify the visualization option using these steps.

1. In the controller model, go to Modeling > Model Settings to open the Configuration Parameters dialog box.

2. Expand Target Hardware resources and in Build Options, ensure that you select Simulink for Vehicle visualization option.

3. Click Apply and OK.

Open the simulink_3DVisualization_HostTarget model.

Visualization for SIH in Host Target Workflow

This section outlines the visualization options and configurations in the Host Target Workflow.

  • Default Visualization: By default, the system uses UAV Animation Visualization with high fidelity.

  • Switching Visualization: Use the Visualization Selection button to switch to the UAV Animation Visualization, which is a low fidelity visualizer.

  • Model Configuration: The model utilizes the MAVLink Deserializer to obtain the vehicle's position in the NED (North-East-Down) frame and its attitude. This data is used solely for visualization purposes.

  • Airframe Selection: The default airframe is set to a quadcopter. To change the airframe, in the Simulink model, go to simulink_3DVisualization_HostTarget/Visualization Variant Subsystem/Simulation 3D UAV Vehicle Visualization and then double-click the Simulation 3D UAV Vehicle block.

In the Simulation 3D UAV Vehicle block parameter dialoge, select the required vehicle.

Alternatively, use the Visualization Selection button to switch to UAV Animation Visualization, which is a low fidelity visualizer.

In the UAV Animation block parameter dialoge, select the required UAV type.

Monitor and Tune the Model

To run the model for signal monitoring and parameter tuning, on the Hardware tab, in the Mode section, select Run on board (External mode) and then click Monitor & Tune to start signal monitoring and parameter tuning.

Related Topics