Guy on Simulink

Simulink & Model-Based Design

Programming a PARROT Minidrone using Simulink 8

Posted by Guy Rouleau,

You know what I did this weekend? Yes, as the title of this post says, I deployed custom flight control software to my Parrot Rolling Spider Minidrone

Simulink Support Package for PARROT Minidrones

Last Christmas, my girlfriend got me one of those Parrot Rolling Spider Minidrone.

PARROT Mini drone

Immediately, I thought it would be cool to program it using Simulink. At that time, I did some research and it sounded pretty complicated to install a custom firmware and glue all the necessary code together.

Not anymore, with the recent release of the PARROT Minidrones Support Package.

Today I will describe my first experience using this package.


To get started, open the Add-On Explorer from the MATLAB toolstrip.

Add-on menu

In the Explorer, search for "PARROT Minidrone", click Install, and follow the instructions. Once the package is installed, the installer will guide you through the hardware setup.

This setup will first update the minidrone firmware. Notice that once the firmware is updated, you will not be able to fly the minidrone from the smartphone app anymore. As one of my colleagues likes to say: When you update the firmware, you are converting a toy into an experimental device.

Updating firmware

If you want to bring your minidrone back to "toy mode", you will need to go to the PARROT website and follow the instructions to reset the original firmware.

Once the firmware is updated, you will need to connect to the minidrone through Bluetooth. Once again, the Hardware Setup window will guide you through all the steps:

Connecting to the minidrone

First Test

The best way to get started with programming the minidrone is using the Quadcopter Project, included with the Aerospace Blockset. In MATLAB, type asbQuadcopterStart to open the example.

Quadcopter Example model

This example is a full simulation of a PARROT minidrone. As you can imagine, we will not generate code for this entire model. What we want is generating code for the model flightControlSystem.slx, which is referenced by the FCS block.

Quadcopter Flight Control Model

In the Simulink Project click on the shortcut named Set PARROT Target

Configure the model for PARROT drone

This will setup a few things in the model configuration to make the generated code compatible with the minidrone.

Configure the model for PARROT drone

In the model, click the Build Button to generate code. Once the code generation is complete, go to the MATLAB prompt to connect to the minidrone, and start execution of the code.

Starting the code

For a first test, the line p.setPowerGain(20) is probably a good idea. It will instruct the drone to use 20% of the power available. That way, the drone will not fly, but the motors will move to confirm that the code is running.

What's Next?

The way things work, the customized firmware expects a library with a specific function and signature. In the example model, there are two bus objects specified on the two root-level Inport matching this expected signature. As output, a vector of 4 power commands, one per motor, is expected.

Available Sensor

To familiarize yourself with all the sensors available, I recommend enabling MAT-file logging in the model configuration, and use To Workspace blocks in the model to log the sensors signals. After your flight terminates, you will then be able to exeute p.getMatFile to retrieve the logged signals from the drone and analyze them.

My First flight

Confirm that I could change the model and see the effect, I used a Signal Builder to command the drone to fly at a fixed height and move left and right. Here is what it looks like in action:

Now it's your turn

Install the Simulink Support Package for PARROT Minidrones and let us know if you are able to improve the stability of the flight controller, or implement cool features like line or target tracking using the downward pointing camera.

If you want to learn more on that topic, I also recommend registering for the upcoming webinar on Programming Drones with Simulink that will be held on December 7th.

8 CommentsOldest to Newest

John Judge replied on : 1 of 8

did you have any issues updating the firmware? I am trying to do this type of project but can’t get past the firmware update.

ChangKi Sung replied on : 2 of 8

Hi, I am having trouble at opening the example of the Simulink Model. I got this message ‘Undefined function or variable ‘asbQuadcopterStart’.’.
I am sure that the aerospace toolbox is installed on my computer. My version of the Matlab is 2017b. Do you know how to open it?

ChangKi Sung replied on : 5 of 8

@Guy Rouleau Thanks, I got the Aerospace Blockset, then I updated firmware. But, I got a new problem. I modified the signal builder then I deployed the ‘flight control system’ on the parrot minidrone, but the drone does not move. I tested on the 3D simulation, it moved depends on the signal builder. Is there any possible reason for this problem?

@ChangKi Sung: The Signal builder is in the top model, used only for simulation. You can either send command to the drone using the parrotminidrone object, or modify the flightControl model to specify commands there.

Yanis Bouhraoua replied on : 7 of 8

I’m working on Parrot RS Mini-drone, and I want to use the camera on it to process a line following or recognition of geometric shapes. Any body have any documentation attached to how to use OpticalFlowData signal in Simulink?

Greg Drayer Andrade replied on : 8 of 8

Hi Yanis,
Thanks for the question and interest in using the down-facing camera to process line following or object recognition algorithms. We are currently investigating this question and considering possible use cases. It would be great to hear more about your use case and make sure to capture any additional requirements. Please send me a private message through my File Exchange profile.
Thanks again,

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide