5th order polynomial trajectory

Prerequisites

  • In order to obtain a trajectory with continuous velocity, each trajectory in the trajectory needs to satisfy position and velocity constraints (4 boundary conditions), that is, the previous trajectory J i − 1 J_{i-1}Ji1The end position and speed ofJiThe position and velocity of are the same, so a third-order polynomial is used to represent each trajectory.
  • In order to obtain a trajectory with continuous acceleration, each trajectory in the trajectory needs to satisfy position, velocity and acceleration constraints (6 boundary conditions), that is, the previous trajectory J i − 1 J_{i-1}Ji1The end position, speed and acceleration must be the same as those of the next trajectory J i J_{i}JiThe position, velocity and acceleration of are the same, so a fifth-order polynomial is used to represent each trajectory.

text

  For a trajectory, a continuous trajectory can usually be segmented into multi-segment polynomial trajectories. Here, each trajectory is considered to be represented by a fifth-order polynomial. The time corresponding to each trajectory is from 0 0Starting from 0 toT i T_iTiend, that is, for the iii segment trajectoryJ i J_iJi, its start time is 0 00 , the end time isT i T_iTi, the starting position, speed and acceleration are respectively pi p_ipivi v_iviai a_iai。根据多项式轨迹的定义
p = c 0 + c 1 t + c 2 t 2 + c 3 t 3 + c 4 t 4 + c 5 t 5 v = c 1 + 2 c 2 t + 3 c 3 t 2 + 4 c 4 t 3 + 5 c 5 t 4 a = 2 c 2 + 6 c 3 t + 12 c 4 t 2 + 20 c 5 t 3 j e r k = 6 c 3 + 24 c 4 t + 60 c 5 t 2 s n a p = 24 c 4 + 120 c 5 t . ( 公 式 1 ) \begin{aligned} p&=c_{0}+c_{1}t+c_{2}t^2+c_{3}t^3+c_{4}t^4+c_{5}t^5 \\ v&=\quad\quad c_{1}+2c_{2}t+3c_{3}t^2+4c_{4}t^3+5c_{5}t^4 \\ a&=\quad\quad\quad\quad2c_{2}+6c_{3}t+12c_{4}t^2+20c_{5}t^3 \\ jerk&=\quad\quad\quad\quad\quad\quad \quad6c_{3}+24c_{4}t+60c_{5}t^2 \\ snap&=\quad\quad\quad\quad\quad\quad \quad\quad \quad\quad 24c_{4}+120c_{5}t. \quad\quad(公式1)\\ \end{aligned} pvajerksnap=c0+c1t+c2t2+c3t3+c4t4+c5t5=c1+2 c2t+3c _3t2+4c4t3+5 c5t4=2 c2+6c _3t+12c4t2+20c5t3=6c _3+24c4t+60 c _5t2=24c4+120c5t.( Official 1 )
Take No. 1 1Taking 1 segment of trajectory as an example, sett = 0 t=0t=By bringing 0 into (Formula 1), we can get the beginning of the first trajectory:
p 1 ( 0 ) = c 10 , v 1 ( 0 ) = c 11 , a 1 ( 0 ) = 2 c 12 . \begin{aligned} p_1 (0)&=c_{10}, \\ v_1(0)&=c_{11},\\ a_1(0)&=2c_{12}. \end{aligned}p1(0)v1(0)a1(0)=c10,=c11,=2 c12.
Let t = T 1 t=T_1t=T1Bringing in (Formula 1) we can get the initial end of the first segment of the trajectory:
p 1 ( T 1 ) = c 10 + c 11 ( T 1 − 0 ) + c 12 ( T 1 − 0 ) 2 + c 13 ( T 1 − 0 ) 3 + c 14 ( T 1 − 0 ) 4 + c 15 ( T 1 − 0 ) 5 = c 10 + c 11 T 1 + c 12 T 1 2 + c 13 T 1 3 + c 14 T 1 4 + c 15 T 1 5 , v 1 ( T 1 ) = c 11 + 2 c 12 ( T 1 − 0 ) + 3 c 13 ( T 1 − 0 ) 2 + 4 c 14 ( T 1 − 0 ) 3 + 5 c 15 ( T 1 − 0 ) 4 = c 11 + 2 c 12 ( T 1 ) + 3 c 13 ( T 1 ) 2 + 4 c 14 ( T 1 ) 3 + 5 c 15 ( T 1 ) 4 , a 1 ( T 1 ) = 2 c 12 + 6 c 13 ( T 1 − 0 ) + 12 c 14 ( T 1 − 0 ) 2 + 20 c 15 ( T 1 − 0 ) 3 = 2 c 12 + 6 c 13 ( T 1 ) + 12 c 14 ( T 1 ) 2 + 20 c 15 ( T 1 ) 3 . \begin{aligned} p_1(T_1)&=c_{10}+c_{11}(T_1-0)+c_{12}(T_1-0)^2+c_{13}(T_1-0)^3+c_{14}(T_1-0)^4+c_{15}(T_1-0)^5 \\ & = c_{10}+c_{11}T_1+c_{12}T_1^2+c_{13}T_1^3+c_{14}T_1^4+c_{15}T_1^5, \\ v_1(T_1)&=c_{11}+2c_{12}(T_1-0)+3c_{13}(T_1-0)^2+4c_{14}(T_1-0)^3+5c_{15}(T_1-0)^4 \\ & = c_{11}+2c_{12}(T_1)+3c_{13}(T_1)^2+4c_{14}(T_1)^3+5c_{15}(T_1)^4, \\ a_1(T_1)&=2c_{12}+6c_{13}(T_1-0)+12c_{14}(T_1-0)^2+20c_{15}(T_1-0)^3\\ & = 2c_{12}+6c_{13}(T_1)+12c_{14}(T_1)^2+20c_{15}(T_1)^3. \end{aligned} p1(T1)v1(T1)a1(T1)=c10+c11(T10)+c12(T10)2+c13(T10)3+c14(T10)4+c15(T10)5=c10+c11T1+c12T12+c13T13+c14T14+c15T15,=c11+2 c12(T10)+3c _13(T10)2+4c14(T10)3+5 c15(T10)4=c11+2 c12(T1)+3c _13(T1)2+4c14(T1)3+5 c15(T1)4,=2 c12+6c _13(T10)+12c14(T10)2+20c15(T10)3=2 c12+6c _13(T1)+12c14(T1)2+20c15(T1)3.
In the same way, we can get the beginning of the second trajectory:
p 2 ( 0 ) = c 20 , v 2 ( 0 ) = c 21 , a 2 ( 0 ) = 2 c 22 . \begin{aligned} p_2(0)&= c_{20}, \\ v_2(0)&=c_{21},\\ a_2(0)&=2c_{22}. \end{aligned}p2(0)v2(0)a2(0)=c20,=c21,=2 c22.
Since a trajectory is composed of multiple polynomial trajectories, it needs to satisfy:
{ c 10 = p 1 ( 0 ): starting position boundary condition c 11 = v 1 ( 0 ): starting speed boundary condition 2 c 12 = a 1 ( 0 ): starting acceleration boundary condition The previous segment of the trajectory terminates jerk and The starting snap of the latter segment of the trajectory is the same, and there is no jerk size constraint, that is, jerk 1 ( T 1 ) − jerk 2 ( 0 ) = 0 6 c 13 + 24 c 14 T 1 + 60 c 15 T 1 2 − 6 c 23 = 0 The ending snap of the previous trajectory is the same as the starting snap of the following trajectory, without snap size constraints, that is, snap 1 ( T 1 ) − snap 2 ( 0 ) = 0 24 c 14 + 120 T 1 − 24 c 24 = 0 Previous trajectory The end position is the same as the starting position of the next segment of the trajectory, that is, p 1 ( T 1 ) = p 2 ( 0 ):c 10 + c 11 T 1 + c 12 T 1 2 + c 13 T 1 3 + c 14 T 1 4 + c 15 T 1 5 = p 2 ( 0 ) c 10 + c 11 T 1 + c 12 T 1 2 + c 13 T 1 3 + c 14 T 1 4 + c 15 T 1 5 − c 20 = 0 The end position of the previous trajectory is the same as the starting speed of the next trajectory, that is, v 1 ( T 1 ) − v 2 ( 0 ) = 0 c 11 + 2 c 12 T 1 + 3 c 13 T 1 2 + 4 c 14 T 1 3 + 5 c 15 T 1 4 − c 21 = 0 The end position of the previous trajectory is the same as the starting acceleration of the next trajectory. That is, a 1 ( T 1 ) − a 2 ( 0 ) = 0 2 c 12 + 6 c 13 T 1 + 12 c 14 T 1 2 + 20 c 15 T 1 3 − 2 c 22 = 0 \left\{\begin {aligned} &c_{10}=p_1(0): Starting position boundary condition\\ &c_{11}=v_1(0): Starting velocity boundary condition\\ &2c_{12}=a_1(0): Starting acceleration Boundary conditions\\ &The ending jerk of the previous trajectory is the same as the starting snap of the following trajectory. There is no jerk size constraint, that is, jerk_1(T_1)-jerk_2(0)=0\\ &6c_{13}+24c_{14}T_1+60c_ {15}T_1^2-6c_{23}=0\\ &The ending snap of the previous trajectory is the same as the starting snap of the following trajectory. There is no snap size constraint, that is, snap_1(T_1)-snap_2(0)=0\\ &24c_ {14}+120T_1-24c_{24}=0\\ &The end position of the previous trajectory is the same as the starting position of the next trajectory, that is, p_1(T_1)=p_2(0):\\ &c_{10}+c_{11}T_1+c_{12}T_1^2+c_{13}T_1^3+c_{14}T_1^4+c_{15}T_1^5=p_2(0)\ \ &c_{10}+c_{11}T_1+c_{12}T_1^2+c_{13}T_1^3+c_{14}T_1^4+c_{15}T_1^5-c_{20}=0 \\ &The end position of the previous trajectory is the same as the starting speed of the next trajectory, that is, v_1(T_1)-v_2(0)=0\\ &c_{11}+2c_{12}T_1+3c_{13}T_1^2+ 4c_{14}T_1^3+5c_{15}T_1^4-c_{21}=0\\ &The end position of the previous trajectory is the same as the starting acceleration of the next trajectory, that is, a_1(T_1)-a_2(0)= 0\\ &2c_{12}+6c_{13}T_1+12c_{14}T_1^2+20c_{15}T_1^3-2c_{22}=0\\ \end{aligned}\right.c10=p1(0):Starting position boundary conditionsc11=v1(0):Starting velocity boundary condition2 c12=a1(0):Starting acceleration boundary conditionThe end j e r k of the previous segment of the trajectory is the same as the starting sn a p of the next segment of the trajectory , and there is no j e r k size constraint , that is, j e r k1(T1)jerk2(0)=06c _13+24c14T1+60 c _15T126c _23=0The ending s n a p of the previous segment of the trajectory is the same as the starting s n a p of the next segment of the trajectory , and there is no s n a p size constraint , that is, s n a p1(T1)snap2(0)=024c14+120T124c24=0The end position of the previous trajectory is the same as the starting position of the next trajectory , that is , p1(T1)=p2(0):c10+c11T1+c12T12+c13T13+c14T14+c15T15=p2(0)c10+c11T1+c12T12+c13T13+c14T14+c15T15c20=0The end position of the previous trajectory is the same as the starting speed of the next trajectory , that is , v1(T1)v2(0)=0c11+2 c12T1+3c _13T12+4c14T13+5 c15T14c21=0The end position of the previous trajectory is the same as the starting acceleration of the next trajectory , that is , a1(T1)a2(0)=02 c12+6c _13T1+12c14T12+20c15T132 c22=0

Convert the above constraints into matrix Ax=b form, we can get:
x = [ c 10 c 11 c 12 c 13 c 14 c 15 c 20 c 21 c 22 c 23 c 24 c 25 ] x=\begin{bmatrix} c_ {10}\\ c_{11}\\ c_{12} \\ c_{13} \\ c_{14} \\ c_{15} \\ c_{20} \\ c_{21} \\ c_{22 } \\ c_{23} \\ c_{24} \\ c_{25} \\ \end{bmatrix}x=c10c11c12c13c14c15c20c21c22c23c24c25

b = [ p 1 ( 0 ) v 1 ( 0 ) a 1 ( 0 ) 0 0 p 2 ( 0 ) 0 0 0 ] b=\begin{bmatrix} {p_1(0)}\\ {v_1(0)}\\ {a_1(0)}\\ 0\\ 0\\ p_2(0)\\ 0\\ 0\\ 0\\ \\ \end{bmatrix} b=p1(0)v1(0)a1(0)00p2(0)000

Construct the A matrix as follows:

0 1 2 3 4 5 6 7 8 9 10 11
0 1 1 1
1 1 11
2 2 2 2
3 6 6 6 24 T 1 24T_1 24T1 60 T 1 2 60T_1^2 6 0 T12 − 6 -6 6
4 24 24 24 120 T 1 120T_1 120T1 − 24 -24 24
5 1 11 T 1 T_1 T1 T 1 2 T_1^2 T12 T 1 3 T_1^3 T13 T 1 4 T_1^4 T14 T 1 5 T_1^5 T15
6 1 11 T 1 T_1T1 T 1 2 T_1^2T12 T 1 3 T_1^3T13 T 1 4 T_1^4T14 T 1 5 T_1^5T15 − 1 -1 1
7 1 11 2 T 1 2T_1 2T _1 3 T 1 2 3T_1^23T _12 4 T 1 3 4T_1^3 4 T13 5 T 1 4 5T_1^4 5T14 − 1 -1 1
8 2 2 2 6 T 6T 6 T 12 T 1 2 12T_1^2 1 2 T12 20 T 1 3 20T_1^3 2 0T _13 − 2 -2 2
9
10 1 1 1 T 2 T_2 T2 T 2 2 T_2^2 T22 T 2 3 T_2^3 T23 T 2 4 T_2^4 T24 T 2 5 T_2^5 T25
11 1 11 2 T 2 2T_2 2T _2 3 T 2 2 3T_2^23T _22 4 T 2 3 4T_2^3 4 T23 5 T 2 4 5T_2^4 5T24
12 2 22 6 T 2 6T_2 6 T2 12 T 2 2 12T_2^2 1 2 T22 20 T 2 3 20T_2^3 2 0T _23

Note : Red is the row/column label.

inline void generate(const Eigen::MatrixXd &inPs,
const Eigen::VectorXd &ts)
{
    
    
	T1 = ts;
	T2 = T1.cwiseProduct(T1);
	T3 = T2.cwiseProduct(T1);
	T4 = T2.cwiseProduct(T2);
	T5 = T4.cwiseProduct(T1);
	A.reset();
	b.setZero();
	A(0, 0) = 1.0;
	A(1, 1) = 1.0;
	A(2, 2) = 2.0;
	b.row(0) = headPVA.col(0).transpose();
	b.row(1) = headPVA.col(1).transpose();
	b.row(2) = headPVA.col(2).transpose();
	for (int i = 0; i < N - 1; i++)
	{
    
    
		A(6 * i + 3, 6 * i + 3) = 6.0;
		A(6 * i + 3, 6 * i + 4) = 24.0 * T1(i);
		A(6 * i + 3, 6 * i + 5) = 60.0 * T2(i);
		A(6 * i + 3, 6 * i + 9) = -6.0;
		A(6 * i + 4, 6 * i + 4) = 24.0;
		A(6 * i + 4, 6 * i + 5) = 120.0 * T1(i);
		A(6 * i + 4, 6 * i + 10) = -24.0;
		A(6 * i + 5, 6 * i) = 1.0;
		A(6 * i + 5, 6 * i + 1) = T1(i);
		A(6 * i + 5, 6 * i + 2) = T2(i);
		A(6 * i + 5, 6 * i + 3) = T3(i);
		A(6 * i + 5, 6 * i + 4) = T4(i);
		A(6 * i + 5, 6 * i + 5) = T5(i);
		A(6 * i + 6, 6 * i) = 1.0;
		A(6 * i + 6, 6 * i + 1) = T1(i);
		A(6 * i + 6, 6 * i + 2) = T2(i);
		A(6 * i + 6, 6 * i + 3) = T3(i);
		A(6 * i + 6, 6 * i + 4) = T4(i);
		A(6 * i + 6, 6 * i + 5) = T5(i);
		A(6 * i + 6, 6 * i + 6) = -1.0;
		A(6 * i + 7, 6 * i + 1) = 1.0;
		A(6 * i + 7, 6 * i + 2) = 2 * T1(i);
		A(6 * i + 7, 6 * i + 3) = 3 * T2(i);
		A(6 * i + 7, 6 * i + 4) = 4 * T3(i);
		A(6 * i + 7, 6 * i + 5) = 5 * T4(i);
		A(6 * i + 7, 6 * i + 7) = -1.0;
		A(6 * i + 8, 6 * i + 2) = 2.0;
		A(6 * i + 8, 6 * i + 3) = 6 * T1(i);
		A(6 * i + 8, 6 * i + 4) = 12 * T2(i);
		A(6 * i + 8, 6 * i + 5) = 20 * T3(i);
		A(6 * i + 8, 6 * i + 8) = -2.0;
		b.row(6 * i + 5) = inPs.col(i).transpose();
	}
	A(6 * N - 3, 6 * N - 6) = 1.0;
	A(6 * N - 3, 6 * N - 5) = T1(N - 1);
	A(6 * N - 3, 6 * N - 4) = T2(N - 1);
	A(6 * N - 3, 6 * N - 3) = T3(N - 1);
	A(6 * N - 3, 6 * N - 2) = T4(N - 1);
	A(6 * N - 3, 6 * N - 1) = T5(N - 1);
	A(6 * N - 2, 6 * N - 5) = 1.0;
	A(6 * N - 2, 6 * N - 4) = 2 * T1(N - 1);
	A(6 * N - 2, 6 * N - 3) = 3 * T2(N - 1);
	A(6 * N - 2, 6 * N - 2) = 4 * T3(N - 1);
	A(6 * N - 2, 6 * N - 1) = 5 * T4(N - 1);
	A(6 * N - 1, 6 * N - 4) = 2;
	A(6 * N - 1, 6 * N - 3) = 6 * T1(N - 1);
	A(6 * N - 1, 6 * N - 2) = 12 * T2(N - 1);
	A(6 * N - 1, 6 * N - 1) = 20 * T3(N - 1);
	b.row(6 * N - 3) = tailPVA.col(0).transpose();
	b.row(6 * N - 2) = tailPVA.col(1).transpose();
	b.row(6 * N - 1) = tailPVA.col(2).transpose();
	A.factorizeLU();
	A.solve(b);
	return;

Guess you like

Origin blog.csdn.net/qq_16775293/article/details/125621501