Guy on Simulink

Simulink & Model-Based Design

Programming a Parrot Minidrone using Simulink 19

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.

19 CommentsOldest to Newest

John Judge replied on : 1 of 19
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 19
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 19
@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 19
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 19
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 19
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 19
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 19
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 19
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 19
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.
Manuela Lopera Gil replied on : 15 of 19
Hi, I have problems with internal storage of parrot Mambo loading the image block and a trajectory block ¿How is possible to achieve a tracking mission with image processing without exceed the storage?. I mean, I've seen line detection and tracking and Mambo responds well but when I create the trajectory and add the image processing block to detect color just goes down. Thanks.
Ryan Debevec replied on : 16 of 19
I am haveing issues with the example. I get it to hover but when I try to bring in the commands like they did in the video I have issues. I opt to "fix" by allowing continuous signal but my quadcopter gets unstable and barely performs the task I give it. Don't need to somehow make it discrete (not sure how)? Also how do I access the camera for pictures to use for line following? Is it the same port as the opticalflow?
Maitreyee Mordekar replied on : 17 of 19
Hello Ryan, Can you please elaborate a little more on the issue you observe? Is there any specific error message that you receive when you try to deploy the model on the hardware? If so, can you share the error message? As far as the camera is concerned, accessing camera feature has been introduced from the R2018b version on MATLAB. You can use R2018b version of MATLAB to design your own image processing algorithms using the camera feed in simulations and on the hardware.
rayane benyoucef replied on : 18 of 19
@Guy Rouleau. Your tutorial was really helpful. thanks. I have two question that am hoping to get answers for : 1- if Am to change the block where the commands are sent I should change ' VSS_COMMAND' I know but how!! should I use set_parameter command or something of the sort! 2- I want to have a life streaming of the camera detecting a circle. How can I connect parrot mambo with WIFI not bleutooth to be able to use Parrot class Thanks
Jayanth Yelandur Keshava replied on : 19 of 19
Hi Rayane, If you are using R2018a and above, navigate into the "path planning" subsystem inside the "Flight Control System" subsystem. Here you can specify the path to be followed. This works with the simulation also. If you are using R2017b or earlier versions, navigate into the FCS->Flight Control System->Landing logic. There you need to modify the pos_ref bus to plug in the x-y-z inputs. As of now we don't support the WiFi connectivity. But you should still be able to see the live images from the drone's downward facing camera using External mode. Check out the examples and should be able to stream images. Regards, Jayanth