You are on page 1of 14

Management quadrocopters ArDrone 2.

0
through ROS with the joystick
This project of joystick quadrocopters ArDrone 2.0 c of ROS.
1. quadrocopters ArDrone 2.0
Parrot AR.Drone - This radio-controlled quadrocopter, ie a helicopter with four rotors placed on extension of the diagonal
beams. Himself AR.Drone is running the operating system Linux, as well as a remote control to quadrocopters can serve
almost any touchscreen smartphone and tablet Android or iOS. Distance sustainable management of Wi-Fi - from 25 to
100 meters, depending on the room and the weather conditions, if the flight is on the street.

Quadrocopters Parrot AR.Drone 2.0 is equipped with 4 motors power 14.5 W and issuing 28,500 RPM. The gearbox
gears nilatrona used for noise reduction and bronze self-lubricating bearings allow all this effectively rotate. On each
motor controller uses 8 MIPS AVR CPU, and the controller itself humidity resistant.Maximum flight speed - 18 km / h
on board quadrocopters updated version with 2 video cameras:
Front HD camera provides 720p, 30 fps angle lens with 92 degrees.
The lower chamber QVGA (320x240) 60 fps with the angle of the lens 64 degrees. Her AR.Drone also uses the measured
horizontal velocity.
"Brains" drone represent a 1GHz ARM Cortex A8 processor with a 800 MHz DSP TMS320DMC64x video. 1Gbit DDR2
RAM at 200MHz. And manage it all with the help of Linux 2.6.32. The connection to the "remote" control (which is the iOS
and Android Soup) occurs WiFi. So copter carries a WiFi point.
orientation in space is due to the 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer (magnetic compass), a
pressure sensor and an ultrasound altimeter
Specifications
Video features:

Real-time HD camcorder: 720p 30fps

Wide-angle lens: 92 degrees

H264 video coding format

Video is recorded and transmitted to the control unit or to the usb-storage

Capture and save images in JPEG (720p)

Specifications

3-cell Lithium-Polymer (LiPo) battery 1,000 mAH

Propellers specially shaped for easy maneuvering

4 brushless motor 14.5 W and a rotation speed per minute 28,500

Low noise Nylatron gears

Automatic stop all the screws in contact with an obstacle

Full software control motors

Resistant to water ingress motor controller

Special suspension control boards, quenching load

Weight: 380g with housing for flights on the street, 420g - with housing for indoor flight

Helicopter parts are made of wear-resistant and impact-resistant plastic

Any part of the helicopter is replaced with special tools

Electronics and Sensors

Processor 16MHz 32 bit ARM Cortex A8 with 800MHz video DSP TMS320DMC64x

Memory 16bit DDR2 RAM at 200MHz

Motor controller 8 MIPS AVR CPU

Wi-Fi b / g / n

3-axis accelerometer

3-axis gyro rotation angle 2000 degrees / sec

Barometric sensor with an accuracy of +/- 10 Pa (80cm above sea level)

60 fps QVGA vertical camera to measure the horizontal speed

3x axial magnetometer up to 6 degrees

Ultrasonic sensors to measure altitude

Operating system Linux 2.6.32

AR.Drone quadrocopter is not easy, and quadrocopter with ideas for the idea of augmented reality (Augmented Reality
Drone). For him, there is an augmented reality video games, and even had an open API.
Due to the low cost, a large number of high-quality sensors, as well as its open API, AR.Drone has become a popular
platform for scientific experiments and educational purposes. It is used in the works on automatic control, learning AI,
autonomous video surveillance, human-machine interaction, etc.
I had a desire to organize voice control AR.Drone of ROS, in the long term, he worked in tandem with the robot
Turtlebot. But first you need a safety net to make Ardrone controlled with convenient device. I decided to choose the
joystick.
2. Driver quadrocopters ArDrone 2.0 for ROS
Ardrone_autonomy is ROS driver for quadrocopters Parrot ArDrone. Supports quadrocopters ArDrone 1.0 and ArDrone
2.0. This package is an offshoot of the package ArDrone Brown. The package allows you to receive messages from
sensors ArDrone, receive images from the cameras, control the movement of quadrocopters and the LEDs.
Installation of ArDrone autonomy. First clone the code directory packages (ROS_PACKAGE_PATH - I ros_pkgs)
?

