Work with AR Parrot 2 using ROS

From COINS Research Group
Jump to: navigation, search

Tutorial Overview

Title

Work with AR Parrot 2 using ROS

Author

Maram Alajlan

Note

This tutorial shows how to work with AR Parrot 2 using in ROS. This tutorial tested on ROS indigo under Ubuntu 14.04 LTS.

References

Required Packages

Install and compile following packages:

Working with real drone

Create new package (e.g. drone_application)

$ catkin_create_pkg drone_application std_msgs rospy roscpp

create a lunch 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

Real drone 1.png

You can view the robot camera using following command

$ rosrun image_view image_view image:=/ardrone/image_raw

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.by) 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 lunch 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

Tum drone launch.png

It is straightforward using tum_ardrone_GUI to command the robot

Tum ardrone GUI.png