# Continuous Object Tracking

## #Continuous Object Tracking Beyond a Single Drone's Battery Time

Object tracking is a popular and useful drone application. However, the maximum duration of tracking in drone object tracking applications is limited by the maximum flying time of a single drone. This limitation is also true in most of other drone orchestraction platforms.

In BeeCluster, we overcome this limitation by allowing multiple physical drones to work together to act as a single virtual (abstract) drone that can fly forever (an illusion).

You can materialize this virtual drone abstraction in BeeCluster by using the drone binding relationship - you can create a task and specify that the task should be non-interruptible but the task can be run on multiply drones.

When the task is running, the platform will monitor the drone assigned to the task. If the remaining flying time of the drone is not enough to finish the whole task, another drone will be sent off to continue working on the task prior to the moment when te first drone has to return home because of the low battery. If the task is very long, this drone hand-off could happen many times.

## #Real World Demo

In this case study, we build an application that can track a person from drones. In the experiment, we limit the flying time of the drones to one minute to simulate the limited battery time of drones. We show a video below to demonstrate how the hand-off between two drones looks like.

## #A Simple Code Example

We show a simplfied example in testcases/test3.py where the task is to visit a set of locations along the circumference of a circle.

This example can run in the simulator with two drones. We show the code of the task below.

def circle(bc, r):
interval = []
for i in range(32*4):
alpha = 2*3.1415926/32.0*i
bc.act("flyto", (r * math.cos(alpha), r * math.sin(alpha),30))
bc.act("gp:sense", None).val
if i > 1:
interval.append(time()-t0)
t0 = time()
bc.wait()
print("max interval: ", np.amax(interval))
print("average interval: ",np.mean(interval))
print("interval std: ", np.std(interval))
return (np.amax(interval), np.mean(interval), np.std(interval))

This task creates a set of waypoints on the circumference of a circle. The virtual drone has to visit them sequentially. As shown below, in the main function, we create the task with binding flags NonInterruptible=True and SameDrone=False.

if __name__ == "__main__":
bc = beecluster.Session(appID = "TEST-3")
h = bc.newTask(circle, bc, 80, TaskName="circle2", NonInterruptible = True, SameDrone = False)
result = h.val
bc.close()
assert result < result*3.0, "######## TEST-3 FAILED ######## Hand-off too slow!"

In fact, we use this example as a unit-test for the platform. The time intervals between any two iterations are measured. Most of the two consecutive iterations are assigned to a single drone, however, when hand-off happens, the two consecutive iterations are assigned to two different drones. In this case, the time interval between the two iterations could be longer than the time interval between two normal iterations. We consider this longer time interval as the overhead of the drone hand-offs. A good implementation should minimize this overhead.