Main Content

Simulate a Quadcopter

R2026b

This example shows how to use the Simulation 3D Actor block to build a complex actor and animate individual actor components in the simulation 3D environment. You build a quadcopter from two STL files and animate the propellers.

Load Data

Download the example model and STL files.

exampleFolder = matlab.internal.examples.downloadSupportFile( ...
    'R2023a/sl3d/examples/','QuadCopter.zip');
unzip(exampleFolder)

Open Model

Open the quadcopter model.

open_system("Quadcopter.slx");

Simulink diagram of a quadcopter simulation with model components for body translation, rotation, and propeller inputs within a 3D scene.

Model Components

The model includes a Simulation 3D Scene Configuration block and a Simulation 3D Actor block named Quadcopter. The Simulation 3D Scene Configuration block implements a 3D simulation environment. You must include the configuration block when building Simulink models with Simulation 3D Actor blocks.

Double-click the Simulation 3D Actor block named Quadcopter to open the Block Parameters dialog box. The Main tab contains the Initialization script to create, build, and animate the Quadcopter actor. First, the script creates the Body actor, sets actor properties, and attaches the Body actor to the Parent actor in the world. Next, the script loads the QuadCopter_Body.stl file to build the actor shape, translates, and rotates the Body actor. Then, the script creates the Propeller actors, sets actor properties, and attaches the Propeller actors to the Parent actor in the world. Finally, the script loads the QuadCopter_Propeller.stl file to build each actor shape, translates, and rotates each Propeller actor.

The block parameter dialog box of the Simulation 3D Actor block shows parameters and the initialization script.

The Transform tab sets the initial transform properties for the Quadcopter actor.

Parameters of Simulation 3D Actor block that shows the transform tab with initial position, rotation, and scale.

The Inputs tab lists the inputs to the Quadcopter actor.

Parameters of Simulation 3D Actor block that shows the input tab with the input ports.

Simulate Model

Simulate the model to view the quadcopter animation in the Simulation 3D Viewer window.

3D visualization of a quadcopter model with four propellers in the simulation environment.

See Also

| | |

Topics