1
2
3
4

$
$
$
$

Cd ~ / ros_pkgs
Git Clone https: //github.com/AutonomyLab/ardrone_autonomy.git
Rosstack profile && rospack profile
Roscd ardrone_autonomy

Next - a compilation ArDrone SDK 2.0. Run the script build_sdk.sh


?

$ ./build_sdk

If the compilation was successful - check the contents of the lib directory
?

$ Ls ./lib

It must be so: libavcodec.a libavformat.a libpc_ardrone_notool.a libvlib.a


libavdevice.a libavutil.a libsdk.a
libavfilter.a libpc_ardrone.a libswscale.a
and reassembly
?

rosmake ardrone_autonomy

To run driver
?

rosrun ardrone_autonomy ardrone_driver

List of topics for the publication of data driver ardrone_autonomy

/ Ardrone / bottom / camera_info

/ Ardrone / bottom / image_raw

/ Ardrone / bottom / image_raw / compressed

/ Ardrone / bottom / image_raw / compressed / parameter_descriptions

/ Ardrone / bottom / image_raw / compressed / parameter_updates

/ Ardrone / bottom / image_raw / theora

/ Ardrone / bottom / image_raw / theora / parameter_descriptions

/ Ardrone / bottom / image_raw / theora / parameter_updates

/ Ardrone / camera_info

/ Ardrone / front / camera_info

/ Ardrone / front / image_raw

/ Ardrone / front / image_raw / compressed

/ Ardrone / front / image_raw / compressed / parameter_descriptions

/ Ardrone / front / image_raw / compressed / parameter_updates

/ Ardrone / front / image_raw / theora

/ Ardrone / front / image_raw / theora / parameter_descriptions

/ Ardrone / front / image_raw / theora / parameter_updates

/ Ardrone / image_raw

/ Ardrone / image_raw / compressed

/ Ardrone / image_raw / compressed / parameter_descriptions

/ Ardrone / image_raw / compressed / parameter_updates

/ Ardrone / image_raw / theora

/ Ardrone / image_raw / theora / parameter_descriptions

/ Ardrone / image_raw / theora / parameter_updates

/ Ardrone / imu

/ Ardrone / land

/ Ardrone / mag

/ Ardrone / navdata

/ Ardrone / reset

/ Ardrone / takeoff

/ Cmd_vel

/ Tf

List of services driver ardrone_autonomy

/ Ardrone / bottom / image_raw / compressed / set_parameters

/ Ardrone / bottom / image_raw / theora / set_parameters

/ Ardrone / bottom / set_camera_info

/ Ardrone / flattrim

/ Ardrone / front / image_raw / compressed / set_parameters

/ Ardrone / front / image_raw / theora / set_parameters

/ Ardrone / front / set_camera_info

/ Ardrone / image_raw / compressed / set_parameters

/ Ardrone / image_raw / theora / set_parameters

/ Ardrone / imu_recalib

/ Ardrone / setcamchannel

/ Ardrone / setflightanimation

/ Ardrone / setledanimation

/ Ardrone / togglecam

/ Ardrone_driver / get_loggers

/ Ardrone_driver / set_logger_level

Information obtained from the quadrocopters driver publishes the topic ardrone / navdata. Message Type
ardrone_autonomy :: Navdata
The following information
header: ROS message header

batteryPercent: Remaining battery drone (%)

state: the status ArDropne

0: not determined 1: Inited 2: ground 3.7: flight

4: Hovering 5: Test (?)

6: included 8: Landing 9: Looping (?)

rotx: left / right tilt in degrees (rotation around the axis X)

roty: Forward / backward tilt in degrees (rotation around the axis Y)

rotz: orientation in degrees (rotation around the axis Z)

magX, magY, magZ: magnetometer (only AR-Drone 2,0)

pressure: Pressure perceived barometer drone (only AR-Drone 2,0)

temp: perceived temperature sensor drone

wind_speed: Estimated wind speed (only AR-Drone 2,0)

wind_angle: Current wind angle (only AR-Drone 2,0)

wind_comp_angle: Estimated wind angle compensation (only AR-Drone 2,0)

altd: Estimated height (mm)

vx, vy, vz: linear velocity (mm / s)

ax, ay, az: linear acceleration (G)

