[Mobile Robot Motion Planning] 04 - Trajectory Generation

foreword

Part of the content of this article refers to the mobile robot motion planning of Deep Blue Academy , and makes relevant notes and arrangements accordingly.

Related code finishing:

  1. https://gitee.com/lxyclara/motion-plan-homework/
  2. https://github.com/KailinTong/Motion-Planning-for-Mobile-Robots/blob/master
  3. https://gitee.com/aries-wu/Motion-plan/blob/main/
  4. Link: https://pan.baidu.com/s/1UtVHRxDq771LfSGK_21wgQ?pwd=rhtp Extraction code: rhtp

introduce

The trajectories experienced by robots and unmanned vehicles need to satisfy smooth characteristics and at the same time comply with the corresponding dynamic constraints. The traditional academic route obviously needs to generate an optimized trajectory after generating the path to conform to the characteristics of kinodynamic; while the path that has been kinodynamic needs to further optimize the trajectory to improve the quality of the path.

Smooth trajectory generation usually needs to meet the following characteristics:

  1. Boundary conditions: location of start point, end point (direction, etc.)
  2. Intermediate conditions: position, direction of relay node...
  3. Judgment criteria for a smooth trajectory: the evaluation function should be reasonable (such as lim ⁡ x → x 0 + f ( x ) = lim ⁡ x → x 0 − f ( x ) \begin{aligned}\lim_{x\rightarrow x_0^+ } f(x)\end{aligned} =\begin{aligned}\lim_{x\rightarrow x_0^- }f(x)\end{aligned}xx0+limf(x)=xx0limf(x)

Minimum Snap Optimization

Differential Flatness

Paper: Minimum Snap Trajectory Generation and Control for Quadrotors, Daniel Mellinger and Vijay Kumar
will be full-dimensional state space problem XXX goes to the flat spaceσ \sigmaσ for research. State Space XX
insert image description here
for Quadrotor UAVsX consists of position, direction, linear velocity and angular velocity:
X = [ x , y , z , ϕ , θ , ψ , x ˙ , y ˙ , z ˙ , ω x , ω y , ω z ] TX=[x, y,z,\phi,\theta,\psi,\dot{x},\dot{y},\dot{z},\omega_x,\omega_y,\omega_z]^TX=[x,y,z,ϕ ,i ,ps ,x˙,y˙,z˙,ohx,ohy,ohz]The T angular velocity is observed in the UAV's own coordinate system.

The states and inputs of the quadrotor can be expressed as algebraic functions of the output variables and their derivatives in four flat spaces.
Any smooth trajectory (with reasonably bounded derivatives) in flat space can be tracked by an underactuated quadrotor.

Choose 4 dimensions as a flat space in the 12-dimensional state space: σ = [ x , y , z , ψ ] T \sigma=[x,y,z,\psi]^Tp=[x,y,z,ψ ]T
T 0 → T M T_0\rightarrow T_M T0TMtime, the trajectory in flat space is defined as: R 3 × SO ( 2 ) \mathbb{R}^3\times SO(2)R3×SO(2)( R 3 \mathbb{R}^3 R3 isx , y , z , x,y,z,x,y,z, S O ( 2 ) SO(2) SO ( 2 ) ψ \psiψ )

The dynamics of a quadrotor drone are shown below, divided into two formulas:
insert image description here
z W \mathbf{z}_WzWRepresents z in the world coordinate system \mathbf{z}z axis,z B \mathbf{z}_BzBRepresents z \mathbf{z} in the Body coordinate systemz- axis.
insert image description hereFrom the equation of motion: z B = t ∥ t ∥ , t = [ σ ¨ 1 , σ ¨ 2 , σ ¨ 3 + g ] T \mathbf{z}_B=\dfrac{\mathbf{t}} {\|\mathbf{t}\|},\mathbf{t}=[\ddot{\sigma}_1,\ddot{\sigma}_2,\ddot{\sigma}_3+g]^TzB=tt,t=[p¨1,p¨2,p¨3+g]T σ 1 , σ 2 , σ 3 \sigma_1,\sigma_2,\sigma_3 p1,p2,p3For x , y , zx,y,z respectivelyx,y,z , sot \mathbf{t}t represents the direction of the resultant acceleration of the UAV. Therefore, representsz B \mathbf{z}_BzBis σ \sigmaThe variable algebraic combination of σ . The attitude of the drone can be usedx B , y B , z B \mathbf{x}_B,\mathbf{y}_B,\mathbf{z}_BxB,yB,zBTo express, if x B , y B , z B \mathbf{x}_B,\mathbf{y}_B,\mathbf{z}_B can be determinedxB,yB,zBBy algebraic combination, then ϕ , θ , ψ \phi,\theta,\psiϕ ,i ,ψ can also be determined.

Next define an intermediate coordinate system CCC , only one yaw angle difference from the world system. x C = [ cos ⁡ σ 4 , sin ⁡ σ 4 , 0 ] T \mathbf{x}_C=[\cos\boldsymbol{\sigma}_4,\sin\boldsymbol{\sigma}_4,0]^TxC=[cosp4,sinp4,0]T
insert image description here
x C \mathbf{x}_CxCalso z B \mathbf{z}_BzBalso y B \mathbf{y}_ByB
y B = z B × x C ∥ z B × x C ∥ , x B = y B × z BRB = [ x B y B z B ] \mathbf{y}_B=\frac{\mathbf{z}_B\ times\mathbf{x}_C}{\|\mathbf{z}_B\times\mathbf{x}_C\|},\quad\mathbf{x}_B=\mathbf{y}_B\times\mathbf{z }_B\quad\mathbf{R}_B=\begin{bmatrix}\mathbf{x}_B&\mathbf{y}_B&\mathbf{z}_B\end{bmatrix}yB=zB×xCzB×xC,xB=yB×zBRB=[xByBzB]

At this point, only the angular velocity is left.
For mp ¨ = − mgz W + u 1 z B m\ddot{\boldsymbol{p}}=-mg\mathbf{z}_W+u_1\mathbf{z}_Bmp¨=m g zW+u1zB求导,得 m a ˙ = u ˙ 1 z B + ( ω B W ) × u 1 z B m\dot{\boldsymbol{a}}=\dot{u}_1\mathbf{z}_B+(\boldsymbol{\omega}_{BW})\times u_1\mathbf{z}_B ma˙=u˙1zB+( ohBW)×u1zB(This involves some knowledge of rigid body kinematics) BW BWB W :Body angular velocity
viewed in the world frame
Because the drone is only thrust in the vertical direction, thenu ˙ 1 = z B ⋅ ma ˙ \dot{u}_1=\mathbf{z}_B\cdot m\dot {\boldsymbol{a}}u˙1=zBma˙Define
ah ω \mathbf{h}_\omegahoh, h ω = ω BW × z B = in 1 ( a ̇ − ( z B ⋅ a ̇ ) z B ) \mathbf{h}_\omega=\boldsymbol{\omega}_{BW}\times\mathbf{ z}_B=\frac m{u_1}(\dot{\ballsymbol{a}}-(\mathbf{z}_B\cdot\dot{\ballsymbol{a}})\mathbf{z}_B)hoh=ohBW×zB=u1m(a˙(zBa˙)zB)h ω \mathbf{h}_\omegahohQuantities in can be expressed in flat space.
We know that ω BW = ω xx B + ω yy B + ω zz B \omega_{BW}=\omega_x\mathbf{x}_B+\omega_y\mathbf{y}_B+\omega_z\mathbf{z}_BohBW=ohxxB+ohyyB+ohzzB
沿y B \mathbf{y}_ByB x B \mathbf{x}_B xBGive the following solution: ω x = − h ω ⋅ y B , ω y = h ω ⋅ x B \omega_x=-\mathbf{h}_\omega\cdot\mathbf{y}_B,\quad\omega_y =\mathbf{h}_\omega\cdot\mathbf{x}_Bohx=hohyB,ohy=hohxB
insert image description here

Summary
insert image description hereinsert image description here
The generated trajectory is a polynomial, which has the following advantages:
• Easy determination of smoothness criteria using polynomial order
• Simple closed-form computation of derivatives
• Three-dimensional decoupled trajectory generation

Minimum-snap

Smooth 1D Trajectory

insert image description hereinsert image description here

Smooth Multi-Segment Trajectory

insert image description hereinsert image description here
The velocities and accelerations to reach these points are not really easy to specify.

Optimization-based Trajectory Generation

insert image description here
Minimizing jerk is equivalent to the minimum angular velocity, which can obtain a better visual tracking field of view.
Minimizing snap can save energy
insert image description here

得到以下公式
f ( t ) = { f 1 ( t ) ≐ ∑ i = 0 N p 1 , i t i T 0 ≤ t ≤ T 1 f 2 ( t ) ≐ ∑ i = 0 N p 2 , i t i T 1 ≤ t ≤ T 2 ⋮ ⋮ f M ( t ) ≐ ∑ i = 0 N p M , i t i T M − 1 ≤ t ≤ T M f(t)=\begin{cases}f_1(t)\doteq\sum_{i=0}^Np_{1,i}t^i&\quad T_0\leq t\leq T_1\\f_2(t)\doteq\sum_{i=0}^Np_{2,i}t^i&\quad T_1\leq t\leq T_2\\\vdots&\quad\vdots\\f_M(t)\doteq\sum_{i=0}^Np_{M,i}t^i&\quad T_{M-1}\leq t\leq T_M\end{cases} f(t)= f1(t)i=0Np1,itif2(t)i=0Np2,itifM(t)i=0NpM,itiT0tT1T1tT2TM1tTM

  • Each segment is a polynomial
  • It is not necessarily required that the order of each trajectory is the same, but the same can simplify the problem.
  • The time of each trajectory needs to be known

Constraints :
insert image description here
trajectory smoothness, continuousness, and control input minimization are independent of each other
insert image description here

Minimizing jerk requires five trajectories (one section of trajectory)
and minimizing snap requires seven trajectories (one section of trajectory)
insert image description here

Timeline Settings
insert image description here

A trajectory objective function
insert image description here

Differential constraints, k = 0, 1, 2, 3 for the starting point and end point, that is, p, v, a, j are required; for waypoint, k = 0 is usually required, that is, only p is required, both cases can be written as a matrix Formal equality constraints
insert image description here

Continuity constraints, although v, a, j are not required for the waypoint, but the derivatives of the left and right trajectories at the waypoint are required to be equalinsert image description here

insert image description here

Convex Optimization

Convex optimization related courses:

  1. Boyd Stanford Open Class
  2. HKUSThttps://github.com/KellyHwong/convex-hkust
  3. Convex optimization introductory textbooks and courses recommendation and arrangement

Convex functions and convex sets

The mathematical definition of a convex function is: if f ( x ) f(x)f ( x ) in intervalIII upper link,III is an interval on the set of real numbers, and for anyx , y ∈ I x,y \in Ix,yI sum anyλ ∈ [ 0 , 1 ] \lambda \in [0,1]l[0,1 ], we have f ( λ x + ( 1 − λ ) y ) ≤ λ f ( x ) + ( 1 − λ ) f ( y ) f(\lambda x + (1-\lambda)y) \leq \ lambda f(x) + (1-\lambda)f(y)f(λx+(1l ) y )λf(x)+(1λ ) f ( y )f ( x ) f(x)f ( x ) in intervalIII is a convex function. Among them,λ \lambdaλ is called the weight or mixing ratio. This definition is in a geometric sense, that is, for any two points on the function, the value of the function at each point on the line segment between these two points does not exceed the value on the linear function corresponding to the point. A convex function can also be defined in the form of a second derivative asf ′ ′ ( x ) ≥ 0 f''(x)\geq 0f′′(x)0 . insert image description here
Mathematical definition of convex set: In Euclidean space, a setSSS is a convex set if and only if for anyx , y ∈ S x,y\in Sx,yS0 ≤ λ ≤ 1 0\leq \lambda\leq0l1 ,都有
λ x + ( 1 − λ ) y ∈ S \lambda x+(1-\lambda)y\in Sλx+(1l ) yS among them,λ \lambdaλ is a real number, representingx 1 x_1x1and x 2 x_2x2ratio coefficient between. In other words, if the line segment formed by two points in any set is in the set, then it is a convex set.insert image description here

The standard form of a convex optimization problem

m i n i m i z e f 0 ( x ) s u b j e c t   t o f i ( x ) ≤ 0 i = 1 , … , m A x = b \begin{aligned}\mathrm{minimize}\quad&f_0(x)\\\mathrm{subject~to}\quad&f_i(x)\leq0\quad i=1,\ldots,m\\&\mathrm{A}x=b\end{aligned} minimizesubject tof0(x)fi(x)0i=1,,mAx=b
where the objective function f 0 f_0f0and the inequality constraint function fi ( x ) f_i(x)fi( x ) are convex functions,A x = b Ax=bAx=b is required to be affine,xxIf the domain of x is a convex set

Linear Programming (LP): linear programming problems

minimize ⁡ x c T x + d subject to G x ≤ h A x = b \begin{aligned} \underset{x}{\operatorname*{minimize}}\quad &c^Tx+d \\ \text{subject to}\quad &Gx\leq h \\ &Ax=b \end{aligned} xminimizesubject tocTx+dGxhAx=b

Quadratic Programming (QP): quadratic programming problem

minimize ⁡ x 1 2 x T P x + q T x + r subject to G x ≤ h A x = b \begin{aligned} \underset{x}{\operatorname*{minimize}}\quad &\frac1 2 x^TPx+q^Tx +r \\ \text{subject to}\quad &Gx\leq h \\ &Ax=b \end{aligned} xminimizesubject to21xT Px+qTx+rGxhAx=b

Quadratically Constrained QP (QCQP): A quadratic programming problem with quadratic constraints

QCQP (Quadratically Constrained Quadratic Program) can be expressed in the following form:

$ minimize ⁡ x ( 1 / 2 ) x T P 0 x + q 0 T x + r 0 s u b j e c t   t o ( 1 / 2 ) x T P i x + q i T x + r i ≤ 0 i = 1 , … , m A x = b \begin{aligned}\underset{x}{\operatorname*{minimize}}\quad&(1/2)x^TP_0x+q_0^Tx+r_0\\\mathrm{subject~to}\quad&(1/2)x^TP_ix+q_i^Tx+r_i\leq0\quad i=1,\ldots,m\\&Ax=b\end{aligned} xminimizesubject to(1/2)xTP0x+q0Tx+r0(1/2)xTPix+qiTx+ri0i=1,,mAx=bConstraint functions are also convex functions

where x ∈ R nx \in \mathbb{R}^nxRn is the optimization variable,P 0 ∈ S n P_0 \in \mathbb{S}^nP0Sn, P i ∈ S n P_i \in \mathbb{S}^n PiSn, q 0 , q i ∈ R n q_0,q_i \in \mathbb{R}^n q0,qiRn, b i ∈ R b_i \in \mathbb{R} biR, A ∈ R p × n A \in \mathbb{R}^{p \times n} ARp×n, b ∈ R p b \in \mathbb{R}^p bRp, l , u ∈ R n l,u \in \mathbb{R}^n l,uRn , andli ≤ ui l_i \leq u_iliui

where, S n \mathbb{S}^nSn means alln × nn \times nn×A collection of real symmetric matrices of n . 1 2 x TP ix + qi T x ≤ bi \frac{1}{2} x^T P_i x + q_i^T x \leq b_i21xTPix+qiTxbiexpress about xxQuadratic inequality constraints on x , A x = b Ax=bAx=b represents linear equality constraints,li ≤ xi ≤ ui l_i \leq x_i \leq u_ilixiuiRepresents the lower and upper bound constraints on variables. The goal is to minimize the objective function 1 2 x TP 0 x + q 0 T x \frac{1}{2} x^T P_0 x + q_0^T x21xTP0x+q0Tx

Second-Order Cone Programming (SOCP): second-order optimization problem

SOCP is the abbreviation of Second Order Cone Programming. Quadratic cone programming refers to a class of convex optimization problems in which the constraints of the optimization problem consist of quadratic cones.

The general form of quadratic cone programming is:

minimize c T x subject to ∣ ∣ A i x + b i ∣ ∣ 2 ≤ c i T x + d i , i = 1 , . . . , m F x = g \begin{aligned} \text{minimize} \quad & c^Tx \\ \text{subject to} \quad & ||A_ix + b_i||_2 \leq c_i^Tx + d_i, \quad i=1,...,m \\ & Fx = g \end{aligned} minimizesubject tocTx∣∣Aix+bi2ciTx+di,i=1,...,mFx=g

Among them, xxx is the optimization variable,ccc is a vector,A i A_iAiis the matrix, bi b_ibiis a vector, di d_idiand ggg is a scalar.

The main constraint is the quadratic cone constraint, where ∣ ∣ A ix + bi ∣ ∣ 2 ≤ ci T x + di ||A_ix+b_i||_2 \leq c_i^Tx+d_i∣∣Aix+bi2ciTx+diRepresents the vector A ix + bi A_ix+b_iAix+biwith the vector ci T x + di c_i^Tx+d_iciTx+diThe inner product in Euclidean space is less than or equal to 0. This constraint can be written in the transformed form, namely

t ≥ ∣ ∣ A i x + b i ∣ ∣ 2 c i T x + d i − t ≤ 0 \begin{aligned} t \geq ||A_i x + b_i||_2 \\ c_i^T x + d_i - t \leq 0 \end{aligned} t∣∣Aix+bi2ciTx+dit0

where ttt is an auxiliary variable used to ensure that the inner product is less than or equal to 0.

SOCP can be viewed as a directly extended LP problem. Therefore, it can be solved using convex optimization, such as interior point method and branch and bound method. Compared with quadratic programming, SOCP problems have better convexity.

Semidefinite Programming(SDP)

SDP (Semidefinite Programming) can be expressed in the following form:

min ⁡ X   c T x s . t .   F 0 + ∑ i = 1 n X i F i ⪰ 0 X i ⪰ 0 , i = 1 , 2 , … , n \begin{aligned} \min_{X} \ & c^T x\\ s.t. \ & F_0 + \sum_{i=1}^n X_i F_i \succeq 0 \\ & X_i \succeq 0, i = 1, 2, \ldots, n \end{aligned} Xmin s.t. cTxF0+i=1nXiFi0Xi0,i=1,2,,n

其中, X i ∈ S n i X_i \in \mathbb{S}^{n_i} XiSniis a symmetric positive semidefinite matrix, c ∈ R nc \in \mathbb{R}^ncRn is a constant vector,F i ∈ S ni F_i \in \mathbb{S}^{n_i}FiSniis a constant symmetric matrix, F 0 ∈ S n 0 F_0 \in \mathbb{S}^{n_0}F0Sn0is a constant symmetric matrix, ⪰ 0 \succeq 00 means a positive semidefinite matrix. The goal is to minimize the objective functionc T xc^T xcT x, satisfy the matrix inequality constraintF 0 + ∑ i = 1 n X i F i ⪰ 0 F_0 + \sum_{i=1}^n X_i F_i \succeq 0F0+i=1nXiFi0 and positive semi-definite constraintsX i ⪰ 0 , i = 1 , 2 , … , n X_i \succeq 0, i = 1, 2, \ldots, nXi0,i=1,2,,n

It is not difficult to see that SDP can be regarded as a convex optimization problem whose constraints are symmetric positive semi-definite matrices. The matrix inequality constraints guarantee that the problem is convex.

Closed-form Solution to Minimum Snap

Paper: Polynomial Trajectory Planning for Aggressive Quadrotor Flight in Dense Indoor Environments, Charles Richter, Adam Bry, and Nicholas Roy
use the QP solver to solve the numerical solution of the Minimum Snap problem. Another solution is to find the Minimum Snap directly from the algebra. The analytical solution of the problem, that is, the closed-form solution of the Minimum Snap problem.

Decision variable mapping variable mapping

Let's take the equation:
J = [ p 1 ⋮ p M ] T [ Q 1 0 0 0 ⋱ 0 0 0 QM ] [ p 1 ⋮ p M ] J=\begin{bmatrix}\mathbf{p}_1\\; \varvdots\\\mathbf{p}_M\end{bmatrix}^T\quad\begin{bmatrix}\mathbf{Q}_1&\mathbf{0}&\mathbf{0}\\\mathbf{0}&\ ddots&\mathbf{0}\\\mathbf{0}&\mathbf{0}&\mathbf{Q}_M\end{bmatrix}\begin{bmatrix}\mathbf{p}_1\\\varvdots\\\mathbf {p}_M\end{bmatrix}J= p1pM T Q1000000QM p1pM
It can be seen that the optimized variables are the coefficients of the trajectory polynomial p 0 , p 1 , . . . , p M p_0,p_1,...,p_Mp0,p1,...,pM, the coefficient has no actual physical meaning, such as p 10 t 10 p_{10}t^{10}p10t10 o'clock whenttWhen t is large,p 10 p_{10}p10It may be very small, which will cause numerical instability in trajectory planning problems. Therefore, we need to transform the problem of coefficients on trajectory optimization into derivative constraints of trajectory points (that is, p , v , ap, v, ap,v,a , has a physical meaning). Through the mapping matrixM j M_jMjThe variable pj p_j to be solvedpjDerivative constraints dj mapped to trajectory points d_jdj,即 M j p j = d j M_jp_j=d_j Mjpj=dj

New objective function:

J = [ d 1 ⋮ d M ] T [ M 1 0 0 ⋮ 0 0 MM ] − T [ Q 1 0 0 ⋮ 0 0 0 QM ] [ M 1 0 0 ⋮ 0 0 0 MM ] − [ d 1 ⋮ d M ] J=\begin{bmatrix}\mathbf{d}_1\\\valuedots\\\mathbf{d}_M\end{bmatrix}^T\begin{bmatrix}M_1&\mathbf{0}; &\mathbf{0}\\\mathbf{0}&\vdots&\mathbf{0}\\\mathbf{0}&\mathbf{0}&M_M\end{bmatrix}^{-T}\begin{bmatrix} \mathbf{Q}_1&\mathbf{0}&\mathbf{0}\\\mathbf{0}&\vdots&\mathbf{0}\\\mathbf{0}&\mathbf{0}&\mathbf{Q }_M\end{bmatrix}\begin{bmatrix}M_1&\mathbf{0}&\mathbf{0}\\\mathbf{0}&\vdots&\mathbf{0}\\\mathbf{0}&\mathbf{ 0}&\ball symbol{M}_M\end{bmatrix}^{-1}\begin{bmatrix}\mathbf{d}_1\\\vdots\\\mathbf{d}_M\end{bmatrix}J= d1dM T M1000000MM T Q1000000QM M1000000MM 1 d1dM

轨迹方程如下:
x ( t ) = p 5 t 5 + p 4 t 4 + p 3 t 3 + p 2 t 2 + p 1 t + p 0 x ′ ( t ) = 5 p 5 t 4 + 4 p 4 t 3 + 3 p 3 t 2 + 2 p 2 t + p 1 x ′ ′ ( t ) = 20 p 5 t 3 + 12 p 4 t 2 + 6 p 3 t + 2 p 2 \begin{aligned} &x(t)=p_5t^5+p_4t^4+p_3t^3+p_2t^2+p_1t+p_0 \\ &x'(t)=5p_5t^4+4p_4t^3+3p_3t^2+2p_2t+p_1 \\ &\begin{aligned}x''(t)=20p_5t^3+12p_4t^2+6p_3t+2p_2\end{aligned} \end{aligned} x(t)=p5t5+p4t4+p3t3+p2t2+p1t+p0x(t)=5 p.m5t4+4p4t3+3p3t2+2p2t+p1x′′(t)=20p5t3+12p4t2+6 p.m3t+2p2

Ratio:
M = [ 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 2 0 0 T 5 T 4 T 3 T 2 T 1 5 T 4 4 T 3 3 T 2 2 T 1 0 20 T 12 t 2 2 0 0 0 0 ] \bboldsymbol{mbol{mbol{m}\ben{bmatrix}0&0&0&1&0&0&0&0&0&0&0&0&0&0&0&0&0s&0s\t^4&t^4&t^2&t1&t1&t1&t1&t1& ^3&12T^2&6T&2&0&0\end{bmatrix}M= 000T55T420T _3000T44 T312 T2000T33T _26 T002T22T _2010T10100100 To make it clearer, MMThe first three rows of the M matrix will bet = 0 t=0t=Substitute the value at 0 , and the last three lines will be t = T t=Tt=DenoteM pi = [ 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 2 0 0 T 5 T 4 T 3 T 2 T 1 5 T 4 4 T 3 3 T 2 2 T 1 0 20 T 12 T 2 6 T 2 0 0 ] [ p 5 p 4 p 3 p 2 p 1 p 0 ] \bold symbol{M}\textcolor{red}{p_i}=\begin{bmatrix}0&0&0&0&0&1\\0&0&0&0&1&0\\0&0&0&2&0&0 \T^5&T^4&T^3&T^2&T&1\\5T^4&4T^3&3T^2&2T&1&0\\20T^3&12T^2&6T&2&0&0\end{bmatrix}\textcolor{red}{\begin{bmatrix}p_5\\p_4\\p_3\ \p_2\\p_1\\p_0\end{bmatrix}}Mpi= 000T55T420T _3000T44 T312 T2000T33T _26 T002T22T _2010T10100100 p5p4p3p2p1p0

Fixed and free variable separation fixed variable and free variable decomposition

The state variables of the starting point and end point in the trajectory ( p , v , a , jp,v,a,jp,v,a,j ) is determined, the position of the middle point (waypoints)( p ) (p)( p ) is deterministic, so by choosing the matrixCCC to separate free variables (free)d F \mathbf{d}_FdFAnd the fixed variable (constrained) d P \mathbf{d}_PdP. Therefore, the following mapping relationship can be obtained:
CT [ d F d P ] = [ d 1 ⋮ d M ] \mathbf{C}^T\begin{bmatrix}\mathbf{d}_F\\\mathbf{d}_P \end{bmatrix}=\begin{bmatrix}\mathbf{d}_1\\\varvdots\\\mathbf{d}_M\end{bmatrix}CT[dFdP]= d1dM Let’s set the boundary conditions as follows: J = [ d F d P ] TCM − TQM − 1 CT [ d F d P ] ⏟ R = [ d F d P ] T [ RFFRFPRPFRPP ] [ d F d P ] J=\begin{ . bmatrix}\mathbf{d}_F\\\mathbf{d}_P\end{bmatrix}^T\underbrace{\mathbf{C}M^{-T}\mathbf{Q}M^{-1}\mathbf {C}^T\begin{bmatrix}\mathbf{d}_F\\\mathbf{d}_P\end{bmatrix}}_{\mathbf{R}}=\begin{bmatrix}\mathbf{d}_F \\\mathbf{d}_At{bmatrix}^T\begin{bmatrix}\mathbf{R}_{FF}&\mathbf{R}_{FP}\\\mathbf{R}_{PF} &\mathbf{R}_{PP}\end{bmatrix}\begin{bmatrix}\mathbf{d}_F\\\mathbf{d}_At\end{bmatrix}J=[dFdP]TR CMTQM1CT[dFdP]=[dFdP]T[RFFRPFRFPRPP][dFdP] So the objective function becomes an unconstrained quadratic programming problem, which can be solved in closed formJ = d FTRFF d F + d FTRFP d P + d PTRPF d F + d PTRPP d P d P ∗ = − RPP − 1 RFPT d F \begin{aligned}J=\mathbf{d}_F^T\mathbf{R}_{FF}\mathbf{d}_F+\mathbf{d}_F^T\mathbf{R}_{FP}\mathbf {d}_P+\mathbf{d}_P^T\mathbf{R}_{PF}\mathbf{d}_F+\mathbf{d}_P^T\mathbf{R}_{PP}\mathbf{d}_P \\ \mathbf{d}_P^*=-\mathbf{R}_{PP}^{-1}\mathbf{R}_{FP}^T\mathbf{d}_F\end{aligned}J=dFTRFFdF+dFTRFPdP+dPTRPFdF+dPTRPPdPdP=RPP1RFPTdF
PS: Why is the continuity constraint gone? Because the matrix CC can be selected by designC maps a variable ind \mathbf{d}In the two variables of d , the continuity constraint is satisfied

C C C 's design
insert image description here

Hierarchical approach

Use RRT* to get waypoints, then minimum snap to generate trajectory
insert image description here

Problem: safety issue

The path found by RRT is collision-free, but overshooting will occur after trajectory optimization.
insert image description here
Solution: add a waypoint to the collision part and regenerate the trajectory. If there is still a collision, continue to insert waypoints and generate in extreme cases. The trajectory of will be infinitely close to the absolutely safe path from path planninginsert image description here

better solution?

Increase the bounding box, and perform trajectory optimization under hard constraints (the next lecture will explain in detail).
insert image description here

Implementation Details

Convex Solvers

solver address Advantages and disadvantages
CVX http://cvxr.com/cvx/ Based on MATLAB implementation, slower
by Moses https://www.mosek.com/ Very robust, but only runs on x86 architecture
OOQP http://pages.cs.wisc.edu/~swright/ooqp/ Fast, open source, robust, but older code, poor readability
GLPK https://www.gnu.org/software/glpk/ Open source, robust, fast, has advantages in solving LP

Numerical Stability

insert image description here

Other engineering stuff

insert image description here

Time Allocation time allocation

insert image description here
insert image description hereinsert image description here

insert image description hereinsert image description here

reference

[1] Minimum Snap Trajectory Generation and Control for Quadrotors, Daniel Mellinger and Vijay Kumar
[2] Polynomial Trajectory Planning for Aggressive Quadrotor Flight in Dense Indoor Environments, Charles Richter, Adam Bry, and Nicholas Roy

Coding Tips

Take two tracks as an example:
insert image description here
insert image description hereinsert image description here

closed solution

insert image description here

ROS:
closed solution
insert image description here

Guess you like

Origin blog.csdn.net/sinat_52032317/article/details/132197045