Page tree
Skip to end of metadata
Go to start of metadata

This example is an culmination of multiple tutorials. Before completing this tutorial, you should complete these tutorials:

Development Environment

This example uses the Ubuntu 14, ROS Indigo,  MATLAB 206a environment; however, it should be comptaible with older versions.  This example also uses an AR Drone.



Drones can be dangerous. Be mindful of your surroundings. Do not attempt to catch a flying drone.

Start and Connect Drone

Connect drone to battery. Ensure that battery is secured to drone. Ensure that there are no lose wires hanging out.

Connect your computer to the drone's wifi.

Start ROS

Open a new window in the command line. Start ROS.


Start ROS Tools

Open a new window. The easiest way is to do this is with CTRL+SHIFT+T.  This opens a new tab in the same window.  Next, navigate to the folder where you did the Pioneer tutorial. This can be accomplished using the change directory, cd, and list, ls, commands. The folder should end with: /src/nre_p3at/launch

Launch the tools program.

roslaunch tools.launch

Three windows should open. Your topic monitor shows your topics. Your Node Graph shows what is connected to ROS as well as what topics are published and subscribed. The TF Tree shows...  Minimize the windows for now.

Start AR Drone Program

Open a new tab. Navigate to the folder where you did the "Up and Flying with AR" tutorial. The folder should end with: /src/ardrone_autonomy/launch

Launch the drone program.

rosrun ardone_autonomy ardrone_driver

This will connect your drone to the ROS architecture. Open your Node Graph and click refresh (Blue circle arrow in upper left corner). Your AR drone should appear.


In a new tab, open Matlab:


Once Matlab opens, start ROS in Matlab:


Return to the Node Graph and click refresh. a Matlab box should appear.

Simple Scripts

These simple scripts are examples. The publish function will launch your drone. Note that the "/ardrone/" can be replaced with another name when using a different type of drone. Use the Topic Monitor to browse the different topics.

Subscribe and Print Battery Percent

The following script subscribes Matlab to the navdata topic and prints the Battery Percent

NavData = rossubscriber('/ardrone/navdata')
compass = receive(NavData,1)

Use this a template for subscribing to data. Also, open the Node Graph. You will see the connection between the drone node and the Matlab node.

Subscribe to Camera

The following script subscribes Matlab to the front camera, "image_raw" topic, and shows the image.

ForwardVideo = rossubscriber('/ardrone/front/image_raw')
Video = receive(ForwardVideo,1)
img =readImage(Video)

The result should be a snapshot from your drone's camera. 

Launch and Land Drone (THIS WILL LAUNCH YOUR DRONE!)

The following script publishes the launch command to your quadcopter, pauses for 5 seconds, then publishes the land command to your quadcopter.

chatpub= rospublisher('/ardrone/takeoff','std_msgs/Empty');
msg = rosmessage(chatpub);
chatpub2= rospublisher('/ardrone/land','std_msgs/Empty');
msg2 = rosmessage(chatpub2);


These codes can be adapted and combined for other uses. Good luck. -JBT