The problem of maintaining the visibility of a target given it's path and velocity bounds can be solved by using the dynamic programming approach. When the actions of the target are not specified, we run into trouble. All we might know about the target could be it's velocity bounds and perhaps the nonholonomic constraints. In this case, it is not feasible to consider computationally all actions that can be taken by the target over a multiple number of time steps and plan the observer's path, though in theory it is possible. For details about the problem, click here.
In this project, I have compared two different methods to solve the problem. In both methods, we are only given the bounds on the velocity of the target and the observer in a polygonal environment. The robots are considered as point robots for the sake of simplicity. If the robots were convex polygons, we could easily implement the same algorithms after finding the Cobs as done in the class programming assignment. The objective here was to find the advantages of one method over the other in terms of performance, issues concerning the real world problems were not concerned (e.g. uncertainty in motion, error in predicting the target's position and one's own position etc.).
Method 1: Disc of uniform probability density about the current target position
In the first method, the target moved on a fixed path in a convex polygonal world, and the only thing the observer knew about the target was it's maximum speed. The observer simply assumed a uniform probability distribution about the observer's current position, the shape of which was assumed a disc with radius equal to the maximum velocity of the observer.
The above disc was now divided into 36 pie shaped sections, which were further divided into 6 radial subdivisions. Each of this 'piece' was then checked for the visibility from the observer's current position, and the probability of the target remaining in the visible part of the disc was calculated.
Since we were also given the bounds on the observer's velocity, we also tested out 36 different angles in which the observer could move, with 6 different speeds, in order to maximize the probability of the target ending up in the visible part of the disc.
One obvious catch here is that some part of the disc could lie in the obstacles, so only counting the visible fraction of the disc would not yield the correct probability. Therefore, we also found the fraction invisible. The probability of target remaining visible could now be expressed as:
Pvis = Avis/(Avis+Ainvis)
To find the best move for the observer, the above probability was maximized, with the condition that the move did not lead the observer into an obstacle.
Finding the visibility of a pie segment was easy. We simply checked whether the segment from the observer's position to the pie segment intersected any obstacles. If it did, and if the pie segment did not fall into an obstacle, then it was considered hidden.
As given in the paper referred above, we can easily extend this method to calculate the probability of the target remaining visible after more steps, but it becomes computationally expensive, and also the method does not sound very reasonable, given that no robot would be interested in doing a random walk, except perhaps while exploring the world.
Method 2: Maximizing the time of escape
In this method also, the target moved on a fixed path as before, and the velocity constraints were given. Here the task was to find the direction the target could move in to get to the quickest point to escape. The problem is trickier here in the sense that we have to find the visibility polygon. The polygon was found by looking at all vertices that fell within the visibility range in the world one at a time, and adding an edge beginning at the vertex, stretching to the limit of visibility in the direction of the segment joining the observer position and the vertex if:
1. The edge did not go into the obstacle
2. If the edge entered another polygonal obstacle, it was truncated
up to the edge of the other polygon that it intersected.
The present position of the target was then compared with all these edges, and the nearest edge was found. This meant that the target could go towards that edge, and by crossing it, would become invisible. Our task now became one of maximizing the distance between the target and the nearest such edge.
In a same fashion as before, we checked multiple hypothetical positions of the observer, and found the position that maximized the time to escape. Apart from the minimum time to escape, another concern was that the target could run away beyond the visible area of the observer. To prevent that, we set the limit on the distance between the observer and the target to be a little less than the distance up to which the target could see. By doing so, we gave a little more importance to the minimizing of distance between observer and the target.
Also, by simply maximizing the escape time, the observer sometimes was found to stick to the walls of the obstacle, in order to maximize the distance from the edge to the target. This in general is not a good strategy because it severely restricts the field of vision of the observer. To counter this, we did not allow the observer to go very near (distance empirically was set to 1 unit) the obstacle edge.
A little care had also to be taken while finding the nearest edge, because sometimes the edge would not be visible to the target, in which case we assumed that the target would go 'around' the vertex that preceded the edge, and a distance of 'epsilon' was added to the distance to the escape point. The details of the implementation can be seen in the code. Obviously, if an edge falls within the region occluded by another edge, then the former edge was discarded. All these smaller details can also be easily seen in the code.
One common example for both the methods is shown below. It was found that if the target made some smart moves, both methods failed, but the first method failed more readily than the second method. Also, the behavior of the observer with the second method was intuitively more appealing.
Both the algorithms in general will not always give the correct results, due to the obvious reasons. Also, it is quite difficult to infer the target's future moves given it's present state, due to the large size of the state space. Given some partial knowledge about the present path and the goal positions in the environment, it would be a little easier to predict the future moves of the target.
In terms of computational efficiency, the second method worked faster compared to the first one, because the number of vertices in the world was much smaller than the number of slices considered from the probability distribution disc.
As it is, this problem is dubbed as a difficult one, and the solutions
found here did work in some cases, the methods failed in more difficult
cases.
References:
1. Robot Motion Planning; J. Latombe
2. Motion Strategies for maintaining visibility of a moving target;
S. LaValle et al
3. Probability, Random Variables and Stochastic Processes; Papoulis
I have tried to provide one exhaustive, common example for both methods. Initially the target moves at roughly the same speed as the observer, and the observer is capable of keeping track of it. Later, it accelerates, and tries to go through another constriction in the world. Second method succeeds in following it, while the first method fails.
After this, the target moves at it's greatest velocity, and both methods fail miserably.
Once the observer loses track of the target, it just stands at that point. One work around would be to start using the visibility based persuit methods to find the target. Here the problem becomes simpler because many cells can readily be marked clean.
In the examples, red dot is the target, blue dot is the observer. It may look as though the observer and the target collide, but care has been taken so that there is at least an 'epsilon' distance between the two. But since the target is unpredictable, the possibility of a collision cannot be discarded.

Source Code:
Input Files: