This example shows how to use the MATLAB® Support Package for Parrot® drone to acquire and plot real-time navigation data of the Parrot drone
The MATLAB Support Package for Parrot Drones enables you to control and read the in flight navigation data of the drone.
In this example, you will learn to read the navigation data of the Parrot drone such as the speed, orientation, and height using MATLAB commands.
To run this example you need the following:
A fully charged Parrot Mambo FPV drone
A computer with a WiFi connection
Power on the Parrot Mambo FPV drone, wait for the LEDs on the camera to stabilize.
Connect your computer to the drone's Wifi network.
p = parrot();
Start the Parrot Mambo FPV drone flight from a level surface.
Execute the following command at the MATLAB command prompt the takeoff of the drone.
This task shows you how to initialize MATLAB to plot the navigation data.
animatedline to plot the variation in speed along the X, Y, and Z axes, separately.
Initialize the figure handle and create animated line instances hx, hy, and hz corresponding to speeds along the X, Y, and Z axes, respectively.
f = figure; hx = animatedline('Color', 'r', 'LineWidth', 2); hy = animatedline('Color', 'g', 'LineWidth', 2); hz = animatedline('Color', 'b', 'LineWidth', 2); title('DroneSpeed v/s Time'); xlabel('Time (in s)'); ylabel('Speed (in m/s)'); legend('XSpeed', 'YSpeed', 'ZSpeed');
Keep flying the drone along the desired path (forward diagonal path in this example) for 10 seconds and plot navigation data (speed) during this flight.
The default value of
move function is 0.5 seconds.
flightTime = 10; tObj = tic; while(p.BatteryLevel > 10 && toc(tObj) < flightTime) move(p, 'Pitch', deg2rad(-4), 'Roll', deg2rad(4)); speed = readSpeed(p); tStamp = toc(tObj); addpoints(hx, tStamp, speed(1)); addpoints(hy, tStamp, speed(2)); addpoints(hz, tStamp, speed(3)); drawnow; pause(0.1); end
Land the drone.
When finished, clear the connection to the Parrot drone.