发布于 

二连杆机械臂动力学推导(不考虑重力)

前言

前一阵子上了多体动力学的课,动力学方法里主流的两个流派有牛顿欧拉法和拉格朗日法,跟着老师上课也自己看书,梳理讲了一个二连杆机械臂的动力学推导,但是没有给具体的证明,自己按拉格朗日法写一下加深一下理解吧。

二连杆机械臂的动力学推导

书上给出了不考虑重力的动力学公式为:

Image
Image

这里的p1p_1p2p_2p3p_3q1q_1q2q_2都是什么东西?写得不清不楚的,不过推导动力学用拉格朗日是传统艺能了,我们就来推导一下。

不考虑重力、摩擦力和干扰,那我们就不用考虑系统的势能了。

Image
Image

作为一个二关节机械臂,我们认为连杆的质量都集中在末端,旋转关节都在始端,两个旋转关节的旋转角度分别如图旋转θ1\theta_1θ2\theta_2,我们取它们作为广义坐标。

从基座如图建立平面坐标系,我们可以写出每个连杆末端旋转副的位置.第一个连杆XX方向和YY方向的坐标为:

x1=l1cosθ1y1=l1sinθ1\begin{aligned} &x_1=l_1\cos\theta_1\\ &y_1=l_1\sin\theta_1 \end{aligned}

第二个连杆XX方向和YY方向的坐标为:

x2=l1cosθ1+l2cos(θ1+θ2)y2=l1sinθ1+l2sin(θ1+θ2)\begin{aligned} &x_2=l_1\cos\theta_1+l_2\cos(\theta_1+\theta_2)\\ &y_2=l_1\sin\theta_1+l_2\sin(\theta_1+\theta_2) \end{aligned}

第一个连杆XX方向和YY方向的速度(对时间求导)为:

x˙1=l1sinθ1θ1˙y˙1=l1cosθ1θ1˙\begin{aligned} &\dot{x}_1=-l_1\sin\theta_1\,\dot{\theta_1}\\ &\dot{y}_1=l_1\cos\theta_1\,\dot{\theta_1} \end{aligned}

第二个连杆XX方向和YY方向的速度(对时间求导)为:

x˙2=l1sinθ1θ1˙l2sin(θ1+θ2)(θ1˙+θ2˙)y˙2=l1cosθ1θ1˙+l2cos(θ1+θ2)(θ1˙+θ2˙)\begin{aligned} &\dot{x}_2=-l_1\sin\theta_1\,\dot{\theta_1}-l_2\sin(\theta_1+\theta_2)(\dot{\theta_1}+\dot{\theta_2})\\ &\dot{y}_2=l_1\cos\theta_1\,\dot{\theta_1}+l_2\cos(\theta_1+\theta_2)(\dot{\theta_1}+\dot{\theta_2}) \end{aligned}

第一个连杆的动能:

T1=12m1(x˙12+y˙12)=12m1[(l1sinθ1θ1˙)2+(l1cosθ1θ1˙)2]=12m1l12θ˙12\begin{aligned} T_1&=\frac{1}{2}m_1(\dot{x}_1^2+\dot{y}_1^2)\\ &=\frac{1}{2}m_1\left[\left(-l_1\sin\theta_1\,\dot{\theta_1}\right)^2+\left(l_1\cos\theta_1\,\dot{\theta_1}\right)^2\right]\\ &=\frac{1}{2}m_1l_1^2\dot{\theta}_1^2 \end{aligned}

第二个连杆的动能:

