|
2#
楼主 |
发表于 2007-5-6 10:56:22
|
只看该作者
MouseMotionListener classes’ methods to handle the various environment manipulation
tasks by the mouse: for instance, methods mousePressed() and mouseReleased()
(drawing, selecting), mouseDragged() (drawing, moving, resizing), mouseEntered()
and mouseExited() (signals entering and exiting from the canvas) and mouseMoved()
(highlighting shapes when mouse moves over it). While obstacles may overlap with
each other, the system forbids the robot to overlap (collide) with any obstacle. Collision is
an important issue that arises and requires computing the intersection of two shapes.When
the user chooses a goal point, this point represents the reference point of the robot, which
maps to be the left-bottom corner of the geometric shape of the robot. The new location
of the goal may be rejected if the area surrounding it can not accommodate the robot. This
type of verification, at this early stage, helps in eliminating undesirable degenerate cases,
which must be dealt with at a later stage in the path planning process. Notice that the Goal
button is enabled upon the creation of the robot. The objects’ geometric shapes should
be maintained convex. Thus, a validation module is implemented to check for convexity
of drawn objects. If a non-convex (i.e., concave) object is created, the module fixes it
by computing the object’s convex hull. Its use is an acceptable assumption and has been
widely used in the literature. Next, we present the algorithmfor computing the convex hull,
called Graham’s scan [1].
Algorithm ConvexHull(P)
Input: A set P of vertices for an object
Output: A list containing the vertices of CH(P) in CW order
1. Sort the points by x-coordinate, resulting in a sequence p1, . . . , pn
2. Put p1 and p2 in a list Lupper
3. for i ← 3 to n
4. do Append pi to Lupper
5. while Lupper has more than 2 points and the last 3 points do not
make right turn
6. do Delete the middle of the last 3 points from Lupper
7. Put the points pn and pn.1 in a list Llower
8. for i ← n . 1 downto 1
9. do Append pi to Llower
10. while Llower contains more than 2 points and the last 3 points
do not make right turn
11. do Delete the middle of the last 3 points from Llower
12. Remove the first and last points from Llower to avoid the duplication
where the upper and lower hull meet
13. Append Lupper to Llower, and call the resulting list L 14. return L
We first compute the convex hull vertices that lie on the upper hull, which is the part
of the convex hull running from the leftmost point p1 to the rightmost point pn when
the vertices are listed in a clockwise order. In a second scan, which is performed from
right to left, we compute the remaining part of the convex hull, the lower hull. Due to the
sorting step, the total time required for computing the convex hull is O(n log n). This is
one implementation of many others that have the same time complexity.
All objects in the environment are maintained in a vector called shapesVector. The Java
class Vector provides the capabilities of array-like data structures that can dynamically
resize themselves. This vector makes the input of the next phase.
The configuration space (C-Space) is the parameter space of the robot. A robot in
W-Space is represented by a point in C-Space, and any point in C-Space corresponds to
some placement of an actual robot in theW-Space [11]. The underlying idea of C-Space is
to represent the robot as a point called the reference point of the robot andmap the obstacles
into this space by growing their sizes by the size of the robot. The outer boundary of the
W-Space is considered as an obstacle and is mapped into the C-Space by enlarging it as
for other obstacles in the environment by the size of the robot. This mapping transforms
the problem of motion planning into the problem of planning the motion of a point. To
make this mapping possible, we use an efficient algorithm known as the Minkowski sum
algorithm [5].
Minkowski sums are a useful mathematical tool in the motion planning problem. Notice
that a very simple algorithm to compute the Minkowski sums of two convex polygons is
to compute v + w for each pair v, w of vertices, with v ∈ P and w ∈ R. Next, the convex
hull of all these sums is computed. The MinkowskiSums algorithm only looks at pairs of
vertices that are extreme in the same direction, which makes it run in linear time. In this
algorithm, the notation angle ( p, q) is used to denote the angle that the vector −→pq makes
with the positive x-axis. In order to perform the required computation, the lists of vertices
for any two convex polygons should be maintained in clockwise order, with the first vertex
in both lists as the smallest y-coordinate (and smallest x-coordinate in the case of ties).
The Minkowski sum algorithm runs in linear time, because at each execution of the
repeat-loop either i or j is incremented. One can observe that any vertex of the Minkowski
sum is the sum of two original vertices that are extreme in a common direction, and
the angle test ensures that all extreme pairs are found. So, the Minkowski sums of two
convex polygonswith n and m vertices, respectively, has O(n+m) time complexity. Fig. 5
shows the output of the Minkowski algorithm for a translating robot (polygon—leftmost
and topmost object in Fig. 4) (ignore the network of line segments for the time being).
Notice how the robot is shrunk to its reference point (i.e., bottom left corner) whereas each
obstacle including the outer boundary of theW-Space has been grown accordingly.
Algorithm MinkowskiSums(P, R)
Input: 2 convex polygons: P = {v1, . . . ,vn} and R = {w1, . . . ,wm}.
The vertices follow a CCW order, where v1 and w1 are the smallest.
Output: The Minkowski sums (P ⊕ R).
1. i = 1; j = 1
2. vn+1 = v1; wm+1 = w1
3. repeat
4. Add vi + wj as a vertex to P ⊕ R
5. if angle(vi vi+1) < angle(wjwj+1)
6. then i ++ 7. else if angle(vi vi+1) > angle(wjwj+1)
8. then j ++ 9. else i ++ 10. j ++ 11. until i = n + 1 and j = m + 1
The resulting set of C-obstacles will be stored in another vector as it will be extensively
used in the later phases.
5. Motion planning algorithms
5.1. The visibility graph
The visibility graph of a set of obstacles is more complex. It is the graph of all nodes
from all obstacles that can “see” each other. The edges formed must be external to the
obstacles. It has been proven that visibility graphs guarantee to compute the shortest path
because any shortest path between pstart and pgoal among the set S of disjoint polygonal
obstacles is a polygonal path whose inner vertices are vertices of S.
The above characterization of the shortest path enables us to construct the visibility
graph of S, denoted by Gvis (S). Its nodes are the vertices of S, and there is an arc
between vertices v and w if they can see each other: that is, if the segment vw does not
intersect the interior of any obstacle in S. Two vertices that can see each other are called
(mutually) “visible”, and the segment connecting them is called a “visibility edge”. This
also applies to the boundary—chain of line segments—of each obstacle. The endpoints of
each boundary segment (edge) are visible to each other. Hence, the obstacle edges form a
subset of the arcs of Gvis (S). The segments on the shortest path are visibility edges, except
for the first and the last segment. To make them visibility edges as well, the start and goal
positions are added as vertices to S; that is, the visibility graph will be considered of the set
S∗ = S ∪ {pstart , pgoal}. By definition, the arcs of Gvis (S∗) are between vertices (which
now include pstart and pgoal) that can see each other.
The visibility graph is implemented using the adjacency list approach. Adjacency
lists are linked lists, one list per vertex, that identify the vertices to which each vertex
is connected (i.e. the visible vertices to that vertex). All the vertices are stored in an
object of ArrayList, which is a dynamic array-class in Java. It is similar to the Vector
class. Each component of an ArrayList object, in the graph, contains a reference to a
linked list of edge nodes. Each node has a numeric index, a weight and a reference to
the next node in the adjacency list. Class AdjVertex encompasses these attributes. The
general specification of the implemented graph includes boolean methods for checking
whether the graph is empty (isEmpty()) or full (isFull()), and several methods to
add vertices (addVertex(vertex)) and edges (addEdge(from, to, weight)) and to
retrieve the vertices connected to a certain vertex (getToVertices(vertex)). Fig. 5
shows the visibility graphs in the C-Space. Next, we describe the general sketch of the
algorithm to compute the visibility graph.
Algorithm VisibilityGraph(S)
Input: A set S of disjoint polygonal obstacles including pstart and pgoal.
Output: The visibility graph Gvis (S).
1. Initialize the graph G = (V, E) where V is the set of all vertices of the
polygons in S and E = φ
2. for all vertices v in V
3. do W = VisibleVertices(v, S)
4. for every vertex w ∈ W,
5. do add the arc (v,w) to E
6. return G |
|