03 April 2020
[
robotics
,
math
]
A B-spline is a piecewise polynomial parameterized by a set of control
points, a knot vector. The key to the b-spline representation is that it has the convex hull property, which allows the higher order derivatives (velocity, acceleration, jerk, etc) to be checked against dynamic feasibility subject to higher order derivative constraints. B-spline representations implicitly guarantee continuity between higher order derivatives between subsequent control points, which is a helpful property for concatenating sequential b-splines.
Definition. Value of a B-spline of degree k − 1 k{-}1 k − 1 is given by:
γ ( t ) = ∑ i = 0 n P i B i , k ( t ) \gamma(t) = \sum_{i=0}^n P_i B_{i,k}(t) γ ( t ) = i = 0 ∑ n P i B i , k ( t )
where P i P_i P i are the control
points i i i , i ∈ [ 0 , … , n ] i \in [0, \dots, n] i ∈ [ 0 , … , n ] for n n n control points, and
B i , k ( t ) B_{i, k}(t) B i , k ( t ) are the basis functions that can be computed using the
DeBoor-Cox recursive formula. These basis functions blend the control
points.
For a uniform b-spline, Δ t \Delta t Δ t is a fixed constant value. For a
trajectory that is continuous up to snap (4th derivative of position),
we would require quintic splines.
At time t ∈ [ t i , t i + 1 ] t \in [t_i, t_{i{+}1}] t ∈ [ t i , t i + 1 ] , the value of γ ( t ) \gamma(t) γ ( t ) for a k − 1 k{-}1 k − 1
b-spline depends only on k k k local control points
[ t i − ( ⌊ k 2 ⌋ − 1 ) , t i + ⌊ k 2 ⌋ ] \left[t_{i{-}\left(\lfloor\frac{k}{2}\rfloor -1 \right)}, \; t_{i{+}\lfloor\frac{k}{2}\rfloor}\right] [ t i − ( ⌊ 2 k ⌋ − 1 ) , t i + ⌊ 2 k ⌋ ] .
For a quintic b-spline, γ ( t ) \gamma(t) γ ( t ) would depend on 6 control points:
[ t i − 2 , t i − 1 , t i , t i + 1 , t i + 2 , t i + 3 ] \begin{bmatrix} t_{i{-}2}, & t_{i{-}1}, & t_{i}, & t_{i{+}1}, & t_{i{+}2}, & t_{i{+}3} \end{bmatrix} [ t i − 2 , t i − 1 , t i , t i + 1 , t i + 2 , t i + 3 ]
The blending functions B i , k ( t ) B_{i, k}(t) B i , k ( t ) are only nonzero for
i − 2 , i − 1 , i , i + 1 , i + 2 , i + 3 i{-}2, i{-}1, i, i{+}1, i{+}2, i{+}3 i − 2 , i − 1 , i , i + 1 , i + 2 , i + 3 .
Evaluation. To simplify calculations, we transform time t t t to a
uniform representation s ( t ) = ( t − t 0 ) Δ t s(t) = \frac{(t-t_0)}{\Delta t} s ( t ) = Δ t ( t − t 0 ) . Then, the
control points transform into i ∈ [ 0 , . . . , n ] i \in [0, ..., n] i ∈ [ 0 , ... , n ] . The time elapsed
since the start of the segment is given by u ( t ) = s ( t ) − i u(t) = s(t) - i u ( t ) = s ( t ) − i .
The B-spline curve of k − 1 k{-}1 k − 1 degree can be evaluated using the
DeBoor-Cox formula:
γ i ( u ( t ) ) = b k ⊤ M k P i \gamma_i(u(t)) = \mathbf{b}_{k}^\top\mathbf{M}_{k} \mathbf{P}_i γ i ( u ( t )) = b k ⊤ M k P i
For a quintic B-spline:
γ i ( u ( t ) ) = b 6 ⊤ M 6 P i = [ 1 u u 2 u 3 u 4 u 5 ] M 6 [ P i − 2 P i − 1 P i P i + 1 P i + 2 P i + 3 ] \begin{aligned}
\gamma_i(u(t)) & = \mathbf{b}_6^\top\mathbf{M}_6 \mathbf{P}_i\\
& = \begin{bmatrix} 1 & u & u^2 & u^3 & u^4 & u^5 \end{bmatrix} \mathbf{M}_6 \begin{bmatrix} P_{i{-}2} \\ P_{i{-}1} \\ P_{i} \\ P_{i{+}1} \\ P_{i{+}2} \\ P_{i{+}3}\end{bmatrix}\end{aligned} γ i ( u ( t )) = b 6 ⊤ M 6 P i = [ 1 u u 2 u 3 u 4 u 5 ] M 6 P i − 2 P i − 1 P i P i + 1 P i + 2 P i + 3
where
M 6 = 1 5 ! [ 1 26 66 26 1 0 − 5 − 50 0 50 5 0 10 20 − 60 20 10 0 − 10 20 0 − 20 10 0 5 − 20 30 − 20 5 0 − 1 5 − 10 10 − 5 1 ] \begin{aligned}
\mathbf{M}_6 = \frac{1}{5!} \begin{bmatrix}
1 &26 &66 &26 &1 &0 \\
-5 &-50 &0 &50 &5 &0 \\
10&20 &-60 &20 &10 &0 \\
-10&20 &0 &-20 &10 &0 \\
5&-20 &30 &-20 &5 &0 \\
-1&5 &-10 &10 &-5 &1
\end{bmatrix}\end{aligned} M 6 = 5 ! 1 1 − 5 10 − 10 5 − 1 26 − 50 20 20 − 20 5 66 0 − 60 0 30 − 10 26 50 20 − 20 − 20 10 1 5 10 10 5 − 5 0 0 0 0 0 1
The d d d -th time derivative of a k − 1 k{-}1 k − 1 degree b-spline is given by:
∂ γ ( u ( t ) ) d ∂ d t = γ ( d ) ( u ( t ) ) = 1 Δ t d b k ( d ) ⊤ M k P i \frac{\partial\gamma(u(t))^d}{\partial^dt} = \gamma^{(d)} (u(t)) = \frac{1}{\Delta t^d} {\mathbf{b}_k^{(d)}}^\top\mathbf{M}_k \mathbf{P}_i ∂ d t ∂ γ ( u ( t ) ) d = γ ( d ) ( u ( t )) = Δ t d 1 b k ( d ) ⊤ M k P i
E.g. for a quintic b-spline, its first and second derivatives are:
γ ˙ ( u ( t ) ) = 1 Δ t [ 0 1 2 u 3 u 2 4 u 3 5 u 4 ] ⊤ M 6 P i velocity γ ¨ ( u ( t ) ) = 1 Δ t 2 [ 0 0 2 6 u 12 u 2 12 u 2 20 u 3 ] ⊤ M 6 P i acceleration \begin{aligned}
\dot \gamma(u(t)) & = \frac{1}{\Delta t} \begin{bmatrix} 0 & 1 & 2u & 3u^2 & 4 u^3 & 5u^4 \end{bmatrix}^\top\mathbf{M}_6 \mathbf{P}_i \qquad \text{velocity}\\
\ddot \gamma(u(t)) &= \frac{1}{\Delta t^2} \begin{bmatrix} 0 & 0 & 2 & 6u & 12u^2 & 12u^2 & 20u^3\end{bmatrix}^\top\mathbf{M}_6 \mathbf{P}_i \qquad \text{acceleration}\end{aligned} γ ˙ ( u ( t )) γ ¨ ( u ( t )) = Δ t 1 [ 0 1 2 u 3 u 2 4 u 3 5 u 4 ] ⊤ M 6 P i velocity = Δ t 2 1 [ 0 0 2 6 u 12 u 2 12 u 2 20 u 3 ] ⊤ M 6 P i acceleration
The derivatives of a b-spline is also a b-spline. The control points for
higher order derivatives (velocity, acceleration) are:
V i = 1 Δ t ( P i + 1 − P i ) A i = 1 Δ t ( V i + 1 − V i ) V_i = \frac{1}{\Delta t} (P_{i{+}1} - P_i) \qquad \qquad
A_i = \frac{1}{\Delta t} (V_{i{+}1} - V_i) V i = Δ t 1 ( P i + 1 − P i ) A i = Δ t 1 ( V i + 1 − V i )
Integral over squared time derivatives. The local computation of the
integral over squared time derivatives of degree d d d for a k − 1 k{-}1 k − 1
degree b-spline is given by:
E i , k d = ∫ t i t i + 1 ( γ ( d ) ( u ( t ) ) ) 2 d t = ∫ t i t i + 1 1 Δ t d ( b k ( d ) ⊤ M k P i ) ⊤ 1 Δ t d ( b k ( d ) ⊤ M k P i ) d t = ∫ t i t i + 1 1 Δ t 2 d ( P i ⊤ M k ⊤ b k ( d ) b k ( d ) ⊤ M k P i ) d t \begin{aligned}
E^d_{i,k} & = \int_{t_i}^{t_{i{+}1}} {\biggl( \gamma^{(d)} (u(t))\biggr)}^2 dt\\
& = \int_{t_i}^{t_{i{+}1}} \frac{1}{\Delta t^d}\biggl( {\mathbf{b}_k^{(d)}}^\top\mathbf{M}_k {\mathbf{P}_i\biggr)}^\top\frac{1}{\Delta t^d} \biggl( {\mathbf{b}_k^{(d)}}^\top\mathbf{M}_k \mathbf{P}_i \biggr) dt\\
& = \int_{t_i}^{t_{i{+}1}} \frac{1}{\Delta t^{2d}}\biggl( {\mathbf{P}_i }^\top{\mathbf{M}_k}^\top\mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}} ^\top\mathbf{M}_k \mathbf{P}_i \biggr) dt\end{aligned} E i , k d = ∫ t i t i + 1 ( γ ( d ) ( u ( t )) ) 2 d t = ∫ t i t i + 1 Δ t d 1 ( b k ( d ) ⊤ M k P i ) ⊤ Δ t d 1 ( b k ( d ) ⊤ M k P i ) d t = ∫ t i t i + 1 Δ t 2 d 1 ( P i ⊤ M k ⊤ b k ( d ) b k ( d ) ⊤ M k P i ) d t
Rearrange the equation, since P i \mathbf{P}_i P i and M k \mathbf{M}_k M k does not
depend on t t t :
E i , k d = P i ⊤ M k ⊤ ( ∫ t i t i + 1 1 Δ t 2 d b k ( d ) b k ( d ) ⊤ d t ) M k P i = P i ⊤ M k ⊤ ( 1 Δ t 2 d ∫ t i t i + 1 b k ( d ) b k ( d ) ⊤ d t ) M k P i \begin{aligned}
E^d_{i,k} & = \mathbf{P}_i^\top\mathbf{M}_k^\top\biggl( \int_{t_i}^{t_{i{+}1}} \frac{1}{\Delta t^{2d}} \mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}}^\top dt \biggr)\mathbf{M}_k \mathbf{P}_i \\
& = \mathbf{P}_i^\top\mathbf{M}_k^\top\biggl(\frac{1}{\Delta t^{2d}} \int_{t_i}^{t_{i{+}1}} \mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}}^\top dt \biggr)\mathbf{M}_k \mathbf{P}_i \end{aligned} E i , k d = P i ⊤ M k ⊤ ( ∫ t i t i + 1 Δ t 2 d 1 b k ( d ) b k ( d ) ⊤ d t ) M k P i = P i ⊤ M k ⊤ ( Δ t 2 d 1 ∫ t i t i + 1 b k ( d ) b k ( d ) ⊤ d t ) M k P i
We perform a change of integrals from t t t to u u u . Since
u = s ( t ) − i = ( t − t 0 Δ t ) − i \begin{aligned}
u &= s(t) - i\\
&= \left(\frac{t-t_0}{\Delta t}\right) - i\end{aligned} u = s ( t ) − i = ( Δ t t − t 0 ) − i
Then
d u d t = 1 Δ t d t = Δ t d u \begin{aligned}
\frac{d u}{d t}& = \frac{1}{\Delta t}\\
dt& = \Delta t \, du\end{aligned} d t d u d t = Δ t 1 = Δ t d u
Then the change of integral
becomes
E i , k d = P i ⊤ M k ⊤ ( 1 Δ t 2 d ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ Δ t d u ) M k P i = P i ⊤ M k ⊤ ( Δ t Δ t 2 d ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ d u ) M k P i = P i ⊤ M k ⊤ ( 1 Δ t ( 2 d − 1 ) ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ d u ⏟ Q d ) M k P i \begin{aligned}
E^d_{i,k} & = \mathbf{P}_i^\top\mathbf{M}_k^\top\biggl(\frac{1}{\Delta t^{2d}} \int_{u=0}^{u=1} \mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}}^\top\Delta t \, du \biggr)\mathbf{M}_k \mathbf{P}_i \\
& = \mathbf{P}_i ^\top\mathbf{M}_k ^\top\biggl(\frac{\Delta t}{\Delta t^{2d}} \int_{u=0}^{u=1} \mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}}^\top du \biggr)\mathbf{M}_k \mathbf{P}_i \\
& = \mathbf{P}_i ^\top\mathbf{M}_k ^\top\biggl(\underbrace{\frac{1}{\Delta t^{(2d-1)}} \int_{u=0}^{u=1} \mathbf{b}_k^{(d)} {\mathbf{b}_k^{(d)}}^\top du }_{\mathbf{Q}^d}\biggr)\mathbf{M}_k \mathbf{P}_i \end{aligned} E i , k d = P i ⊤ M k ⊤ ( Δ t 2 d 1 ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ Δ t d u ) M k P i = P i ⊤ M k ⊤ ( Δ t 2 d Δ t ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ d u ) M k P i = P i ⊤ M k ⊤ ( Q d Δ t ( 2 d − 1 ) 1 ∫ u = 0 u = 1 b k ( d ) b k ( d ) ⊤ d u ) M k P i
so
Q k d = 1 Δ t ( 2 d − 1 ) ∫ 0 1 ( d b k ( d ) d ( d ) u ) ( d b k ( d ) d ( d ) u ) ⊤ d u \begin{aligned}
\mathbf{Q}^d_k = \frac{1}{\Delta t^{(2d-1)}} \int_{0}^{1} \left(\frac{d\mathbf{b}_k^{(d)}}{d^{(d)}u} \right) \left(\frac{d\mathbf{b}_k^{(d)}}{d^{(d)}u}\right)^\top du\end{aligned} Q k d = Δ t ( 2 d − 1 ) 1 ∫ 0 1 ( d ( d ) u d b k ( d ) ) ( d ( d ) u d b k ( d ) ) ⊤ d u
For a quintic b-spline, the integral over squared acceleration can be
computed as follows,
Q k 2 = 1 Δ t 3 ∫ 0 1 ( d b 6 2 d 2 u ) ( d b 6 2 d 2 u ) ⊤ d u = 1 Δ t 3 [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 12 16 20 0 0 12 24 36 48 0 0 16 36 57.6 80 0 0 20 48 80 114.286 ] \begin{aligned}
\mathbf{Q}^2_k = \frac{1}{\Delta t^{3}} \int_{0}^{1} \left(\frac{d\mathbf{b}_6^{2}}{d^{2}u} \right) \left(\frac{d\mathbf{b}_6^{2}}{d^{2}u}\right)^\top du
&= \frac{1}{\Delta t^{3}} \begin{bmatrix}
0 &0 &0 &0 &0 &0 \\
0 &0 &0 &0 &0 &0 \\
0 &0 &8 &12 &16 &20 \\
0 &0 &12 &24 &36 &48 \\
0 &0 &16 &36 &57.6 &80 \\
0 &0 &20 &48 &80 &114.286
\end{bmatrix}\end{aligned} Q k 2 = Δ t 3 1 ∫ 0 1 ( d 2 u d b 6 2 ) ( d 2 u d b 6 2 ) ⊤ d u = Δ t 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 12 16 20 0 0 12 24 36 48 0 0 16 36 57.6 80 0 0 20 48 80 114.286
For a weighted integral over multiple squared time derivatives:
E i , k D = ∑ d = 1 D w d E i , k d = ∑ d = 1 D w d P i ⊤ M k ⊤ Q k d M k P i \begin{aligned}
E_{i,k}^D &= \sum_{d=1}^D w_d E^d_{i,k}\\
& = \sum_{d=1}^D w_d \mathbf{P}_i^\top\mathbf{M}_k^\top\mathbf{Q}^d_k \mathbf{M}_k \mathbf{P}_i\end{aligned} E i , k D = d = 1 ∑ D w d E i , k d = d = 1 ∑ D w d P i ⊤ M k ⊤ Q k d M k P i
Convex Hull Property. Span of a b-spline γ i ( u ( t ) ) \gamma_i(u(t)) γ i ( u ( t )) lies
within the convex hull of its local control points. This extends to its
higher order derivatives, therefore feasibility check of:
∥ γ ˙ ∥ < v max ∥ γ ¨ ∥ < a max \left\lVert\dot \gamma\right\rVert < v_\text{max} \qquad \left\lVert\ddot \gamma\right\rVert < a_\text{max} ∥ γ ˙ ∥ < v max ∥ γ ¨ ∥ < a max
can be satisfied by checking the control points:
V i < v max A i < a max V_i < v_\text{max} \qquad A_i < a_\text{max} V i < v max A i < a max
References
Vladyslav Usenko, Lukas von Stumberg, Andrej Pangercic, and Daniel Cremers. Real-time trajectory replanning for mavs using uniform b-splines and a 3d circular buffer . In 2017 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pages 215–222. IEEE, 2017.
Wenchao Ding, Wenliang Gao, Kaixuan Wang, and Shaojie Shen. An efficient b-spline-based kinodynamic replanning framework for quadrotors . IEEE Transactions on Robotics, 35(6):1287–1306, 2019.
Boyu Zhou, Fei Gao, Luqi Wang, Chuhao Liu, and Shaojie Shen. Robust and efficient quadrotor trajectory generation for fast autonomous flight . IEEE Robotics and Automation Letters, 2019.