T2=12m2(x˙22+y˙22)=12m2{[l1sinθ1θ1˙l2sin(θ1+θ2)(θ1˙+θ2˙)]2+[l1cosθ1θ1˙+l2cos(θ1+θ2)(θ1˙+θ2˙))]2}=12m2[l12θ˙12+l22(θ˙1+θ˙2)2+2l1l2θ˙1(θ˙1+θ˙2)cosθ2]\begin{aligned} T_2&=\frac{1}{2}m_2(\dot{x}_2^2+\dot{y}_2^2)\\ &=\frac{1}{2}m_2\Biggr\{\left[-l_1\sin\theta_1\,\dot{\theta_1}-l_2\sin(\theta_1+\theta_2)(\dot{\theta_1}+\dot{\theta_2})\right]^2\\&\quad +\left[l_1\cos\theta_1\,\dot{\theta_1}+l_2\cos(\theta_1+\theta_2)(\dot{\theta_1}+\dot{\theta_2}))\right]^2\Biggr\}\\ &=\frac{1}{2}m_2\left[l_1^2\dot{\theta}_1^2+l_2^2(\dot{\theta}_1+\dot{\theta}_2)^2+2l_1l_2\dot{\theta}_1(\dot{\theta}_1+\dot{\theta}_2)\cos\theta_2\right] \end{aligned}

由于不考虑重力、摩擦力和干扰,于是系统的总能量就是两个动能之和,记作LL

L=T1+T2=12m1l12θ˙12+12m2[l12θ˙12+l22(θ˙1+θ˙2)2+2l1l2θ˙1(θ˙1+θ˙2)cosθ2]=12m1l12θ˙12+12m2l12θ˙12+12m2l22θ˙12+m2l22θ˙1θ˙2+12m2l22θ˙22+m2l1l2(θ˙12+θ˙1θ˙2)cosθ2\begin{aligned} L&=T_1+T_2\\ &=\frac{1}{2}m_1l_1^2\dot{\theta}_1^2+\frac{1}{2}m_2\left[l_1^2\dot{\theta}_1^2+l_2^2(\dot{\theta}_1+\dot{\theta}_2)^2+2l_1l_2\dot{\theta}_1(\dot{\theta}_1+\dot{\theta}_2)\cos\theta_2\right]\\ &=\frac{1}{2}m_1l_1^2\dot{\theta}_1^2+\frac{1}{2}m_2l_1^2\dot{\theta}_1^2+\frac{1}{2}m_2l_2^2\dot{\theta}_1^2+m_2l_2^2\dot{\theta}_1\dot{\theta}_2+\frac{1}{2}m_2l_2^2\dot{\theta}_2^2+m_2l_1l_2(\dot{\theta}_1^2+\dot{\theta}_1\dot{\theta}_2)\cos\theta_2 \end{aligned}

机器人在连杆1和连杆2的驱动关节力矩分别是τ1\tau_1τ2\tau_2,利用拉格朗日公式有:

ddt(Lθ1˙)Lθ1=τ1ddt(Lθ2˙)Lθ2=τ2\begin{aligned} &\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta_1}}\right)-\frac{\partial L}{\partial \theta_1}=\tau_1\\ &\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta_2}}\right)-\frac{\partial L}{\partial \theta_2}=\tau_2 \end{aligned}

代入上面的公式有:

ddt(Lθ1˙)=m1l12θ1¨+m2l12θ¨1+m2l22θ¨1+m2l22θ¨2+2m2l1l2cosθ2θ¨12m2l1l2sinθ2θ˙1θ˙2+m2l1l2cosθ2θ¨2m2l1l2sinθ2θ˙22\begin{aligned} \frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta_1}}\right)=&m_1l_1^2\ddot{\theta_1}+m_2l_1^2\ddot{\theta}_1+m_2l_2^2\ddot{\theta}_1+m_2l_2^2\ddot{\theta}_2\\&+2m_2l_1l_2\cos\theta_2\,\ddot{\theta}_1-2m_2l_1l_2\sin\theta_2\,\dot{\theta}_1\dot{\theta}_2\\&+m_2l_1l_2\cos\theta_2\,\ddot{\theta}_2-m_2l_1l_2\sin\theta_2\,\dot{\theta}_2^2\\ \end{aligned}

ddt(Lθ2˙)=m2l22θ¨1+m2l22θ¨2+m2l1l2cosθ2θ¨1m2l1l2sinθ2θ˙1θ˙2\begin{aligned} \frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta_2}}\right)=&m_2l_2^2\ddot{\theta}_1+m_2l_2^2\ddot{\theta}_2+m_2l_1l_2\cos\theta_2\,\ddot{\theta}_1\\&-m_2l_1l_2\sin\theta_2\,\dot{\theta}_1\dot{\theta}_2\\ \end{aligned}

