Guy on Simulink

Simulink & Model-Based Design

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Programming a PARROT Minidrone using Simulink 14

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.

14 CommentsOldest to Newest

John Judge replied on : 1 of 14
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 14
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 14
@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 14
Hello, 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? Thank's
Greg Drayer Andrade replied on : 8 of 14
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, Greg
ChangKi Sung replied on : 9 of 14
Hi, Have you tried to control using the Joy-stick Controller?? I am working on Parrot Rolling Spider drone. I want to control the drone through the Joy-stick controller. So, I modified the flightControl model to specify commands, but I found that the rolling spider drone is not stable if I use the joy-stick controller in both simulation and testing. The drone is moving left and right in the simulation if I change the VSS_COMMAND equal to 1. In addition, the drone is not getting the reference input from the joy-stick controller on testing. However, the drone is receiving the reference input from the joy-stick controller on simulation. (* I copied all the blocks in the Joystick block into the flightControlSystem block, then connected to the bus instead of input-port 1.) Thank you.
Kranthi Kumar replied on : 10 of 14
Hi, how to obtain smooth landing? I am able to perform the experiment which is explained in the " webinar on Programming Drones with Simulink", but after finishing the task my quadcopter is not landing smoothly. How to achieve a smooth landing? (
Jooa Pursiainen replied on : 11 of 14
Hi How common it is to have problems with the camera? I'm constantly getting the "problem with the optical flow" -error which shuts down the engines. Sure I can switch off the optical sensor, but then I loose the XY-estimation and this demo isn't really useful without it.
@Jooa: This issue is common during takeoff from surfaces without distinguishable features. This issue can be usually worked around during takeoff by placing something on that surface that provides sufficient contrast and ensuring lighting conditions that let the optical flow algorithm use the camera feed to obtain an estimate of horizontal velocities. Does this help? If not, are you experiencing this issue during takeoff or during flight? If during flight, can you provide more details about his experimental setup and on the conditions that make the issue repeatable?
Jooa Pursiainen replied on : 13 of 14
Okay, I guess I try different surfaces and see what happens. There has been no real consistency with this problem. Sometimes the drone drops right after the take off, sometimes it hovers awhile before dropping and sometimes it hovers as long as I want. Few times it has taken a quite dramatic plunge backwards before shutting down and when I check the estimators, they show some unwanted movement forwards which I guess it tried to correct, even though there were no real movement.
Shayan Ghani replied on : 14 of 14
I am trying to program the drone to fly in a straight line, however I am having trouble getting started. I am able to run the sample code, but I am confused-what need to be changed- the signal builder or the flight control system? And how do I do that? When I'm changing signals there is either an issue in building it or when it is deployed to hardware it seems to keep running the sample code instead of my changed version.

Add A Comment

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

Preview: hide