tm: Timestamp of the data returned by Drone

The experimental subject Base published messages like sensor_msg / Imu, issuing evidence of linear acceleration,
angular velocity and orientation ustroychtva axes x, y, z.
Cameras
Both AR-Drone 1,0 and 2,0 is equipped with two cameras. A front camera is directed forward and one vertical camera
down. Driver ardrone_driver creates three threads ardrone / image_raw, ardrone / front / image_raw and ardrone /
bottom / image_raw. Each of these topics is published messages like image_transport
To display the camera (current)
?

rosrun image_view image_view image: = / ardrone / image_raw

or specific (say front)


?

rosrun image_view image_view image: = / ardrone / front / image_raw

Sending commands to AR-Drone


Rise - sending a blank message to the topic ardrone / takeoff
Landing - sending a blank message to the topic ardrone / land

Sboros parameters (emergency stop) - sending a blank message to the topic ardrone / reset
?

rostopic pub / ardrone / land std_msgs / Empty

After take-off motion control ArDrone need to send messages like geometry_msgs :: Twist topic cmd_vel
-Linear.x: move backwards
+ Linear.x: move forward
-Linear.y: move right
+ Linear.y: move left
-Linear.z: move down
+ Linear.z: move up
-Angular.z: Turn left
+ Angular.z: turn right
The range for each component should be from -1.0 to 1.0. The maximum range can be configured using the ROS
parameters are discussed later in this document. Publication of "0" value for all components make rumble keep hovering.
?

rostopic pub -r 10 / cmd_vel geometry_msgs / Twist

'{linear: {x: 0.1, y: 0.0, z: 0.0}, angul

LED animation
Call service ardrone / setledanimation will cause the execution of one of the 14 predefined animations for LED ArDrone.
Options

uint8 types: the type of animation that is a number in the range [0 .. 13];

float32 frequency: the frequency in Hz animation;

uint8 duration: the duration of the animation in seconds.

Type parameter animation:


1.

BLINK_GREEN_RED;

2.

BLINK_GREEN;

3.

BLINK_RED;

4.

BLINK_ORANGE;

5.

SNAKE_GREEN_RED;

6.

FIRE;

7.

STANDARD;

8.

RED;

9.

GREEN;

10.

RED_SNAKE;

11.

BLANK;

12.

LEFT_GREEN_RIGHT_RED;

13. LEFT_RED_RIGHT_GREEN;
14. BLINK_STANDARD.
These animations can be tested on the command line, for example,
?

rosservice call / ardrone / setledanimation 1 4 5

Flight animation
Call service ardrone / setflightanimation will perform one of 20 predefined animations flight (flight figures) for
ArDrone. Options:
uint8 types: the type of flight animation, the number in the range [0 .. 19]
uint16 duration: the duration of the animation. Use 0 for the duration of the default (recommended)
1. ARDRONE_ANIM_PHI_M30_DEG;
2. ARDRONE_ANIM_PHI_30_DEG;
3. ARDRONE_ANIM_THETA_M30_DEG;
4. ARDRONE_ANIM_THETA_30_DEG;
5. ARDRONE_ANIM_THETA_20DEG_YAW_200DEG;
6. ARDRONE_ANIM_THETA_20DEG_YAW_M200DEG;
7. ARDRONE_ANIM_TURNAROUND;
8. ARDRONE_ANIM_TURNAROUND_GODOWN;
9. ARDRONE_ANIM_YAW_SHAKE;
10. ARDRONE_ANIM_YAW_DANCE;
11. ARDRONE_ANIM_PHI_DANCE;
12. ARDRONE_ANIM_THETA_DANCE;
13. ARDRONE_ANIM_VZ_DANCE;
14. ARDRONE_ANIM_WAVE;

15. ARDRONE_ANIM_PHI_THETA_MIXED;
16. ARDRONE_ANIM_DOUBLE_PHI_THETA_MIXED;
17. ARDRONE_ANIM_FLIP_AHEAD;
18. ARDRONE_ANIM_FLIP_BEHIND;
19. ARDRONE_ANIM_FLIP_LEFT;
20. ARDRONE_ANIM_FLIP_RIGHT.
These animations can be tested on the command line, for example,
?

rosservice call / ardrone / setflightanimation 1 0

Flight animation can be run during the flight ArDrone.


