Fly a Parrot Minidrone Using Hover Parrot Minidrone Simulink Template

The Hover Parrot Minidrone project template and the parrotMinidroneHover project, which are available in the Simulink® Support Package for Parrot® Minidrones, enable you to fly a Parrot minidrone. Once the model is deployed, the drone hovers at an altitude of 1.1 meters for a specified flight time before powering off.

Before you begin, make sure that you have licenses for these products:

  • Simulink

  • Aerospace Blockset™

  • Aerospace Toolbox

  • Control System Toolbox™

  • Signal Processing Toolbox™

  • Simulink 3D Animation™

Open and Deploy the Hover Model and Start the Flight

  1. Start the Simulink project using either of the two methods:

    • On the Simulink Start Page, navigate to Simulink Support Package for Parrot Minidrones, and select Hover Parrot Minidrone.

    • At the MATLAB® prompt, type:

      parrotMinidroneHoverStart

      This opens a Simulink project with the parrotMinidroneHover model and loads the required workspace variables.

  2. Run the parrotMinidroneHover model in normal simulation mode. Navigate through the different subsystems to learn about the modeling hierarchy and quadcopter dynamics. You can also view the Simulink 3-D animation of the model. For more information, see Quadcopter Dynamics.

  3. Once the Simulink project is open, click the Project Shortcuts tab and perform one of the following tasks based on the type of Parrot minidrone connected:

    • If the host computer is connected to a Parrot Rolling Spider, click Set Rolling Spider Model.

    • If the host computer is connected to a Parrot Mambo, click Set Mambo Model.

  4. In the parrotMinidroneHover model, right-click the Flight Control System reference model, and select Open As Top Model. The flightControlSystem model opens in a separate window.

    Note

    In the flightControlSystem model, do not change the root level input ports, output ports, or the signals through them.

  5. In the flightControlSystem model, click the Deploy to Hardware icon, . After the build process and deployment is successful, the Flight Control Interface is launched automatically if you had selected the option Launch Parrot Flight Control Interface automatically after build in the Configuration Parameters dialog box in Simulink (see Model Configuration Parameters for Parrot Minidrone).

  6. Before flying the Parrot minidrone with full speed, test the model at low speed by spinning the motors at low power. Open the Flight Control Interface (see Step 1: Open the Flight Control Interface). Drag the PowerGain slider to 20, which sets the power gain of the motors to 20%.

  7. Click START to start the model deployed on the drone. The motors on the Parrot minidrone start. The propellers spin for the time defined as flight duration (by default, the simulation time) and stop.

  8. To prepare the Parrot minidrone for flight, set the power gain of the motors to the highest value (100%). Drag the PowerGain slider to 100.

    Note

    Before flying the Parrot minidrone (as explained in the next step), adhere to the following safety procedures:

    • Ensure the safety of people, animals, and property in the vicinity of the flight.

    • Wear safety glasses at all times.

    • Place the drone on a flat surface before starting.

    • Fly the drone only indoors, with an open area greater than 10x10 feet, over a non-glossy floor.

    • Always be ready to stop the flight. The Flight Control Interface displays the STOP button after the motors on the drone start.

  9. Click START to start the flight of the drone. The motors on the Parrot minidrone start, and the drone performs a vertical take-off to an altitude of 1.1 meters. The drone hovers at this position for the time defined as flight duration (by default, the simulation time), and the motors stop after the flight duration is completed.

    To stop the flight before the flight duration is completed, click STOP in the Flight Control Interface.

  10. Perform the flight analysis:

    • Click Flight Log to download the flight log. The file droneFlight.txt is downloaded to the Current Folder in MATLAB.

    • Click MAT File to download the MAT-file. The file RSdata.mat is downloaded to the Current Folder in MATLAB.

      Note

      To enable MAT-file logging, Simulink Coder™ must be installed on the host computer. Additionally, you must enable the options Use Simulink Coder features and MAT-file logging in the Configuration Parameters dialog box in Simulink model (see Simulink documentation)

      The data in RSdata.mat contains various estimated outputs.

After successfully flying the Parrot minidrone using the parrotMinidroneHover model, you can now redesign the controller logic in Simulink. Deploy the new model on the minidrone by following the same steps, and start the minidrone flight using the same commands. Always test your model with a low value of power gain (10–20%) for the motors. After you are confident about the flight, increase the power gain and run the model on the minidrone.

Landing Logic in parrotMinidroneHover Model

The control logic to land the drone is present in Flight Control System > Path Planning subsystem.

Two fields have been added to the Command bus (highlighted in the below figure):

  • land_drone - This flag will be set when the Land button on the Parrot Flight Interface is clicked.

  • time_remaining - This is the time remaining for the simulation to finish.

These two fields will be used to enable the landing of the drone.

This landing is achieved using two subsystems - Landing Enable and Landing Logic.

The Landing Enable subsystem defines the logic required to enable the landing. The Land output of this subsystem is set when either of these occurs:

  • The Land Flag flag is set.

  • The time remaining is less than or equal to 5 seconds (this value can be changed).

The Landing Logic subsystem defines the logic required to land the Parrot minidrone. This subsystem is used in the parrotMinidroneHover model for the following:

  • Obtain the landing status from the Landing Enable subsystem, and initiate the landing logic

  • Define the landing step size that starts the descent of the drone along the z-axis. In this example, the landing step size is 0.2 meters. If you increase the value of landing step size, the drone descents faster along the z-axis.

  • Stop the model when the drone reaches 0.3 meters above the ground.

    Flag 255 is set in this case, and no error will be shown in the Parrot Flight Interface.

See Also

| |