Navstik Report
Navstik Report
Tracking Using
Quadcopter
Kalpesh Patil
Electrical Engineering
IIT Bombay
ABSTRACT
Object tracking is very important component of the computer vision system.
It has multiple applications in video surveillance, navigation, 3D image
reconstruction, robotics etc. It has attracted many researchers in this field. This
project was aimed to continuously track an object using a movable camera
mounted on a quadcopter and instruct it to move towards the object. This paper
will give a brief idea about algorithms used for object tracking, hardware setup of
movable camera on quadcopter and softwares required for this task.
Algorithms for tracking in video feed are already discussed. We will use tilt
angle of the gimbal to bring the object on X axis. Similarly yaw movement of
quadcopter will try to bring the object on Y axis simultaneously. Set points for the
quadcopter motion will be generated. All three motion will happen parallel to
each other.
i. Quadcopter
All the below mentioned components were installed on an already
available quadcopter frame. It will be used for demonstrate tracking
ii. SJ4000 camera for capturing image
The camera attached to the gimbal below the quadcopter to capture
video feed
iii. Tarot t2D gimbal
A gimbal is a device which allows independent motion of the device
connected to it irrespective of the motion of the parent device where
base of the gimbal is connected. In short it will allow us to control motion
of the camera without interfering with quadcopter motion
iv. NavStik autopilot
The autopilot controller developed by NavStik having all necessary
sensors was used as controller to the quadcopter as well gimbal motion.
v. Interfacing board
Interfacing board is used for making connection from ESCs, gimbal and
other sensors and devices to NavStik
vi. ZigBee modules
They are used for serial wireless communication
vii. Lidar
This a sensor used for measuring distances. It uses Laser beam instead of
sound waves as in Sonar
viii. AV Tx-Rx
5.8 GHz AV transmitter-receiver pair was used to send video feed
wirelessly from quadcopter to the ground
Major Blocks
Image Processing
on off board
computer
Gimbal
Quad Movement
Movement
There are three major components in the project with interconnection of data flow
amongst themselves.
(b) and (c) will result in motion of gimbal and quadcopter respectively which will
change the position of the object in the video feed. Therefore these two blocks
provide kind of a feedback to the object tracking code.
Algorithm Details
Initial attempts
Motion 2:
Motion 3:
The problem with this algorithm was waste of time caused by waiting for
the previous motion to end. All three motions are independent therefore
they can run independent of each other. Therefore all these loops should
run parallel to each other.
Delta 1
Frame 1(initial)
Till the next frame arrives gimbal would have been moved slightly and
position of the object would have been changed in image frame, therefore
new delta has to be calculated. We don’t know how much gimbal has
moved (gimbal doesn’t provide current angle). Therefore when we are
giving set point we can’t use the tilt information.
X: Unknown angle
by which gimbal
has rotated
Delta 2
This makes it impossible to give correct set point for quad movement. Since
we don’t know the current angle, we won’t be able to find correct angle to
give input for calculating Y set point. The only way to make sure to know
current angle was to use constant step size increment/decrement for
gimbal. This makes sure that gimbal has been rotated completely till the next
frame arrives and thus the angle we are using in code will be equal to the
physical angle of the gimbal. We tried with various step sizes. This made the
whole process of bringing the object very slow and inefficient. Although we
could have got exact set points for quadcopter motion using this approach
but it was very slow and hence dynamic tracking would have been
impossible.
Improved Algorithm
We found out a way to find heading direction for the quadcopter. Once we know
the heading direction, set point for the motion can be generated in steps. Thus
instead of using steps for gimbal motion, we decided to use steps for quadcopter
motion. We also found out way to convert X-Y coordinates in image to tilt angle
and yaw angle.
NOTE: Here we are assuming simple pinhole model for the camera (image forming
at the focal length of the lens).
If we could get feedback from gimbal (tilt), the following table can be used to
calculate set points
Quantity Value
angleX atan(x*p/f)
angleY atan(y*p/f)
h: height
p: pixel size
f: focal length
x: X coordinate in image
y: Y coordinate in image
We need “tilt” only for X and Y set points. If we don’t get feedback, we can use
some other technique to give the set point. Above mentioned values are tested
for tilt and yaw and they have produced positive results. The technique mentioned
below for the quadcopter motion has not been tested.
Assuming an effective closed loop controller for tilt and yaw, most of the time
object is going to remain at the centre of the image frame. We can generate a
set point step for quadcopter motion which will depend upon X and Y coordinates
of the object in image. When object is at the centre, we know quad has to move
in straight direction. This movement of quad will create an offset which will be
immediately removed by the motion of the gimbal and yaw of the quadcopter.
This is how we will initiate quadcopter motion. Next part is to terminate its motion.
Motion of the quadcopter will be terminated when it hovers exactly above the
object. For that two criteria should be satisfied simultaneously:
Since we are not getting any feedback from gimbal, we won’t realise when
camera is pointing downwards. Therefore a marker can placed below the
quadcopter, which will come into view of camera when it is looking downwards.
This will work as a flag to terminate the quadcopter motion. We can get this done
by continuously looking for the flag in the desired pixel area of the frame. This is
how motion of quadcopter is going to terminate. All these things are going to
happen in a single closed loop which will eventually generate smooth motion for
the quadcopter. For the set point generation we can use different methods. We
can use a hybrid method which will generate constant set point when object is at
the centre and will generate an offset above the constant step when it is not at
the centre. The offset will be determined by X-Y coordinates in image. X set point
also be modified by directly using angleX. There are plenty of possibilities to take
this forward.
HARDWARE SETUP
Gimbal tarot t2D
It is a two axis motion controller specifically designed GoPro Hero 3 camera. It
properly balances the mentioned camera. Datasheet for gimbal is easily available
on the internet. It consists of brushless motors which control the tilt and roll angles of
the gimbal. The specifications are as follows:
Power Supply
It can run on 7.4V – 14.8V DC supply, but 12V was recommended. We
connected it directly to the main three cell LiPo battery
Control inputs
All three control inputs take PWM signals
1. Mode selector
It can switch between velocity mode (1000 PWM) and position mode
(2000 PWM). The default mode is velocity mode, if left unconnected.
2. Tilt input
This similar to pitch in default conventions. The range is from -135 (1000
PWM) to 90 (2000 PWM). One should note that 1500 PWM will correspond
to front facing camera while 1200 will correspond to downward facing
camera
3. Roll input
Range is from -45 to 45 for the range of PWM as in tilt. Here also 1500
PWM signal will correspond to centre.
A mechanical joint was created already to attach it below the quadcopter. The
tarot t2d gimbal which we were using was specifically designed to balance the
weight of GoPro Hero 3 camera (SJ4000 is similar to original GoPro Hero 3 in terms
of physical aspects).
Sensor: N201405270ZV02
Make sure glue bulge formed on microUSB pin after soldering with transmitter wires
is small enough to be accommodated in the slot for camera on Gimbal. Also it
should be thick enough to maintain connections even after collisions with
surrounding
NavStik autopilot with interfacing board
NavStik autopilot works as the brain of the quadcopter and controls all the devices
connected to it. There are several in built sensors present in NavStik autopilot chip
like barometer, magnetometer, gyroscope and accelerometer. NavStik also
provide slot for connecting GPS antenna. GPS module is already installed on
NavStik. GPS antenna should be connected/soldered to use GPS.
We used pro-board as interfacing board to connect ESCs, gimbal, Lidar, XBee etc.
devices to NavStik. We used GPIO pins 1 to 4 for connections of ESCs. 5th and 6th
pin were used as PWM output pins for roll and tilt input of gimbal respectively. Also
Lidar was tested using one of the GPIO pins (removing gimbal)
XBee modules and IvyGS board
XBee modules are used for wireless communication. We used mavlink protocol for
sending commands and data from off board computer to quadcopter and vice
versa. Before using XBee modules, they should be paired and set to the required
baud rate which we are using for sending or receiving messages. Otherwise
messages will not be sent or received. This is done using XCTU software. A separate
blog has been written for detailed information on configuring XBee modules
IvyGS board acts as interface for connecting XBee module to the computer. Also it
allows user to access terminal of NavStik, known as “nsh” terminal using HDMI
cable.
CAUTION: IvyGS board is very delicate and should be used with proper care while
connecting it to USB slot in computer. An USB extension can be used to avoid
potential damage
Lidar-lite
Lidar is a device used for calculating distances. It works on the same principle of
Sonar, but uses laser beam instead. We had decided to use it for finding height of
the quadcopter (we ended up not using the Lidar and used inbuilt barometer).
The Lidar should be powered with IC 7805 for its required value of 5V. It can
generate output in two different forms, I2C and PWM. We used PWM output
terminals of Lidar. The PWM output pin should be divided into two terminals, say
+ve and –ve. The +ve terminal can be connected directly to the GPIO pin and –ve
terminal should be connected using a resistor to ground of GPIO pin set. Some
changes in firmware has to be made to accommodate Lidar (instructions are
given on NavStik wiki page for connecting Sonar. Lidar can be incorporated
similarly if external connections are made properly). After that proper calibration is
required for converting PWM signal to height.
Turnigy 9XR RC
Quadcopter Assembly
Due to all the difficulties in tracking using TLD, we had to shift to an algorithm which
has lesser complexity than TLD at the same ability to track objects even when
angle of view is changed. Considering both the factors CamShift algorithm present
on OpenCV was the best choice for tracking simpler mono coloured objects.
CamShift algorithm is an extension to the mean shift algorithm. The Mean Shift
algorithm works well on static probability distributions but not on dynamic ones
(changing size of the object). CamShift is based on principles of the Mean Shift but
also a facet to account for these dynamically changing distributions. CamShift is
able to handle dynamic distributions by readjusting the search window size for the
next frame based on the zeroth moment of the current frames distribution. This
allows the algorithm to anticipate object movement to quickly track the object in
the next scene. Even during quick movements of an object, CamShift is still able to
correctly track.
CamShift works by tracking the hue of an object. The video feed is converted to
HSV space. The CamShift works in the following manner.
Once the location of the object is tracked, coordinates of the centroid are
computed. These coordinates generate tilt and yaw set points as mentioned in the
algorithm.
Firmware Changes
We used the latest “pandapilot_v4” firmware for NavStik. To control gimbal with
NavStik, changes should be made in the firmware. We decided to use pin 5 and
pin 6 for roll and tilt PWM inputs for gimbal. This needs isolation of these pins from
default configuration. After that these pins are to be configured to PWM outputs in
“pwm_output.c” file of the firmware. After initialisation, separate thread should be
run for continuously receiving mavlink commands containing tilt and roll data from
NavStik.
XCTU
This software is used for configuring XBee modules. They have launched their latest
GUI version for linux. The detailed information on configuring XBees using XCTU is
given on the blogs uploaded
NavCon
OpenCV library
We used OpenCV 3.0 library for running various object tracking algorithms. It
comes with large number of in built classes and functions which makes it easier to
use for image processing and can be ported easily in our code. Compilation and
linking instructions are easily available on internet
Logic Analyser
The software along with the hardware allows user to monitor PWM signals. It helps
in debugging as well as checking our script before actual implementation with
hardware
Minicom
This terminal based linux package helps in monitoring and sending data on various
ports of the computer. “nsh” terminal of NavStik can be accessed from minicom.
Also other devices connected via USB can be accessed through minicom.
QT 5.0
This is used as an IDE for creating various GUI based softwares. NavCon requires
installation of QT 5.0 or more for its installation on computer.
NavStik Pandapilot_v4
This is firmware which is to be flashed into NavStik autopilot. Whatever changes you
make in firmware will reflect in operation of NavStik firmware
Mavlink library
This is a library written in C++ used for wireless communication. Mavlink protocol
should be followed for sending and receiving commands/data wirelessly.
RESULTS AND TESTS
EVALUATION
Object tracking algorithms
Performance of different object tracking algorithms was tested against various
parameters like occlusion, changes in shape and orientation, execution speed,
fast movements etc. The table summarising the results is given below.
Change in Fast
Execution
Algorithm Occlusion shape or Robustness movement of
Speed
orientation object
STRUCK very good very good very bad very bad depends
Compressive
bad bad bad good very good
Tracking
CamShift (simple
very good very good very bad good very good
colour based)
Test specifications:
Gimbal Calibration
We had to map PWM values to the tilt angles of the gimbal. To make sure that
gimbal is working properly as mentioned in data sheet, this test was conducted. A
marker pen along the axis of rotation of gimbal was attached to one of the
corners of the camera. Manual commands were given using “nsh” terminal of
NavStik to set the PWM output of pins to the desired values. This caused rotation of
camera and thus arcs were drawn by the marker on the paper attached
perpendicular to the axis of rotation. Using simple geometric constructions angles
corresponding to the given PWM values were calculated. Thus proportionality
factor was found out. This was used wherever we wanted to convert angles to the
PWM values
The black arc indicates the amount of rotation caused due to sending PWM
commands. Red arrow is the marker attached to corner of the green camera. This
picture illustrates the test for roll. Similar setup was made for tilt also.
The plate is the object to be tracked. Camera is pointing towards the object.
Tilt of the gimbal is changed, focusing continuously on the object
Object was at the same position, but quadcopter was at some height. Now you
can observe that camera is pointing slightly downwards which indicates motion of
gimbal.
NOTE: Videos for above mentioned tests are available except for the position and
altitude hold and gimbal calibration
CONCLUSION AND
FUTURE WORK
This project was aimed at creating autonomous object tracking quadcopter.
Although it was difficult to achieve the final target from the scratch during the
specified duration of few weeks, the project has definitely contributed significantly
in that domain. This will help people working on this topic as well as projects along
these lines. Our biggest achievement was to incorporate autonomously controlled
gimbal on flying quadcopter with NavStik firmware. We were also able to achieve
yaw movement of the quadcopter on ground.
Future Work
1. Achieving feedback from gimbal
This could be the major milestone for achieving the target. Once we are
able to get feedback from gimbal, a closed loop controller can be
implemented easily for X-Y set points of the quadcopter. The expressions and
methods for calculating those set points is mentioned in the project. Tarot
has developed a software for windows which is used for monitoring gimbal
movement and flashing its own firmware. The source code of the software
isn’t available, therefore we are not in position to use their protocol for our
purpose. Gimbal is connected to computer using USB. If we somehow
decode the protocol used in that serial communication, we can get the
required angle information in our code. One must look for USB hacking of
gimbal for this purpose.
2. Designing and testing algorithm for quadcopter movement
If we are not able to get feedback from gimbal, we will have to design a
new algorithm for quadcopter movement. We have plenty of options
available to achieve this. One of the most feasible option is explained in
detail earlier in this report.
3. Using both tilt and roll of gimbal
This could also be an alternative to present algorithm. The problem with this
algorithm was its difficulty in tracking objects. If we could design a better
tracking algorithm, this can be considered for generating set points
4. Designing PID controller for tilt
We have used only proportional logic for generating set points for tilt. We
would like to design a full-fledged PID controller for generating tilt set points
Currently we are giving manually selected object as an input for tracking. An
extension to this project can be autonomously detecting an object from learnt
templates and take it as an input for further motion. Not only this, the project can
be extended in various manners like tracking and following multiple objects, taking
shots from different angles of the tracked object etc. Such projects will be
contributing a lot to the fields like aerial photography, autonomous surveillance,
vision based navigation etc. I hope this project helps all the contributors in future.
REFERENCES
Research Papers
1. People Tracking via a Modified CAMSHIFT Algorithm
Fahad Fazal Elahi Guraya, Pierre-Yves Bayle and Faouzi Alaya Cheikh
2. AUTONOMOUS DETECTION AND TRACKING OF AN OBJECT AUTONOMOUSLY
USING AR.DRONE QUADCOPTER
Futuhal Arifin, Ricky Arifandi Daniel and Didit Widiyanto
3. An Efficient Moving Target Tracking Strategy Based on OpenCV and
CAMShift Theory
Dongyu Li
4. Tracking objects with fixed-wing UAV using model predictive control and
machine vision
Stian Aas Nundal, Espen Skjong
5. Robust Feature-based Object Tracking
Bing Han, William Roberts, Dapeng Wu, Jian Li
6. Real-Time Compressive Tracking
Kaihua Zhang, Lei Zhang and Ming-Hsuan Yang
7. Particle Filtering for Visual Tracking
Pedram Azad
8. Tracking-Learning-Detection
Zdenek Kalal, Krystian Mikolajczyk and Jiri Matas
Surveys
1. REVIEW AND EVALUATION OF WELL-KNOWN METHODS FOR MOVING OBJECT
DETECTION AND TRACKING IN VIDEOS
Bahadır KARASULU
2. Performance Comparison of Kalman Filter and Mean Shift Algorithm for
Object Tracking
Ravi Kumar Jatoth, Sampad Shubhra, Ejaz Ali
3. The Visual Object Tracking VOT2014 challenge results
4. An Experimental Comparison of Online Object Tracking Algorithms
Qing Wang, Feng Chen, Wenli Xu and Ming-Hsuan Yang
5. Performance evaluation of object detection algorithms for video
surveillance
Jacinto Nascimento, Jorge Marques
6. A Superior Tracking Approach: Building a strong Tracker through Fusion
Christian Bailer, Alain Pagani1 and Didier Stricker
7. A SURVEY ON MOVING OBJECT TRACKING IN VIDEO
Barga Deori and Dalton Meitei Thounaojam
Codes
1. MO-TLD (Multi Object TLD)
https://github.com/evilsantabot/motld
2. Compressive Tracking
http://www4.comp.polyu.edu.hk/~cslzhang/CT/CT.htm
3. CMT
http://www.gnebehay.com/cmt
4. STRUCK
https://github.com/gnebehay/STRUCK
5. Open TLD
https://github.com/gnebehay/OpenTLD/releases
6. Particle filter
https://bitbucket.org/kschluff/particle_tracker