You can try to direct the ArDrone and keyboard
rosrun teleop_twist_keyboard teleop_twist_keyboard.py
But I would not recommend it - it is very difficult to manage - a couple of hard falls quadrocopters forced me to abandon
the idea.
Connect the joystick
I imeelsya available joystick Defender Gamne Racer X7

Defender Game Racer X7 has 12 buttons (including the D-Pad and 2 analog sticks), as well as buttons Turbo, Clear and
Home. The device supports vibration feedback, which works with the help of 2 vibration motor. Connection to the
computer is done via USB. The joystick can operate in two modes, one of which HID-device, the other - the controller
XBOX360. Switching is done by pressing the Mode.
We connect the joystick to your computer with Linux.
?

$ Ls / dev / input

The joystick device called by the JSX, I had our joystick js0. Make sure that the joystick is working.
?

1
img

$ Sudo jstest / dev / input / js0

On the server, set the parameter setting joy_node / dev, which is the port connecting our joystick
?

$ Rosparam set joy_node / dev "/ dev / input / jsX0"

And the launch of the package assembly joy_node joy


?

$ Rosrun joy joy_node

And look at the messages published in the topic joy


img
Create a new ROS package
?

$ Roscreate-pkg vp_ardrone1 rospy std_msgs ardrone_autonomy joy

Install the package dependencies


?

$ Rosdep install vp_ardrone1

Putting package
?

$ Rosmake vp_ardrone1

Now we need to write a script that creates the node that will receive messages from the topic of joy and send control
commands quadrocopters Ardrone. The script is written in python.
Use the joystick to execute the following commands

take-off,

planting,

movement (up, down, left, right, up, down, turn) at the joystick,

hang,

LED animation 0-13,

