单腿建模
*规定z轴沿关节轴的i指向
*规定x轴沿两关节公垂线从i指向i+1
*规定y轴按右手定则
单腿坐标系变换关系参数表
连杆 | θ i θ_i θi | d i d_i di | a i a_i ai | α i α_i αi |
---|---|---|---|---|
L1 | θ 1 θ_1 θ1 | 0 | a 1 a_1 a1 | p i 4 \frac{pi}{4} 4pi |
L2 | θ 2 θ_2 θ2 | 0 | a 2 a_2 a2 | 0 |
L3 | θ 3 θ_3 θ3 | 0 | a 3 a_3 a3 | 0 |
- θ i θ_i θi为x轴间夹角
- d i d_i di为沿z轴,x轴的间距
- a i a_i ai为沿x轴,z轴的间距
- r i r_i ri 为z轴间夹角
则 T i i − 1 = R z ( θ i ) ∗ t r a n s ( 0 , 0 , d i ) t r a n s ( a i , 0 , 0 ) R x ( d i ) T_i^{i-1} =R_z(θ_i)*trans(0,0,d_i)trans(a_i,0,0)R_x(d_i) Tii−1=Rz(θi)∗trans(0,0,di)trans(ai,0,0)Rx(di)
T 2 1 = [ c o s θ 1 − s i n θ 1 0 0 s i n θ 1 c o s θ 1 0 0 0 0 1 0 0 0 0 1 ] ∗ [ 1 0 0 a 1 0 1 0 0 0 0 1 0 0 0 0 1 ] ∗ [ 1 0 0 0 0 0 − 1 0 0 1 0 0 0 0 0 1 ] = [ c o s θ 1 0 s i n θ 1 a 1 ∗ c o s θ 1 s i n θ 1 0 − c o s θ 1 a 1 ∗ s i n θ 1 0 1 0 0 0 0 0 1 ] T_2^1=\begin{bmatrix} cosθ_1&-sinθ_1&0&0\\ sinθ_1&cosθ_1&0&0\\0&0&1&0\\0&0&0&1\end{bmatrix}*\begin{bmatrix} 1&0&0&a_1\\ 0&1&0&0\\0&0&1&0\\0&0&0&1\end{bmatrix}*\begin{bmatrix} 1&0&0&0\\ 0&0&-1&0\\0&1&0&0\\0&0&0&1\end{bmatrix}=\begin{bmatrix} cosθ_1&0&sinθ_1&a_1*cosθ_1\\ sinθ_1&0&-cosθ_1&a_1*sinθ_1\\0&1&0&0\\0&0&0&1\end{bmatrix} T21= cosθ1sinθ100−sinθ1cosθ10000100001 ∗ 100001000010a1001 ∗ 100000100−1000001 = cosθ1sinθ1000010sinθ1−cosθ100a1∗cosθ1a1∗sinθ101
T 3 2 = [ c o s θ 2 − s i n θ 2 0 a 2 ∗ c o s θ 2 s i n θ 2 c o s θ 2 0 a 2 ∗ s i n θ 2 0 0 1 0 0 0 0 1 ] T_3^2=\begin{bmatrix} cosθ_2&-sinθ_2&0&a_2*cosθ_2\\ sinθ_2&cosθ_2&0&a_2*sinθ_2\\0&0&1&0\\0&0&0&1\end{bmatrix} T32= cosθ2sinθ200−sinθ2cosθ2000010a2∗cosθ2a2∗sinθ201
T 4 2 = [ c o s θ 3 − s i n θ 3 0 a 3 ∗ c o s θ 3 s i n θ 3 c o s θ 3 0 θ 3 ∗ s i n θ 3 0 0 1 0 0 0 0 1 ] T_4^2=\begin{bmatrix} cosθ_3&-sinθ_3&0&a_3*cosθ_3\\ sinθ_3&cosθ_3&0&θ_3*sinθ_3\\0&0&1&0\\0&0&0&1\end{bmatrix} T42= cosθ3sinθ300−sinθ3cosθ3000010a3∗cosθ3θ3∗sinθ301
正运动学
通过 θ 1 , θ 2 , θ 3 θ_1,θ_2,θ_3 θ1,θ2,θ3求解足尖坐标 ( x , y , z ) (x,y,z) (x,y,z)
T 4 1 = T 2 1 ∗ T 3 2 ∗ T 3 4 = [ − − − a 1 c o s θ 1 + a 2 c o s θ 1 c o s θ 2 + a 3 c o s θ 1 c o s θ 2 c o s θ 3 − a 3 c o s θ 1 s i n θ 2 s i n θ 3 − − − a 1 s i n θ 1 + a 2 s i n θ 1 c o s θ 2 + a 3 s i n θ 1 c o s θ 2 c o s θ 3 − a 3 s i n θ 1 s i n θ 2 s i n θ 3 − − − a 2 s i n θ 2 + a 3 c o s θ 2 s i n θ 3 + a 3 s i n θ 2 c o s θ 3 0 0 0 1 ] T_4^1=T_2^1*T_3^2*T_3^4=\begin{bmatrix} -&-&-&a_1cosθ_1+a_2cosθ_1cosθ_2+a_3cosθ_1cosθ_2cosθ_3-a_3cosθ_1sinθ_2sinθ_3\\ -&-&-&a_1sinθ_1+a_2sinθ_1cosθ_2+a_3sinθ_1cosθ_2cosθ_3-a_3sinθ_1sinθ_2sinθ_3\\-&-&-&a_2sinθ_2+a_3cosθ_2sinθ_3+a_3sinθ_2cosθ_3\\0&0&0&1\end{bmatrix} T41=T21∗T32∗T34= −−−0−−−0−−−0a1cosθ1+a2cosθ1cosθ2+a3cosθ1cosθ2cosθ3−a3cosθ1sinθ2sinθ3a1sinθ1+a2sinθ1cosθ2+a3sinθ1cosθ2cosθ3−a3sinθ1sinθ2sinθ3a2sinθ2+a3cosθ2sinθ3+a3sinθ2cosθ31
则
x
=
a
1
c
o
s
θ
1
+
a
2
c
o
s
θ
1
c
o
s
θ
2
+
a
3
c
o
s
θ
1
c
o
s
θ
2
c
o
s
θ
3
−
a
3
c
o
s
θ
1
s
i
n
θ
2
s
i
n
θ
3
x=a_1cosθ_1+a_2cosθ_1cosθ_2+a_3cosθ_1cosθ_2cosθ_3-a_3cosθ_1sinθ_2sinθ_3
x=a1cosθ1+a2cosθ1cosθ2+a3cosθ1cosθ2cosθ3−a3cosθ1sinθ2sinθ3
y = a 1 s i n θ 1 + a 2 s i n θ 1 c o s θ 2 + a 3 s i n θ 1 c o s θ 2 c o s θ 3 − a 3 s i n θ 1 s i n θ 2 s i n θ 3 y=a_1sinθ_1+a_2sinθ_1cosθ_2+a_3sinθ_1cosθ_2cosθ_3-a_3sinθ_1sinθ_2sinθ_3 y=a1sinθ1+a2sinθ1cosθ2+a3sinθ1cosθ2cosθ3−a3sinθ1sinθ2sinθ3
z = a 2 s i n θ 2 + a 3 c o s θ 2 s i n θ 3 + a 3 s i n θ 2 c o s θ 3 z=a_2sinθ_2+a_3cosθ_2sinθ_3+a_3sinθ_2cosθ_3 z=a2sinθ2+a3cosθ2sinθ3+a3sinθ2cosθ3
逆运动学
已知足尖坐标 p ( x , y , z ) p(x,y,z) p(x,y,z)
设 T 4 1 = [ − − − x − − − y − − − z 0 0 0 1 ] T_4^1=\begin{bmatrix} -&-&-&x\\ -&-&-&y\\-&-&-&z\\0&0&0&1\end{bmatrix} T41= −−−0−−−0−−−0xyz1
由 T 4 1 = T 2 1 ∗ T 3 2 ∗ T 3 4 T_4^1=T_2^1*T_3^2*T_3^4 T41=T21∗T32∗T34 有 ( T 2 1 ) − 1 ∗ T 4 1 = T 3 2 ∗ T 3 4 (T_2^1)^{-1}*T_4^1=T_3^2*T_3^4 (T21)−1∗T41=T32∗T34
得 x c o s θ 1 − a 1 + y s i n θ 1 = a 2 c o s θ 2 + a 3 c o s ( θ 2 + θ 3 ) xcosθ_1-a_1+ysinθ_1=a_2cosθ_2+a_3cos(θ_2+θ_3) xcosθ1−a1+ysinθ1=a2cosθ2+a3cos(θ2+θ3)
z = a 2 s i n θ 2 + a 3 s i n ( θ 2 + θ 3 ) z=a_2sinθ_2+a_3sin(θ_2+θ_3) z=a2sinθ2+a3sin(θ2+θ3)
x s i n θ 1 − y c o s θ 1 = 0 xsinθ_1-ycosθ_1=0 xsinθ1−ycosθ1=0
解得
θ 1 = a t a n ( y / x ) θ_1=atan(y/x) θ1=atan(y/x)
θ 3 = ∓ a c o n ( M 2 + z 2 − a 2 2 − a 3 2 2 a 2 a 3 ) θ_3=∓acon(\frac{M^2+z^2-a_2^2-a_3^2}{2a_2a_3}) θ3=∓acon(2a2a3M2+z2−a22−a32)
θ 2 = p i 2 − a c o s z a 3 c o s θ 3 + z a 2 − M a 3 s i n θ 3 M 2 + z 2 θ_2=\frac{pi}{2}-acos\frac{za_3cosθ_3+za_2-Ma_3sinθ_3}{M^2+z^2} θ2=2pi−acosM2+z2za3cosθ3+za2−Ma3sinθ3
注: M = x c o s θ 1 + y s i n θ 1 − a 1 M=xcosθ_1+ysinθ_1-a_1 M=xcosθ1+ysinθ1−a1
在MATALB中验证正确性:
伪代码:
1 穷举
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3在
(
−
p
i
4
,
p
i
4
)
(-\frac{pi}{4},\frac{pi}{4})
(−4pi,4pi)的所有状态
2 将所有状态正解为坐标
p
i
(
x
i
,
y
i
,
z
i
)
p_i(x_i,y_i,z_i)
pi(xi,yi,zi)
3 将所有
p
i
(
x
i
,
y
i
,
z
i
)
p_i(x_i,y_i,z_i)
pi(xi,yi,zi)逆解为
θ
1
∗
,
θ
2
∗
,
θ
3
∗
θ_1^*,θ_2^*,θ_3^*
θ1∗,θ2∗,θ3∗
4 将
θ
1
∗
,
θ
2
∗
,
θ
3
∗
θ_1^*,θ_2^*,θ_3^*
θ1∗,θ2∗,θ3∗与
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3进行比较,误差范围在
∓
0.01
∓0.01
∓0.01视为正确
5 将正确的
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3在图1显示,否则在图2显示;将单腿运动范围在图3显示
结果:
图1:正确的
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3
图2:错误的
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3图3:单腿运动范围
从验证结果可以看到,该逆解公式在
θ
1
,
θ
2
,
θ
3
∊
(
−
p
i
4
,
p
i
4
)
θ_1,θ_2,θ_3∊(-\frac{pi}{4},\frac{pi}{4})
θ1,θ2,θ3∊(−4pi,4pi)范围内完全正确,图3可对后面的单腿轨迹规划作一定参考
单腿轨迹规划
在单腿向前运动的一个周期T中,在
(
0
,
T
2
)
(0,\frac{T}{2})
(0,2T)用抛物线形成的拱形轨迹,在
(
T
2
,
T
)
(\frac{T}{2},T)
(2T,T)的轨迹为直线段。
s
s
s为步长,
h
h
h为迈步高度
y
=
{
−
s
2
4
∗
x
2
+
h
x
∊
(
0
,
T
2
)
s
2
−
x
x
∊
(
T
2
,
T
)
y=\begin{cases} -\frac{s^2}{4}*x^2+h & x∊(0,\frac{T}{2}) \\ \frac{s}{2}-x & x∊(\frac{T}{2},T)\\ \end{cases}
y={−4s2∗x2+h2s−xx∊(0,2T)x∊(2T,T)
通过运动学逆解将轨迹转化为三个关节坐标,实现单腿运动规划
前进的三角步态生成
三角步态特点:L1 L3 R2同相 R1 R3 L2 同相; (L1 L3 R2) 超前 (R1 R3 L2) T/2;同一组的三个足始终呈三角形向前运动
由以上特点建立以下单组腿的位置关系
设足尖1对坐标系1的坐标为
p
1
(
x
0
,
y
0
)
p_1(x_0,y_0)
p1(x0,y0)
足尖1对坐标系0的坐标为 p 1 ∗ ( x 0 , y 0 + b 2 ) p_1^*(x_0,y_0+b_2) p1∗(x0,y0+b2)
足尖2对坐标系0的坐标为 p 2 ∗ ( x 0 + c 1 , y 0 + b 2 − c 2 − c 3 ) p_2^*(x_0+c_1,y_0+b_2-c_2-c_3) p2∗(x0+c1,y0+b2−c2−c3)
足尖3对坐标系0的坐标为 p 3 ∗ ( x 0 − c 1 , y 0 + b 2 − c 2 − c 3 ) p_3^*(x_0-c_1,y_0+b_2-c_2-c_3) p3∗(x0−c1,y0+b2−c2−c3)
足尖2对坐标系2的坐标为 p 2 ( − 2 2 ( x 0 + y 0 − b 1 + b 2 + b 3 + c 1 − c 2 − c 3 ) , − 2 2 ( − x 0 + y 0 + b 1 + b 2 + b 3 − c 1 − c 2 − c 3 ) ) p_2(-\frac{\sqrt2}{2}(x_0+y_0-b_1+b_2+b_3+c_1-c_2-c_3),- \frac{\sqrt2}{2}(-x_0+y_0+b_1+b_2+b_3-c_1-c_2-c_3)) p2(−22(x0+y0−b1+b2+b3+c1−c2−c3),−22(−x0+y0+b1+b2+b3−c1−c2−c3))
足尖3对坐标系3的坐标为 p 3 ( − 2 2 ( x 0 − y 0 + b 1 − b 2 − b 3 − c 1 + c 2 + c 3 ) , − 2 2 ( x 0 + y 0 + b 1 + b 2 + b 3 − c 1 − c 2 − c 3 ) ) p_3(-\frac{\sqrt2}{2}(x_0-y_0+b_1-b_2-b_3-c_1+c_2+c_3),-\frac{\sqrt2}{2}(x_0+y_0+b_1+b_2+b_3-c_1-c_2-c_3)) p3(−22(x0−y0+b1−b2−b3−c1+c2+c3),−22(x0+y0+b1+b2+b3−c1−c2−c3))
即我们可以通过只对足尖1进行轨迹规划,通过以上关系求出在三角形约束条件下的足尖2和足尖3的轨迹
伪代码
1 规划足尖1运动轨迹
p
1
(
x
1
,
y
1
,
z
1
)
p_1(x_1,y_1,z_1)
p1(x1,y1,z1)
2 通过上述关系求出足尖2和足尖3运动轨迹
p
2
(
x
2
,
y
2
,
z
2
)
p_2(x_2,y_2,z_2)
p2(x2,y2,z2)和
p
3
(
x
3
,
y
3
,
z
3
)
p_3(x_3,y_3,z_3)
p3(x3,y3,z3)
3 将三个足尖轨迹在图1中显示
4 将轨迹坐标逆解为角度
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3
5 将
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3正解为
p
1
∗
p_1^*
p1∗、
p
2
∗
p_2^*
p2∗和
p
3
∗
p_3^*
p3∗,并与
p
1
p_1
p1、
p
2
p_2
p2和
p
3
p_3
p3进行对比,在误差允许范围内视正确,否则错误
6 将错误个数输出,将转化的
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3输出
结果:
图1:足尖轨迹
最后将输出的
θ
1
,
θ
2
,
θ
3
θ_1,θ_2,θ_3
θ1,θ2,θ3作为输入,在仿真环境中进行验证