Professional Documents
Culture Documents
Geofence Boundary Violation Detection in 3D Using Triangle Weight Characterization With Adjacency
Geofence Boundary Violation Detection in 3D Using Triangle Weight Characterization With Adjacency
Geofence Boundary Violation Detection in 3D Using Triangle Weight Characterization With Adjacency
https://doi.org/10.1007/s10846-018-0930-5
Received: 10 October 2017 / Accepted: 5 September 2018 / Published online: 15 September 2018
© Springer Nature B.V. 2018
Abstract
This paper introduces a computationally efficient geofence boundary violation detection method using the Triangle Weight
Characterization with Adjacency (TWCA) algorithm. The geofence is defined as a maximum and a minimum altitude,
and a horizontal boundary specified as a polygon that does not self-intersect. TWCA initialization divides the horizontal
component and bounding box of each geofence into a finite set of triangles, then determines the triangle containing the
vehicle. During flight, each position update is checked for containment within the vertical geofence boundaries using
inequalities and the horizontal geofence boundaries using TWCA. TWCA searches for the triangle containing the vehicle
position using breadth-first search of the adjacency graph. The root node of the search is the triangle occupied at the previous
time step. This algorithm is applicable to three-dimensional geofences containing both keep-in (inclusion) geofences and
keep-out (exclusion) geofences.
Keywords Geofence · Unmanned aerial vehicle · Unmanned aircraft system · Safety · UTM
violations and the response to a geofence violation. There a traditional Ray Casting approach to boundary violation
are many possible responses to a geofence violation detection. Section 6 discusses the application of geofencing
including but not limited to alerting the pilot, cutting with TWCA in real-world environments and areas for future
the aircraft power, or an alternative guidance scheme work, followed by a brief conclusion in Section 7.
designed to respect the geofence boundaries [17]. To
prevent the vehicle from violating the geofence boundaries,
the geofence system must activate before the boundary 2 Problem Statement
is crossed. The activation point can be represented as a
stopping distance calculated based on the vehicle flight The static UAS geofence proposed in this work has the
characteristics and the current wind speeds, which can following characteristics:
be used to shift the geofence boundaries. The design of
– A geofence consists of exactly one surrounding keep-
these shifted geofence boundaries is discussed in other
in boundary and any number of interior keep-out
works [3, 18], which can then be analyzed using the
boundaries.
methods presented in this paper. This paper focuses on
– Geofence boundaries remain unchanged for the dura-
the detection of geofence violations through the application
tion of a flight, i.e., the geofence volume is static.
of the Triangle Weight Characterization with Adjacency
– Each geofence boundary is a polyhedron with vertical
(TWCA) algorithm [2, 8, 14, 15]. TWCA is compared to the
and horizontal boundaries.
Ray Casting algorithm [1, 5, 11], a common solution to this
– The polyhedron is formed by extruding a horizontal
type of problem, as a baseline for algorithm analysis.
plane polygon vertically. Geofence vertical boundaries
This paper contributes a survey of algorithms applica-
are specified as altitude ceiling and floor above ground
ble to the geofence boundary violation detection problem.
level (AGL) or mean sea level (MSL). Note that
General geofence boundaries may be non-convex, and mul-
buildings and terrain with variable elevations can be
tiple geofences can potentially overlap causing intersecting
modeled with multiple keep-out polyhedra.
boundaries. This paper also contributes a methodology for
– The horizontal geofence boundary is a polygon that is
benchmarking geofence boundary violation detection strate-
not self-intersecting as shown in Fig. 1. Each horizontal
gies. These benchmarking techniques are applied to com-
geofence boundary is specified as a list of vertices in a
pare Ray Casting and TWCA. This is the first paper to our
local ENU (East-North-Up) or local NED (North-East-
knowledge that evaluates and compares multiple geofencing
Down) format, in clockwise or counterclockwise order
boundary detection strategies.
around the polygon boundary.
Section 2 states geofence characteristics and assump-
– The vehicle is powered on, initialized, and launched
tions made in the proposed geofence violation detection
from a position within the keep-in geofence polyhedron
framework. Section 3 discusses methods commonly applied
and outside all keep-out geofence polyhedra.
to solve problems similar to the detection of horizontal
– The geofencing system monitors vehicle state at regular
geofence boundary violations. Section 4 presents the Tri-
interval δt.
angle Weight Characterization with Adjacency (TWCA)
algorithm, while Section 5 presents results of introduc- This work assumes the internal representations of the
ing randomly-generated UAS flight paths through randomly geofence boundaries are expressed in meters relative to
generated geofence boundaries to compare TWCA with a locally defined origin point, the launch point of the
size of the grid squares and the number of polygon edges [9, count = count + 1/2 instead of count = count + 1 to
19, 20]. prevent double counting [1].
An outline of the Ray Casting algorithm is shown in
3.2 Decomposition Algorithms Algorithm 1. The algorithm is based on the formulation
presented by Narkawicz and Hagen [11]. The Ray Casting
Decomposition divides the polygon into subcomponents algorithm iterates over all edges of p and does not have an
that are less complex to simplify the point-in-polygon inclu- initialization step. The complexity of the algorithm is O(N),
sion check. Three decomposition methods are commonly and if the geofence boundaries change from one time step
utilized: Wedge, Swath, and convex decomposition. The to the next, code execution and results of the Ray Casting
Wedge method, only applicable to convex polygons, divides algorithm are not impacted. Ray Casting with a bounding
the polygon into triangles by connecting an interior point box is used as the baseline for comparison with TWCA
to each of the polygon vertices. There are the same num- (Figs. 4 and 5).
ber of triangles as number of original polygon vertices.
This algorithm has a run-time complexity of O(log N) [6,
13]. The Swath method divides the polygon into horizon- 4 Triangle Weight Characterization
tal swaths where the maximum and minimum y-values are with Adjacency (TWCA)
designated by successive polygon vertices when the vertices
are ordered by y-value. Each swath contains a subset of rel- The point-in-polygon algorithm being proposed by this
evant polygon edges. The step to find the swath containing a paper for application in geofence systems is Triangle
position of interest has complexity O(log N) when searched Weight Characterization with Adjacency (TWCA). This
for using a balanced binary tree [16]. Convex decomposition algorithm is closely related to the Wedge algorithm [6,
has a run-time complexity of O(log N) [10]. 13]. Both algorithms divide the polygon into triangles then
search the triangles for the one containing the position of
3.3 Ray Casting interest. Unlike the Wedge algorithm, TWCA is designed to
handle non-convex polygons and multiple trajectory-based
The Ray Casting algorithm determines whether or not the inquiries. TWCA contains an initialization step and a run-
position of interest, r, is inside a given polygon, p, by time step as shown in Algorithm 2. The initialization step
projecting an infinite ray from r. In this implementation, must be executed for all keep-in and keep-out geofences
each ray is cast in the positive y-direction (Fig. 3). If an when the system first activates. If there are any changes
infinite ray intersects an odd number of polygon edges, then to any of the geofence boundaries after the original
r is contained in p; otherwise r is outside of p. If the ray initialization, each keep-in or keep-out geofence that is
intersects a vertex of p, then that intersection is tallied as changed must be initialized again.
Fig. 3 Example polygon with ray directed along the y-axis for the Ray
Casting algorithm [11]
J Intell Robot Syst (2019) 95:239–250 243
4.2.2 Monotone Polygon Conversion to Triangles between the geofence and the bounding box being divided
into τb = (v +4+2)−2 = v +4 triangles. The total number
For each monotone polygon, the vertices are iterated over of triangles to be considered is τ = (v − 2) + (v + 4) =
from highest to lowest y-value, iteratively adding edges 2 ∗ (v + 1) triangles.
to create triangles. Because the polygons are already y-
monotone, all created edges are inside the polygon and 4.3 Triangle Occupancy Check
therefore kept. For the example geofence, this algorithm is
run eight times, once for each monotone polygon. Figure 7b To determine if the launch position or any subsequent
illustrates the TWCA triangles with black lines for the position, r, is inside the geofence polygon, we check if
geofence triangles and red lines for the bounding box r is inside each triangle. Let vertices of the i th triangular
triangles. cell be located at ri1 = (xi1 , yi1 ), ri2 = (xi2 , yi2 ), and
Any geofence represented by a simple polygon with v ri3 = (xi3 , yi3 ). Because a triangle is a 2 − D convex hull,
vertices can be divided into τg = v − 2 triangles using this positions of the i th triangular cell satisfy the following rank
process. For the case of TWCA, both the original polygon condition:
and the bounding box must be divided into triangles. The
bounding box consists of the original v vertices, the 4 xi2 − xi1 xi3 − xi1
Rank ri2 − ri1 ri3 − ri1 = = 2.
vertices of the bounding box rectangle, and 2 vertices to yi2 − yi1 yi3 − yi1
connect the two sets of vertices. This results in the space (1)
Therefore, position of an arbitrary point r = (x, y) in the examples, wi1 = c is a line parallel to triangle side i2 − i3 ,
motion plane can be uniquely expanded as wi2 = c is a line parallel to triangle side i3 − i1 , and wi3 = c
is a line parallel to triangle side i1 −i2 . Also, wik (xij , yij ) =
r = ri1 + wi2 ri2 − ri1 + wi3 ri3 − ri1
δk,j , where δk,j is the Kronecker delta defined as follows:
= 1 − wi2 − wi3 ri1 + wi2 ri2 + wi3 ri3 . (2)
1 j =k
Setting wi1 = 1 − wi2 − wi3 , Eq. 2 can be rewritten as δk,j = . (7)
0 j = k
3
r= wik rik (3) In Fig. 8, the x −y motion plane can be divided into seven
k=1 sub-regions based on the signs of distance weights wi1 , wi2 ,
where wi3 . As shown, distance weights are all positive inside the
i th triangular cell.
3
If the distance weights of one of the triangles are all
wik = 1. (4)
positive for the position of interest, then the position of
k=1
interest is within the polygon.
Considering Eqs. 3 and 4, distance weights wi1 , wi2 , and
wi3 are obtained from Remark If a geofence area is sufficiently large, it may
⎡ ⎤⎡ ⎤ ⎡ ⎤
xi1 xi2 xi3 wi1 x not be approximated by a planar surface. For this case,
⎣ yi1 yi2 yi3 ⎦ ⎣ wi2 ⎦ = ⎣ y ⎦ . (5) the geofence domain can be considered as a spherical
1 1 1 wi3 1 surface with longitude φ and latitude λ. The proposed
TWCA method can still be applied for boundary violation
The distance weights satisfying Eq. 5 can expressed as
checking over a spherical surface. By substituting x, xi1 ,
follows:
xi2 , xi3 , y, yi1 , yi2 , yi3 by φ, φi1 , φi2 , φi3 , λ, λi1 , λi2 ,
xi3 − xi2 y − yi2 − yi3 − yi2 x − xi2 λi3 , weights wi1 (φ, λ), wi2 (φ, λ), and wi3 (φ, λ) can be
wi1 (x, y) =
xi3 −xi2 yi1 − yi2 − yi3 − yi2 xi1 − xi2 obtained from Eq. 6. Similar to a planar representation,
the UAS is enclosed by the i th sector over the spherical
geofence surface if wi1 (φ, λ), wi2 (φ, λ), and wi3 (φ, λ) are
xi1 − xi3 y − yi3 − yi1 − yi3 x − xi3
wi2 (x, y) = all positive.
xi1 − xi3 yi2 − yi3 − yi1 − yi3 xi2 − xi3
4.4 Adjacency Graph
xi2 − xi1 y − yi1 − yi2 − yi1 x − xi1
wi3 (x, y) = . The adjacency graph can be stored as an adjacency matrix,
xi2 −xi1 yi3 −yi1 − yi2 − yi1 xi3 − xi1
multiply linked list, or an array. A multiply linked list is
(6)
typically preferred for low-level languages such as C++.
wik (x, y) = c (k = 1, 2, 3 and c is a constant) is a However, an array is used in this work because case studies
line parallel to a triangle side not passing through ik . As were implemented in MATLAB. Adjacent triangles are
defined as triangles that share a common side. To efficiently Figure 9 shows the average time for a position of interest
search for an occupied triangle, each search is initialized at query for each of the 1,200 randomly generated geofences.
the triangle occupied at the prior time step. If that triangle is TWCA queries are shown in blue, while Ray Casting query
no longer occupied, a Breadth First Search is executed with times are shown in red. Figure 9a and b show the results
a “visited” list that eliminates the possibility of checking the when the position is sampled 10 times and sampled 100
same triangle more than once. times along each of the 100 flight paths respectively. The
frequency of position samples along the flight path does
not impact execution time of the Ray Casting algorithm
5 Results because Ray Casting does not utilize any information from
prior states during execution. However, the Ray Casting
To evaluate TWCA performance, it is compared against Ray execution time is seen to scale linearly with the number of
Casting with a bounding box using MATLAB on a laptop vertices in the geofence.
running Windows 10. Embedded UAS applications would The frequency of position samples strongly impacts
require these algorithms to be compiled in a language such the expected execution time of TWCA. By sampling the
as C so the execution times will be lower. The relative position of the vehicle at a higher frequency, the average
performance trends presented here are expected to translate execution time of TWCA is shown to be independent of
to embedded codes. Trial geofences are randomly generated the number of geofence vertices rather than increasing
such that test cases are 25 instances of geofences with 3 to linearly as in Ray Casting. This result is expected because
50 vertices for a total of 1,200 geofences. Geofence vertices as the time between vehicle position estimates increases,
have a maximum possible magnitude of 50 m in the x and the likelihood that the vehicle has moved multiple triangles
y directions. Each geofence is tested with 100 simulated away from the previously occupied triangle increases as
flight paths from the origin (0, 0) to a randomly generated well.
end position. The flight path end positions have a maximum Figure 10 displays results in terms of the percentage
possible magnitude of 50 m in the x and y directions. of triangles explored: τe /τ where τ is the total number
Two sampling intervals of the flight path are tested: 10 of triangles and τe is the number of triangles explored.
positions along the flight path and 100 positions along The black data points present the percentage of triangles
the flight path. State sampling frequency can therefore be explored for each geofence averaged over each position
analyzed given that the adjacency graph search complexity sample in each flight path. Both plots in Fig. 10 show that
depends on number of triangle passages taken from the as the number of geofence vertices increases, the percentage
previously-occupied triangle. of triangles explored for each position update decreases.
10-4 10-4
1 1
0.9 0.9
0.8 0.8
0.7 0.7
0.6 0.6
Time [s]
Time [s]
0.5 0.5
0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
0 5 10 15 20 25 30 35 40 45 50 0 5 10 15 20 25 30 35 40 45 50
# of Vertices # of Vertices
Fig. 9 Average time per boundary violation check for each of 25 ran- results are shown in blue. Note that sporadic inconsistencies in the
domly generated geofences with 3 to 50 vertices for a total of 1,200 data are likely due to a background process on the computer and not
random geofences. Ray Casting results are shown in red. TWCA relevant to the results illustrated for geofences of size 23 to 25 vertices
248 J Intell Robot Syst (2019) 95:239–250
100 100
90 90
% of Triangles Checked 80 80
% of Triangles Checked
70 70
60 60
50 50
40 40
30 30
20 20
10 10
0 0
0 5 10 15 20 25 30 35 40 45 50 0 5 10 15 20 25 30 35 40 45 50
# of Vertices # of Vertices
Fig. 10 Maximum percentage of triangles explored before locating the percentage of triangles explored before locating triangle containing
triangle containing the vehicle is shown in green. One maximum is vehicle is shown in black. The average percentage of triangles is
reported for each set of 25 geofences with the same number of ver- reported for each of the 1,200 geofences. The average is over each of
tices and each position sampled for each flight path explored. Average the position samples for each of the explored flight paths
This trend is also present in the worst-case scenarios the complexity of its borders, it becomes possible to form
for TWCA. The green data points in Fig. 10 are the the geofence based on data from a mapping database. The
highest percentage of triangles checked for each number of usage of a mapping database would reduce pre-flight pilot
geofence vertices. This data shows that the inverse relation workload of manually entering geofence data.
between the number of geofence vertices and the percentage In the near future, geofences generated using property
of triangles checked is still present in the worst observed maps could enable flights over areas such as private property
cases. Although the trends are observable in both plots, the and public parks. Figure 11a shows the outline of a privately
trends are more pronounced in Fig. 10b than in Fig. 10a. owned campsite in a sparsely populated area. If the campsite
As discussed above, this reflects that TWCA executes with owners want to photograph the campsite from a UAV, they
a time complexity independent of the complexity of the might want to utilize a geofence to prevent flights over the
geofence by leveraging knowledge of the triangle occupied adjacent properties and the public roads. They might also
at the previous time step. choose to manually define keep-out geofences around the
campers and trees to preserve the privacy of their guests and
prevent collisions.
6 Case Study In the not too distant future, as UAS operate in increas-
ingly populated areas, similar geofences could be automati-
With a geofence boundary violation detection algorithm like cally generated for suburban and urban flight volumes. The
TWCA that has an expected execution time independent of keep-in geofences might be created encompassing parks
Fig. 11 Examples of rural and urban environments that might be operational areas for UAS with geofences in the future. Generated using Google
Maps at www.google.com/maps/ and OpenStreetMap at www.openstreetmap.org
J Intell Robot Syst (2019) 95:239–250 249
or multiple blocks or entire city regions, while keep-out Publisher’s Note Springer Nature remains neutral with regard to
geofences might be used to denote buildings. jurisdictional claims in published maps and institutional affiliations.
In a city aligned with the Earth coordinate axes such as
Salt Lake City (Fig. 11b), the bounding box buffer distance
Δ could be defined as a value that minimized overlap References
between keep-out geofences or that minimized the instances
of being within a keep-out geofence bounding box. These 1. Alciatore, D., Miranda, R.: A winding number and point-in-
polygon algorithm. Glaxo Virtual Anatomy Project Research
optimizations become more complicated as the geofence
Report, Department of Mechanical Engineering, Colorado State
becomes less regular. Consider the section of Manhattan in University (1995)
New York City shown in Fig. 11c. The city blocks are at a 2. Garey, M.R., Johnson, D.S., Preparata, F.P., Tarjan, R.E.:
consistent angle to the cardinal axes; this inefficiency can Triangulating a simple polygon. Inf. Process. Lett. 7(4), 175–179
(1978)
be eliminated by applying a yaw (heading) transformation 3. Gilabert, R.V., Dill, E.T., Hayhurst, K.J., Young, S.D.: Safeguard:
to the local map (ground) coordinate axes. In general, the Progress and test results for a reliable independent on-board safety
coordinate axis orientation can be optimized to maximize net for UAS. In: 2017 IEEE/AIAA 36th Digital Avionics Systems
the flight area not covered by a keep-out geofence bounding Conference (DASC), pp. 1–9. IEEE (2017)
4. Government US: Operation and certification of small unmanned
box. aircraft systems. In: Title 14 Code of Federal Regulations, Part 107
In an urban environment, there are obstacles to be (2016)
avoided other than other aircraft, including buildings, power 5. Hormann, K., Agathos, A.: The point in polygon problem for
lines, and street lights. The issue is further complicated by arbitrary polygons. Comput. Geom. 20(3), 131–144 (2001)
6. Huang, C.W., Shih, T.Y.: On the complexity of point-in-polygon
the existence of urban canyons, where GPS is denied due algorithms. Comput. Geosci. 23(1), 109–118 (1997)
to the surrounding buildings. In these areas, even if every 7. Kopardekar, P.H.: Unmanned aircraft systems traffic management
obstacle were designated a keep-out geofence, accumulated (UTM) safely enabling UAS operations in low-altitude airspace
(2017)
state estimation error might make it impossible for the 8. Lee, D.T., Preparata, F.P.: Location of a point in a planar
geofence to guarantee a collision free flight. In these cases, subdivision and its applications. SIAM J. Comput. 6(3), 594–606
the addition of a sense and avoid system could enable (1977)
safe flight through a geofenced region without relying on 9. Li, J., Wang, W.: Point-in-polygon tests by determining grid
center points in advance. In: Signal and Information Processing
a potentially inaccurate state estimate. The inclusion of a Association Annual Summit and Conference (APSIPA), 2013
sense and avoid system in addition to a geofencing system Asia-Pacific, pp. 1–7. IEEE (2013)
is critical to safe flight. 10. Li, J., Wang, W., Wu, E.: Point-in-polygon tests by convex
When operating at higher altitudes, in shared airspace decomposition. Comput. Graph. 31(4), 636–648 (2007)
11. Narkawicz, A., Hagen, G.: Algorithms for collision detection
with manned aircraft, large UAS can still benefit from between a point and a moving polygon, with applications to
geofencing. The keep-in geofence ensures that the UAS aircraft weather avoidance. In: 16th AIAA Aviation Technology,
does not exit its designated flight boundary, and keep-out Integration, and Operations Conference, p. 3598 (2016)
12. Nordbeck, S., Rystedt, B.: Computer cartography point-in-
geofences can ensure separation from buildings, terrain,
polygon programs. BIT Numer. Math. 7(1), 39–64 (1967)
and ultimately other aircraft operating in fixed regions / 13. Preparata, F.P., Shamos, M.I.: Introduction. In: Computational
bounding boxes. Geometry, pp. 1–35. Springer (1985)
14. Rastgoftar, H.: Continuum Deformation of Multi-Agent Systems.
Birkhäuser, Cambridge (2016)
15. Rastgoftar, H., Jayasuriya, S.: Evolution of multi-agent systems as
7 Conclusion continua. J. Dyn. Syst. Meas. Control. 136(4), 041014 (2014)
16. Salomon, K.B.: An efficient point-in-polygon algorithm. Comput.
This paper has presented an efficient methodology for Geosci. 4(2), 173–178 (1978)
17. Stevens, M.N., Atkins, E.M.: Multi-mode guidance for an
defining a static geofence for an unmanned aircraft system independent multicopter geofencing system. In: 16th AIAA
(UAS) containing both keep-in (inclusion) geofences and Aviation Technology, Integration, and Operations Conference, p.
keep-out (exclusion) geofences. This paper developed 3150 (2016)
Triangle Weight Characterization with Adjacency (TWCA) 18. Stevens, M.N., Atkins, E.M.: Layered geofences in complex
airspace environments. In: 2018 Aviation Technology, Integration,
to detect horizontal geofence boundary violations with an and Operations Conference, p. 3348 (2018)
execution time complexity that is independent from the 19. Yang, S., Yong, J.H., Sun, J., Gu, H., Paul, J.C.: A point-in-
number of vertices used to define the geofence. Case studies polygon method based on a quasi-closest point. Comput. Geosci.
36(2), 205–213 (2010)
showed that TWCA on average has better performance 20. Žalik, B., Kolingerova, I.: A cell-based point-in-polygon algo-
than Ray Casting, particularly when geofence polyhedra are rithm suitable for large sets of points. Comput. Geosci. 27(10),
complex, with a large number of vertices. 1135–1145 (2001)
250 J Intell Robot Syst (2019) 95:239–250
Mia N. Stevens is a Robotics PhD candidate at the University of Dr. Ella M. Atkins is a Professor of Aerospace Engineering at the
Michigan, Ann Arbor, MI, USA. She received a Bachelor’s of Science University of Michigan, where she directs the Autonomous Aerospace
in Aerospace Engineering with Information Technology from the Systems Lab and is Associate Director of Graduate Programs for
Massachusetts Institute of Technology, Cambridge, MA, USA, in the Robotics Institute. Dr. Atkins holds B.S. and M.S. degrees
2014, and a Master of Science in Robotics from the University in Aeronautics and Astronautics from MIT and M.S. and Ph.D.
of Michigan, Ann Arbor, MI, USA, in 2016. Her current research degrees in Computer Science and Engineering from the University of
interests include software design for UAS, safety system development, Michigan. She is past-chair of the AIAA Intelligent Systems Technical
and autonomous systems. Committee and has served on the National Academy’s Aeronautics
and Space Engineering Board, the Institute for Defense Analysis
Defense Science Studies Group, and an NRC committee to develop an
Dr. Hossein Rastgoftar received the B.Sc. degree in mechanical autonomy research agenda for civil aviation. She pursues research in
engineering-thermo-fluids from Shiraz University, Shiraz, Iran, the Aerospace system autonomy and safety.
M.S. degrees in mechanical systems and solid mechanics from
Shiraz University and the University of Central Florida, Orlando, FL,
USA, and the Ph.D. degree in mechanical engineering from Drexel
University, Philadelphia, PA, USA, in 2015. He is currently an assistant
research scientist at the University of Michigan, Ann Arbor, MI, USA.
His current research interests include dynamics and control, multiagent
systems, human-cyber physical systems, optimization and Markov
decision processes, multi criteria decision analysis, and differential
game theory.