Flight animation 0-14 of 19, except for flip (to turn a somersault string adjust num2 = min (num2 + 1,14) for num2
= min (num2 + 1,18).

The current value of the led-animation and flight-animation stored on the server settings (parameters and joystick_num1
joystick_num2). Recent data values sent to the topic cmd_vel also stored on the server settings (option). Here are the
contents (nodes / ros_ardrone1_joystick_to_move.py).
1

#! / Usr / bin / env python

2
3
4
5
6
7
8
9
10
eleven
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
thirty
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

# - * - Coding: utf-8 - * import


import
import
import
Import
from
from
from
from
from
from
from

roslib; roslib.load_manifest ( 'vp_ardrone1' )


rospy
subprocess
shlex
time

ardrone_autonomy.msg import *
ardrone_autonomy.srv import *
sensor_msgs.msg import Joy
std_msgs.msg import String
std_msgs.msg import Empty
std_msgs.msg import Int32
geometry_msgs.msg import Twist

def controller (data):


# Check takeoff - button start / 10
if (data.buttons [7] == 1) # off
rospy.loginfo ( "off" )
pub1 = rospy.Publisher ( 'ardrone / Takeoff' , Empty)
pub1.publish ()
time .sleep (1)
elif (data.buttons [6] == 1) # posadka- button back / 9
rospy.loginfo ( "landing" )
pub1 = rospy.Publisher ( 'ardrone / Land' , Empty)
pub1.publish ()
time .sleep (1)
elif (data.buttons [1] == 1) # next led animation - button B2
num1 = rospy.get_param ( "joystick_num1" )
num1 = min (num1 + 1,13) # 0 ... 13
rospy.set_param ( "joystick_num1" , num1)
serv1 = rospy.ServiceProxy ( 'ardrone / setledanimation' , LedAnim)
res1 = serv1 (num1,1,5);
rospy.loginfo ( "next led animation" + str (num1))
rospy.loginfo (res1)
time .sleep (1)
elif (data.buttons [0] == 1): # previous animation led - button A1
num1 = rospy.get_param ( "joystick_num1" )
num1 = max (num1-1,0) # 0 ... 13
rospy.set_param ( "joystick_num1" , num1)
serv1 = rospy.ServiceProxy ( 'ardrone / setledanimation' , LedAnim)
res1 = serv1 (num1,1,5);
rospy.loginfo ( "prev led animation" + str (num1))
rospy.loginfo (res1)
time .sleep (1)
elif (data.buttons [5] == 1) # hovered - button RB6
pub3 = rospy.Publisher ( 'cmd_vel' , Twist)
odom = Twist ()
odom.linear.x = 0.0
odom.linear.y = 0.0
odom.linear.z = 0.0
odom.angular.x = 0.0
odom.angular.y = 0.0
odom.angular.z = 0.0
pub3.publish (odom)
rospy.loginfo ( "floating !!!!" )
time .sleep (1)
elif (data.buttons [3] == 1) # next flight animation - button Y4

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

num2 = rospy.get_param ( "joystick_num2" )


num2 = min (num2 + 1,14) # 0 ... 18 (limited to flip)
rospy.set_param ( "joystick_num2" , num2)
serv1 = rospy.ServiceProxy ( 'ardrone / setflightanimation' , FlightAnim)
res1 = serv1 (num2,0);
rospy.loginfo ( "next flight animation" + str (num2))
rospy.loginfo (res1)
time .sleep (1)
elif (data.buttons [2] == 1): # previous flight animation - button X3
num2 = rospy.get_param ( "joystick_num2" )
num2 = max (num2-1,0) # 0 ... 18 (limited to flip)
rospy.set_param ( "joystick_num2" , num2)
serv1 = rospy.ServiceProxy ( 'ardrone / setflightanimation' , FlightAnim)
res1 = serv1 (num2,0);
rospy.loginfo ( "prev - flight animation" + str (num2))
rospy.loginfo (res1)
time .sleep (1)

elif (data.axes [0]! = 0.0 or data.axes [1]! = 0.0 or data.axes [3]! = 0.0 or data.a
pub3 = rospy.Publisher ( 'cmd_vel' , Twist)
joistick_prev_odom = rospy.get_param ( "joystick_prev_odom" )
odom = Twist ()
odom.linear.x = data.axes [1]
odom.linear.y = data.axes [0]
odom.linear.z = data.axes [4]
odom.angular.x = 0.0
odom.angular.y = 0.0
odom.angular.z = data.axes [3]
pub3.publish (odom)
joistick_prev_odom [0] = data.axes [0]
joistick_prev_odom [1] = data.axes [1]
joistick_prev_odom [2] = data.axes [2]
joistick_prev_odom [3] = data.axes [3]
joistick_prev_odom [4] = data.axes [4]
joistick_prev_odom [5] = data.axes [5]
rospy.set_param ( "joystick_prev_odom" , joistick_prev_odom)
rospy.loginfo ( "movement !!!!" )
else : # shutdown joysticks
joistick_prev_odom = rospy.get_param ( "joystick_prev_odom" )
odom = Twist ()
if (joistick_prev_odom [0]! = data.axes [0] or joistick_prev_odom [1]! = data.axes [1]
joistick_prev_odom [3]! = data.axes [3] or joistick_prev_odom [4]! = data.axes [4]):
pub3 = rospy.Publisher ( 'cmd_vel' , Twist)
odom.linear.x = 0.0
odom.linear.y = 0.0
odom.linear.z = 0.0
odom.angular.x = 0.0
odom.angular.y = 0.0
odom.angular.z = 0.0
pub3.publish (odom)
joistick_prev_odom [0] = 0.0
joistick_prev_odom [1] = 0.0
joistick_prev_odom [2] = 0.0
joistick_prev_odom [3] = 0.0
joistick_prev_odom [4] = 0.0
joistick_prev_odom [5] = 0.0
rospy.set_param ( "joystick_prev_odom" , joistick_prev_odom)
rospy.loginfo ( "stop on the joystick !!!!" )
#
# Rospy.loginfo (data.axes)
# Rospy.loginfo (data.buttons)

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

def listener ():


rospy.init_node ( 'joyctick' )
if not rospy.has_param ( "joystick_num1" ):
rospy.set_param ( "joystick_num1" , 0)
if not rospy.has_param ( "joystick_num2" ):
rospy.set_param ( "joystick_num2" , 0)
if not rospy.has_param ( "joystick_prev_odom" ):
rospy.set_param ( "joystick_prev_odom" , [0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
sub = rospy.Subscriber ( "Joy" , Joy, controller)
rospy.spin ()
if __name__ == '__main__' :
listener ()

Run
?

$ Rosrun vp_ardrone1 ros_ardrone1_joystick_to_move.py

You might also like