Lθ1=0\begin{aligned} \frac{\partial L}{\partial \theta_1}=0 \end{aligned}

Lθ2=m2l1l2θ˙12sinθ2+m2l1l2θ˙1θ˙2sinθ2\begin{aligned} \frac{\partial L}{\partial \theta_2}=m_2l_1l_2\dot{\theta}_1^2\sin\theta_2+m_2l_1l_2\dot{\theta}_1\dot{\theta}_2\sin\theta_2 \end{aligned}

整理以后我们就有:

(m1l12+m2l12+m2l22+2m2l1l2cosθ2)θ¨1+(m2l1l2cosθ2+m2l22)θ¨22m2l1l2sinθ2θ˙1θ˙2m2l1l2sinθ2θ˙22=τ1\begin{aligned} &(m_1l_1^2+m_2l_1^2+m_2l_2^2+2m_2l_1l_2\cos\theta_2)\ddot{\theta}_1+(m_2l_1l_2\cos\theta_2+m_2l_2^2)\ddot{\theta}_2\\&-2m_2l_1l_2\sin\theta_2\dot{\theta}_1\dot{\theta}_2-m_2l_1l_2\sin\theta_2\dot{\theta}_2^2=\tau_1 \end{aligned}

(m2l1l2cosθ2+m2l22)θ¨1+m2l22θ¨2+m2l1l2sinθ2θ˙12=τ2\begin{aligned} &(m_2l_1l_2\cos\theta_2+m_2l_2^2)\ddot{\theta}_1+m_2l_2^2\ddot{\theta}_2+m_2l_1l_2\sin\theta_2\dot{\theta}_1^2=\tau_2 \end{aligned}

于是我们就可以写成书中的形式,描述为矩阵非常简洁的形式:

D(q)q¨+C(q,q˙)q˙=τ\begin{aligned} \mathbf{D(q)\ddot{q}+C(q,\dot{q})\dot{q}}=\bm{\tau} \end{aligned}

其中:

D(q)=[m1l12+m2l12+m2l22+2m2l1l2cosθ2m2l1l2cosθ2+m2l22m2l1l2cosθ2+m2l22m2l22]\mathbf{D(q)}=\begin{bmatrix} m_1l_1^2+m_2l_1^2+m_2l_2^2+2m_2l_1l_2\cos\theta_2 & m_2l_1l_2\cos\theta_2+m_2l_2^2\\ m_2l_1l_2\cos\theta_2+m_2l_2^2 & m_2l_2^2 \end{bmatrix}

C(q,q˙)=[m2l1l2sinθ2θ˙2m2l1l2sinθ2θ˙1m2l1l2sinθ2θ˙2m2l1l2sinθ2θ˙10]\mathbf{C(q,\dot{q})}=\begin{bmatrix} -m_2l_1l_2\sin\theta_2\dot{\theta}_2 & -m_2l_1l_2\sin\theta_2\dot{\theta}_1-m_2l_1l_2\sin\theta_2\dot{\theta}_2\\ m_2l_1l_2\sin\theta_2\dot{\theta}_1 & 0 \end{bmatrix}

q=[θ1θ2]q˙=[θ˙1θ˙2]τ=[τ1τ2]\mathbf{q}=\begin{bmatrix} \theta_1\\ \theta_2 \end{bmatrix}\quad \dot{\mathbf{q}}=\begin{bmatrix} \dot{\theta}_1\\ \dot{\theta}_2 \end{bmatrix}\quad \bm{\tau}=\begin{bmatrix} {\tau}_1\\ {\tau}_2 \end{bmatrix}

这也就解释了开头书中的公式:

Image
Image

其中

p1=m1l12+m2l12p2=m2l22p2=m2l1l2\begin{aligned} p_1&=m_1l_1^2+m_2l_1^2\\ p_2&=m_2l_2^2\\ p_2&=m_2l_1l_2 \end{aligned}