This example shows how to use the Cannon block in Simulink Support Package for Parrot Minidrones to control a Cannon module attached to a Parrot Mambo minidrone.
The Simulink Support Package for Parrot Minidrones provides a Cannon block that you can use to control the Cannon module attached to a Parrot Mambo minidrone.
The Cannon block can be found in the Simulink library. To access the block from Simulink Library Browser:
1. Enter slLibraryBrowser at the MATLAB prompt.
2. In the Simulink Library Browser, navigate to Simulink Support Package for Parrot Minidrones.
In this example, you will learn how to use the Cannon block in the Code Generation Template to fire the balls from the Cannon module attached to the Parrot minidrone.
If you are new to Simulink, complete the Interactive Simulink Tutorial.
To setup and run Simulink model on a Parrot minidrone, follow the example described in Spin the Motors of a Parrot Minidrone without Flying the Drone.
To run this example, you will need the following hardware:
Parrot Mambo minidrone with a fully charged battery
Cannon module attached to the drone
Bluetooth Low Energy (BLE) 4.0 support on the host computer
1. On the Simulink Start page, navigate to Simulink Support Package for Parrot Minidrones and select Code Generation Template.
2. In the Simulink model, navigate into the Flight Control System, and insert the Cannon block from the library.
3. Add two Constant blocks and a Manual Switch block in the model, and connect the output of the Constant blocks to the inputs of the Manual Switch block.
4. Double-click the Constant blocks and set the Constant value as 1 and 0 respectively.
5. Connect the output of the Manual Switch block to the input of the Cannon block.
6. Connect the output port of the Cannon block to a Scope block. The output port provides the number of firing commands that are pending in the queue while the Cannon module is busy.
The completed Simulink model looks like this:
In this task, you will use the Monitor and Tune feature in Simulink to run the model on Parrot minidrone, and change the values of the Manual Switch block to start firing the balls from the Cannon module attached to the drone.
Before proceeding with this task, ensure that the Cannon module is properly attached to the Parrot Mambo minidrone and the balls are loaded in the Cannon module.
1. Go to the Hardware tab of the Simulink toolstrip, and click Monitor & Tune. The Simulink model starts running on the Parrot minidrone.
2. In the Simulink model, double click the Manual Switch block to change the input value to 1. The Cannon module starts firing the first ball after a few seconds.
Observe the value in the Scope block connected to the output of Cannon block in the model. The displayed value, which was initially 1 when you first clicked the Manual Switch block, changes to 0 after the ball is fired.
3. Double click the Manual Switch block twice to return to the input value of 1. The Cannon module starts firing the second ball.
Note: The Scope block displays the pending inputs that are queued up before the actual firing action of the Cannon module occurs.
The support package also provides a pre-configured model that you can use to work with the Cannon module of Parrot Mambo minidrone.
You can use the Keyboard Read block available with Simulink Support Package for Parrot Minidrones to control the input to the Cannon block. You can configure any key on the keyboard of the host computer to trigger the firing of balls from the Cannon module. For reference, look at this pre-configured model.