Use Nko 17 Re Planning
Use Nko 17 Re Planning
Use Nko 17 Re Planning
I. I NTRODUCTION
In recent years, microaerial vehicles (MAVs) have gained
popularity in many practical applications such as aerial pho-
tography, inspection, surveillance and even delivery of goods.
Most commercially available drones assume that the path
planned by the user is collision-free or provide only limited
obstacle-avoidance capabilities. To ensure safe navigation in
the presence of unpredicted obstacles a replanning method that
generates a collision-free trajectory is required.
Formulation of the trajectory generation problem largely
depends on the application and assumptions about the envi- Fig. 1: Example of local trajectory replanning algorithm run-
ronment. In the case where an MAV is required to navigate ning in the simulator. Global trajectory is visualized in purple
a cluttered environment, possibly an indoor one, we would and the local obstacle map is visualized in red. The local
suggest subdividing the problem into two layers. First, we trajectory is represented by a uniform quintic B-spline, and its
assume that a map of the environment is available and a control points are visualized in yellow for the fixed parts and
trajectory from a specified start point to the goal point is in green for the parts that can still change due to optimization.
planned in advance.
This task has been a popular research topic in recent years,
and several solutions have been proposed by Achtelik et al. [1]
and Richter et al. [21]. They used occupancy representation and simultaneously avoids unpredicted obstacles based on an
of the environment to check for collisions and searched for environment representation constructed from the most recent
the valid path in a visibility graph constructed using sam- sensor measurements. This replanning level should run in
pling based planners. Thereafter, they followed the approach several milliseconds to ensure the safety of MAVs operating
proposed by Mellinger and Kumar [14] to fit polynomial at high velocities.
splines through the points of the planned path to generate a The proposed approach solves a similar problem as that
smooth feasible trajectory. The best algorithms of this type solved by Oleynikova et al. [17], but instead of using poly-
can compute a trajectory through tens of waypoints in several nomial splines for representing the trajectory we propose the
seconds. use of B-splines and discuss their advantages over polynomial
To cope with any unmodeled, possibly dynamic, obsta- splines for this task. Furthermore, we propose the use of a
cle a lower planning level is required, which can generate robocentric, fixed-size three-dimensional (3D) circular buffer
a trajectory that keeps the MAV close to the global path to maintain local information about the environment. Even
though the proposed method cannot model arbitrarily large to find a feasible trajectory depends largely on the selected
occupancy maps, as some octree implementations, faster look- discretization scheme.
up and measurement insertion operations make it better suited
for real-time replanning tasks. B. Environment representation
We demonstrate the performance of the system in several To be able to plan a collision-free trajectory a representation
simulated and real-world experiments, and provide open- of the environment that stores information about occupancy
source implementation of the software to community. is required. The simplest solution that can be used in the
The contributions of the present study are as follows: 3D case is a voxel grid. In this representation, a volume is
• Formulation of local trajectory replanning as a B-spline
subdivided into regular grid of smaller sub-volumes (voxels),
optimization problem and thorough comparison with al- where each voxel stores information about its occupancy. The
ternative representations (polynomial, discrete). main drawback of this approach is its large memory-footprint,
• High-performance 3D circular buffer implementation for
which allows for maping only small fixed-size volumes. The
local obstacle mapping and collision checking and com- advantage, however, is very fast constant time access to any
parison with alternative methods. element.
• System design and evaluation on realistic simulator and
To deal with the memory limitation, octree-based represen-
real hardware, in addition to performance comparison tations of the environment are used in [9] [22]. They store
with existing methods. information in an efficient way by pruning the leaves of the
trees that contain the same information, but the access times
In addition to analyzing the results presented in the paper,
for each element become logarithmic in the number of nodes,
we encourage the reader to watch the demonstration video and
instead of the constant time as in the voxel-based approaches.
inspect the available code, which can be found at
Another popular approach to environment mapping is voxel
https://vision.in.tum.de/research/ hashing, which was proposed by Nießner et al. [16] and used
robotvision/replanning in [18]. It is mainly used for storing a truncated signed distance
function representation of the environment. In this case, only
II. R ELATED W ORK a narrow band of measurements around the surface is inserted
In this section, we describe the studies relevant to different and only the memory required for that sub-volume is allocated.
aspects of collision-free trajectory generation. First, we discuss However, when full measurements must be inserted or the
existing trajectory generation strategies and their applications dense information must be stored the advantages of this
to MAV motion planning. Thereafter, we discuss the state-of- approach compared to those of the other approaches are not
the-art approaches for 3D environment mapping. significant.
Optimization-based approaches rely on minimizing a cost where pi ∈ Rn are control points at times ti , i ∈ [0, .., n] and
function that consists of smoothness and collision terms. The Bi,k (t) are basis functions that can be computed using the De
trajectory itself can be represented as a set of discrete points Boor – Cox recursive formula [5] [4]. Uniform B-splines have
[25] or polynomial segments [17]. The approach presented a fixed time interval ∆t between their control points, which
in the present work falls into this category, but represents a simplifies computation of the basis functions.
trajectory using uniform B-splines. In the case of quintic uniform B-splines, at time t ∈
Another group of approaches is based on path sampling [ti , ti+1 ) the value of p(t) depends only on six control points,
and motion primitives. Sampling-based approaches were suc- namely [ti−2 , ti−1 , ti , ti+1 , ti+2 , ti+3 ]. To simplify calcula-
cessfully used for challenging tasks such as ball juggling tions we transform time to a uniform representation s(t) =
[15], and motion primitives were successfully applied to flight (t − t0 )/∆t, such that the control points transform into
through the forest [19], but the ability of both approaches si ∈ [0, .., n]. We define function u(t) = s(t) − si as time
500
Ring buffer 120
Octomap
100
400
80
300
60
200
40
100
20
0 0
0 2 4 6 8 10 0 20 40 60 80 100
Insertion time [ms] Insertion time [ms]
elapsed since the start of the segment. Following the matrix The integral over squared time derivatives can be computed
representation of the De Boor – Cox formula [20], the value in the closed form. For example, the integral over squared
of the function can be evaluated as follows: acceleration can be computed as follows:
Z ti+1
T Eq = p00 (u(t))2 dt (6)
1 pi−2 ti
u pi−1 T
2 pi−2 pi−2
u pi pi−1 pi−1
p(u(t)) = 3 M6
, (2)
u4 pi+1
pi
M6T QM6 pi ,
u pi+2 =
pi+1 pi+1 (7)
u5 pi+3
pi+2 pi+2
pi+3 pi+3
1 26 66 26 1 0 (8)
−5 −50 0 50 5 0
where
1 10 20 −60 20 10 0 T
M6 = . (3)
0 0
−10 20
5! 0 −20 10 0
Z 1 0 0
5 −20 30 −20 5 0
−1 5 −10 10 −5 1 1 2 2
Q= du (9)
∆t3 0 6u 6u
Given this formula, we can compute derivatives with respect 12u2 12u2
to time (velocity, acceleration) as follows: 20u3 20u3
T 0 0 0 0 0 0
0 pi−2 0 0 0 0
1 pi−1 0 0
1 0 0 8 12 16 20
0 1 2u pi =
0 0 12 24 36
. (10)
p (u(t)) = 2 M6
, (4) ∆t3 48
∆t 3u3 pi+1
0 0 16 36 57.6 80
4u pi+2
0 0 20 48 80 114.286
5u4 pi+3
Please note that matrix Q is constant in the case of uniform
T B-splines. Therefore, it can be computed in advance for
0 pi−2 determining the integral over any squared derivative (see [21]
0 pi−1 for details).
00 1 2 pi
p (u(t)) = M6
. (5) B. Comparison with polynomial trajectory representation
6u2
∆t2 pi+1
12u pi+2 In this subsection, we discuss the advantages and disad-
20u3 pi+3 vantages of B-spline trajectory representation compared to
polynomial-splines-based representation [21] [17].
The computation of other time derivatives and derivatives To obtain a trajectory that is continuous up to the forth
with respect to control points is also straightforward. derivative of position, we need to use B-splines of degree five
or greater and polynomial splines of at least degree nine (we
need to set five boundary constraints on each endpoint of the
segment). Furthermore, for polynomial splines we must ex-
plicitly include boundary constraints into optimization, while
the use of B-splines guarantees the generation of a smooth
trajectory for an arbitrary set of control points. Another useful
property of B-splines is the locality of trajectory changes
due to changes in the control points, which means that a
change in one control point affects only a few segments
in the entire trajectory. All these properties result in faster
optimization because there are fewer variables to optimize and
fewer constraints.
Evaluation of position at a given time, derivatives with
respect to time (velocity, acceleration, jerk, snap), and inte-
grals over squared time derivatives are similar for both cases
because closed-form solutions are available for both cases.
The drawback of B-splines, however, is the fact that the
Fig. 3: Example of online trajectory replanning using proposed
trajectory does not pass through the control points. This makes
optimization objective. The plot shows a global trajectory com-
it difficult to enforce boundary constraints. The only constraint
puted by fitting a polynomial spline through fixed waypoints
we can enforce is a static one (all time derivatives are zero),
(red), voxels within 0.5 m of the obstacle (blue), computed B-
which can be achieved by inserting the same control point
spline trajectory with fixed (cyan) and still optimized (green)
k + 1 times, where k is the degree of the B-spline. If we need
segments and control points. In the areas with no obstacles,
to set an endpoint of the trajectory to have a non-zero time
the computed trajectory closely follows the global one, while
derivative, an iterative optimization algorithm must be used.
close to an obstacle, the proposed method generates a smooth
These properties make polynomial splines more suitable
trajectory that avoids the obstacle, and rejoins the global
for the cases where the control points come from planning
trajectory.
algorithms (RRT, PRM), which means that the trajectory must
pass through them, else the path cannot be guaranteed to be
collision-free. For local replanning, which must account for
find its address in the stored array:
unmodeled obstacles, this property is not very important; thus,
the use of B-spline trajectory representation is a better option. insideV olume(x) = 0 ≤ x − o < N, (11)
address(x) = (x − o) mod N. (12)
IV. L OCAL E NVIRONMENT M AP USING 3D C IRCULAR
p
B UFFER If we restrict the size of the array to N = 2 , we can rewrite
these functions to use cheap bitwise operations instead of
To to avoid obstacles during flight, we need to maintain divisions:
an occupancy model of the environment. On one hand, the
model should rely on the most recent sensor measurements,
and on the other hand it should store some information over insideV olume(x) = ! ((x − o) & (∼ (2p − 1))), (13)
time because the field of view of the sensors mounted on the p
address(x) = (x − o) & (2 − 1). (14)
MAV is usually limited.
We argue that for local trajectory replanning a simple where & is a ”bitwise and,” ∼ is a ”bitwise negation,” and !
solution with a robocentric 3D circular buffer is beneficial. In is a ”boolean not.”.
what follows, we discuss details pertaining to implementation To ensure that the volume is centered around the camera,
and advantages from the application viewpoint. we must simply change the offset o and clear the updated part
of the volume. This eliminates the need to copy large amounts
A. Addressing of data when the robot moves.
that lie outside the volume, we compute the closest point penalizing position and velocity deviation at the end of the
inside the volume and mark the corresponding voxels as free optimized trajectory segment from the desired values that
rays. Second, we iterate over all marked voxels and perform come from the global trajectory. Because the property is
raycasting toward the sensor origin. We use a 3D variant of formulated as a soft constraint, the targeted values might not
Bresenham’s line algorithm [2] to increase the efficiency of be achieved, for example, because of obstacles blocking the
the raycasting operation. path. The function is defined as follows:
Thereafter, we again iterate over the volume and update
the volume elements by using the hit and miss probabilities,
Eep = λp (p(tep ) − pep )2 + λv (p0 (tep ) − p0ep )2 , (16)
similarly to the approach described in [9].
where tep is the end time of the segment, p(t) is the trajectory
C. Distance map computation to be optimized, pep and p0ep are the desired position and
To facilitate fast collision checking for the trajectory, we velocity, respectively, λp and λv are the weighting parameters.
compute the Euclidean distance transform (EDT) of the oc-
cupancy volume. This way, a drone approximated by the B. Collision cost function
bounding sphere can be checked for collision by one look- Collision cost penalizes the trajectory points that are within
up query. We use an efficient O(n) algorithm written by the threshold distance τ to the obstacles. The cost function is
Felzenszwalb and Huttenlocher [7] to compute EDT of the computed as the following line integral:
volume, where n = N 3 is the number of voxels in the grid Z tmax
(the complexity is cubic in the size of the volume along a Ec = λc c(p(t))||p0 (t)||dt, (17)
tmin
single axis). For querying distance and computing gradient,
trilinear interpolation is used. where the cost function for every point c(x) is defined as
follows:
V. T RAJECTORY O PTIMIZATION (
1
(d(x) − τ )2 if d(x) ≤ τ
The local replanning problem is represented as an optimiza- c(x) = 2τ (18)
0 if d(x) > τ,
tion of the following cost function:
where τ is the distance threshold, d(x) is the distance to the
Etotal = Eep + Ec + Eq + El , (15)
nearest obstacle, and λc is a weighting parameter. The line
where Eep is an endpoint cost function that penalizes position integral is computed using the rectangle method, and distances
and velocity deviations at the end of the optimized trajectory to the obstacles are obtained from the precomputed EDT by
segment from the desired values that usually come from the using trilinear interpolation.
global trajectory; Ec is a collision cost function; Eq is the cost C. Quadratic derivative cost function
of the integral over the squared derivatives (acceleration, jerk,
snap); and El is a soft limit on the norm of time derivatives Quadratic derivative cost is used to penalize the integral
(velocity, acceleration, jerk and snap) over the trajectory. over square derivatives of the trajectory (acceleration, jerk,
and snap), and is defined as follows:
A. Endpoint cost function 4 Z tmax
X
The purpose of the endpoint cost function is to keep the Eep = λqi (p(i) (t))2 dt. (19)
tmin
local trajectory close to the global one. This is achieved by i=2
Soft Limit Cost Function
Mean
1000 Mean
Success Norm.
Algorithm Compute
Fraction Path
800 time [s]
Length
600 Inf. RRT* + Poly 0.9778 1.1946 2.2965
RRT Connect + Poly 0.9444 1.6043 0.5444
400 CHOMP N = 10 0.3222 1.0162 0.0032
CHOMP N = 100 0.5000 1.0312 0.0312
200 CHOMP N = 500 0.3333 1.0721 0.5153
[17] S = 2 jerk 0.4889 1.1079 0.0310
0 [17] S = 3 vel 0.4778 1.1067 0.0793
0 2 4 6 8 10
[17] S = 3 jerk 0.5000 1.0996 0.0367
[17] S = 3 jerk + Restart 0.6333 1.1398 0.1724
Fig. 5: Soft limit cost function l(x) proposed in Section V-D [17] S = 3 snap + Restart 0.6222 1.1230 0.1573
for pmax equals three (red), six (green), and nine (blue). This [17] S = 3 snap 0.5000 1.0733 0.0379
function acts as a soft limit on the time derivatives of the [17] S = 4 jerk 0.5000 1.0917 0.0400
trajectory (velocity, acceleration, jerk, and snap) to ensure they [17] S = 5 jerk 0.5000 1.0774 0.0745
Ours C = 2 0.4777 1.0668 0.0008
are bounded and are feasible to execute by the MAV. Ours C = 3 0.4777 1.0860 0.0011
Ours C = 4 0.4888 1.1104 0.0015
Ours C = 5 0.5111 1.1502 0.0021
Ours C = 6 0.5555 1.1866 0.0028
The above function has a closed-form solution for trajectory Ours C = 7 0.5222 1.2368 0.0038
segments represented using B-splines. Ours C = 8 0.4777 1.2589 0.0054
Ours C = 9 0.5777 1.3008 0.0072
D. Derivative limit cost function
TABLE I: Comparison of different path planning approaches.
To make sure that the computed trajectory is feasible, we
All results except thouse of the presented study are taken
must ensure that velocity, acceleration and higher derivatives
from [17]. Our approach performs similarly to approaches
of position remain bounded. This requirement can be included
using polynomial splines without restarts, which indicates that
into the optimization as a constraint ∀t : p(k) (t) < pkmax , but
B-splines can represent trajectories similar to those repre-
in the proposed approach, we formulate it as a soft constraint
sented by polynomial splines. Lower computation times of
by using the following function:
our approach can be explained by the fact that unconstrained
X4 Z tmax optimization occurs directly on the control points, unlike other
Eep = l(p(i) (t))dt, (20) approaches where the problem must first be transformed into
i=2 tmin
an unconstrained form.
where l(x) is defined as follows:
(
exp((p(k) (x))2 − (pkmax )2 ) − 1 if p(k) (x) > pkmax After optimization, the first control point from the points
l(x) =
0 if p(k) (x) ≤ pkmax that were optimized is fixed and sent to the MAV position
(21) controller. Another control point is added to the end of the
This allows us to minimize this cost function by using any spline, which increases tep and moves the endpoint further
algorithm designed for unconstrained optimization. along the global trajectory.
For optimization we use [10], which provides an interface
E. Implementation details to several optimization algorithms. We have tested the MMA
To run the local replanning algorithm on the drone, we first [24] and BFGS [13] algorithms for optimization, with both
compute a global trajectory by using the approach described in algorithms yielding similar performance.
[21]. This gives us a polynomial spline trajectory that avoids
VI. R ESULTS
all mapped obstacles. Thereafter, we initialize our replanning
algorithm with six fixed control points at the beginning of In this section, we present experimental results obtained
the global trajectory and C control points that need to be using the proposed approach. First, we evaluate the mapping
optimized. and the trajectory optimization components of the system
In every iteration of the algorithm we set the endpoint separately for comparison with other approaches and justify
constraints (Sec. V-A) to be the position and velocity at tep their selection. Second, we evaluate the entire system in
of the global trajectory. The collision cost (Sec. V-B) of the a realistic simulator in several different environments, and
trajectory is evaluated using a circular buffer that contains finally, present an evaluation of the system running on real
measurements obtained using the RGB-D camera mounted hardware.
on the drone. The weights of quadratic derivatives cost (Sec.
V-C) are set to the same values as those used for global A. Three-dimensional circular buffer performance
trajectory generation, and the limits (Sec. V-D) are set 20% We compare our implementation of the 3D circular buffer
higher to ensure that the global trajectory is followed with the to the popular octree-based solution of [9]. Both approaches
appropriate velocity while laterally deviating from it. use the same resolution of 0.1 m. We insert the depth maps
Inserting
Computing SDF Trajectory
Moving mea-
Operation 3D compu- opti-
volume sure-
points tation mization
ments
Time
0.265 0.025 0.518 9.913 3.424
[ms]