Work with AR Parrot 2 using ROS

In this tutorial you will learn how to work with AR Parrot 2 using in ROS.

Note

This tutorial tested on ROS indigo under Ubuntu 14.04 LTS.

Note

Learn ROS and get your ROS certificate by enrolling in the Udemy course (Highest Rated course) ROS for Beginners: Basics, Motion and OpenCV.

Learn about ROS2: ROS Next Generation by enrolling in the Udemy course ROS2 How To: Discover Next Generation ROS

Required Packages

Install and compile following package:

Working with real drone

Create new package (e.g. drone_application)

catkin_create_pkg drone_application std_msgs rospy roscpp

create a launch file (e.g: launch_drone.launch) and paste following lines:

<launch>
        <arg name="droneip" default="192.168.1.1" />
        <node name="ardrone_driver" pkg="ardrone_autonomy" type="ardrone_driver" output="screen" args="-ip $(arg droneip)">
                <param name="navdata_demo" value="False" />
                <param name="realtime_navdata" value="True" />
                <param name="realtime_video" value="True" />
                <param name="looprate" value="30" />
        </node>
</launch>

Now launch the robot, in terminal:

roslaunch drone_application launch_drone.launch

This message will appear if it works fine

[ INFO] [1456020168.671768680]: Successfully connected to 'My ARDrone' (AR-Drone 2.0 - Firmware: 2.4.8) - Battery(%): 85
../../_images/Real_drone_1.png

You can view the robot camera using following command:

rosrun image_view image_view image:=/ardrone/image_raw
../../_images/2a.png
In new terminal you can control the robot by sending messages through topics, for example:
  • To takeoff:

    rostopic pub -1 ardrone/takeoff std_msgs/Empty
    
  • To land:

    rostopic pub -1 ardrone/land std_msgs/Empty
    

Control the robot from your code in python

To write simple code to takeoff, create your .py file (e.g: takeoff.py) and paste following code:

#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from std_msgs.msg import Empty

def takeoff():
        pub = rospy.Publisher("ardrone/takeoff", Empty, queue_size=10 )
        rospy.init_node('takeoff', anonymous=True)
        rate = rospy.Rate(10) # 10hz
        while not rospy.is_shutdown():
          pub.publish(Empty())
          rate.sleep()

if __name__ == '__main__':
        try:
          takeoff()
        except rospy.ROSInterruptException:
          pass

Launch the drone

roslaunch drone_application launch_drone.launch

Run you code in new terminal:

rosrun drone_application takeoff.py

Control the robot using tum_ardrone package

Create a launch file (e.g: launch_tum_drone.launch) and paste following lines:

<launch>

        <arg name="droneip" default="192.168.1.1" />
        <node name="ardrone_driver" pkg="ardrone_autonomy" type="ardrone_driver" output="screen" args="-ip $(arg droneip)">
                <param name="navdata_demo" value="False" />
                <param name="realtime_navdata" value="True" />
                <param name="realtime_video" value="True" />
                <param name="looprate" value="30" />
        </node>

        <node name="drone_stateestimation" pkg="tum_ardrone" type="drone_stateestimation">
        </node>
        <node name="drone_autopilot" pkg="tum_ardrone" type="drone_autopilot">
        </node>
        <node name="drone_gui" pkg="tum_ardrone" type="drone_gui">
        </node>

</launch>

In terminal:

roslaunch drone_application tum_drone.launch
../../_images/Tum_drone_launch.png

It is straightforward using tum_ardrone_GUI to command the robot

../../_images/Tum_ardrone_GUI.png