Initiation à la robotique Ces notes établissent les modèles géométriques direct et inverse d'une patte de robot à trois articulations, à partir de matrices de rotation et de la loi des cosinus. Le projet, mené à cinq, applique ces modèles au contrôle d'un robot quadrupède puis d'un hexapode, en simulation avec PyBullet.
Définition du problème
On cherche à trouver le modèle direct, i.e. l'expression de ( x , y , z ) (x,y,z) ( x , y , z ) en fonction
de ( θ 0 , θ 1 , θ 2 ) (\theta_0, \theta_1, \theta_2) ( θ 0 , θ 1 , θ 2 ) , puis l'expression de ( θ 0 , θ 1 , θ 2 ) (\theta_0, \theta_1,
\theta_2) ( θ 0 , θ 1 , θ 2 ) en fonction de ( x , y , z ) (x,y,z) ( x , y , z ) (modèle inverse). Nous définissons le repère
R \mathcal{R} R centré sur la première articulation de la patte (repère 0).
Rappel sur les matrices de rotation
En 2D, rotation d'angle θ \theta θ autour de l'origine : r o t ( O , θ ) = ( cos θ − sin θ sin θ cos θ ) rot_{(O,\theta)} = \begin{pmatrix} \cos{\theta} & - \sin{\theta} \\
\sin{\theta} & \cos{\theta} \end{pmatrix} r o t ( O , θ ) = ( cos θ sin θ − sin θ cos θ )
En 3D, rotation d'angle θ \theta θ autour de l'axe ( O , z ) (O,z) ( O , z ) : r o t ( ( O , z ) , θ ) = ( cos ( θ ) − sin ( θ ) 0 sin ( θ ) cos ( θ ) 0 0 0 1 ) rot_{((O,z), \theta)} =
\begin{pmatrix}
\cos(\theta) & -\sin(\theta) & 0 \\
\sin(\theta) & \cos(\theta) & 0 \\
0 & 0 & 1
\end{pmatrix} r o t (( O , z ) , θ ) = cos ( θ ) sin ( θ ) 0 − sin ( θ ) cos ( θ ) 0 0 0 1
Modèle direct
Soit A A A l'origine du repère 1 : A = ( l 0 cos θ 0 l 0 sin θ 0 0 ) R A = \begin{pmatrix}
l_0 \cos{\theta_0} \\ l_0 \sin{\theta_0} \\ 0 \end{pmatrix}_\mathcal{R} A = l 0 cos θ 0 l 0 sin θ 0 0 R .
Soit B B B l'origine du repère 2 : B = ( l 1 cos ( π − θ 1 ) 0 l 1 sin ( π − θ 1 ) ) R 1 B = \begin{pmatrix}
l_1 \cos{(\pi - \theta_1 )} \\ 0 \\ l_1 \sin{(\pi - \theta_1)}\end{pmatrix}_{\mathcal{R}_1} B = l 1 cos ( π − θ 1 ) 0 l 1 sin ( π − θ 1 ) R 1 . On a donc, dans le repère 0 :
B R = r o t ( ( O , z ) , θ 0 ) ⋅ B R 1 + A = ( cos θ 0 − sin θ 0 0 sin θ 0 cos θ 0 0 0 0 1 ) ⋅ ( l 1 cos ( π − θ 1 ) 0 l 1 sin ( π − θ 1 ) ) + ( l 0 cos θ 0 l 0 sin θ 0 0 ) \begin{aligned}
B_{\mathcal{R}} &= rot_{((O,z),\theta_0)} \cdot B_{\mathcal{R}_1} + A \\
&= \begin{pmatrix} \cos{\theta_0} & -\sin{\theta_0} & 0 \\
\sin{\theta_0} & \cos{\theta_0} & 0 \\
0 & 0 & 1 \end{pmatrix} \cdot \begin{pmatrix}
l_1 \cos{(\pi - \theta_1)} \\
0 \\
l_1 \sin{(\pi - \theta_1)}
\end{pmatrix} + \begin{pmatrix} l_0 \cos{\theta_0} \\ l_0 \sin{\theta_0} \\
0 \end{pmatrix}
\end{aligned} B R = r o t (( O , z ) , θ 0 ) ⋅ B R 1 + A = cos θ 0 sin θ 0 0 − sin θ 0 cos θ 0 0 0 0 1 ⋅ l 1 cos ( π − θ 1 ) 0 l 1 sin ( π − θ 1 ) + l 0 cos θ 0 l 0 sin θ 0 0
Soit M M M le point au bout de la patte. Nous pouvons caractériser B M ⃗ = ( l 2 cos ( π − θ 2 ) 0 l 2 sin ( π − θ 2 ) ) R 2 \vec{BM}
= \begin{pmatrix} l_2 \cos{(\pi - \theta_2)} \\ 0 \\ l_2 \sin{(\pi -
\theta_2)} \end{pmatrix}_{\mathcal{R}_2} B M = l 2 cos ( π − θ 2 ) 0 l 2 sin ( π − θ 2 ) R 2 .
Au final, on a ( x , y , z ) = r o t ( ( O , z ) , θ 0 ) ⋅ r o t ( ( O , y ) , π − θ 1 ) ⋅ B M ⃗ R 2 + B R (x,y,z) = rot_{((O,z), \theta_0)} \cdot rot_{((O,y),
\pi-\theta_1)} \cdot \vec{BM}_{\mathcal{R}_2} + B_{\mathcal{R}} ( x , y , z ) = r o t (( O , z ) , θ 0 ) ⋅ r o t (( O , y ) , π − θ 1 ) ⋅ B M R 2 + B R .
Modèle inverse
θ 0 = arctan ( y x ) \theta_0 = \arctan{\left(\dfrac{y}{x}\right)} θ 0 = arctan ( x y )
(en pratique, on utilise atan2 ( y , x ) \operatorname{atan2}(y, x) atan2 ( y , x ) pour obtenir le bon quadrant).
On note d = A M = z 2 + ( x 2 + y 2 − l 0 ) 2 d = AM = \sqrt{z^2 + (\sqrt{x^2+y^2} - l_0)^2} d = A M = z 2 + ( x 2 + y 2 − l 0 ) 2 la distance entre la deuxième articulation A A A et l'extrémité M M M . La loi des cosinus dans le triangle A B M ABM A B M (côtés A B = l 1 AB = l_1 A B = l 1 , B M = l 2 BM = l_2 B M = l 2 , A M = d AM = d A M = d ) donne :
θ 1 = arctan ( − z x 2 + y 2 − l 0 ) − arccos ( l 1 2 − l 2 2 + d 2 2 l 1 d ) + π \theta_1 = \arctan\left(\dfrac{-z}{\sqrt{x^2+y^2}-l_0}\right) - \arccos\left(\dfrac{l_1^2 - l_2^2 + d^2}{2 l_1 d}\right) + \pi θ 1 = arctan ( x 2 + y 2 − l 0 − z ) − arccos ( 2 l 1 d l 1 2 − l 2 2 + d 2 ) + π
θ 2 = 2 π − arccos ( − A M 2 + B M 2 + A B 2 2 × B M × A B ) θ 2 = 2 π − arccos ( − z 2 − ( x 2 + y 2 − l 0 ) 2 + l 2 2 + l 1 2 2 l 1 l 2 ) \begin{aligned}
\theta_2 &= 2 \pi - \arccos{\left(\dfrac{-AM^2+BM^2+AB^2}{2 \times BM \times AB}\right)} \\
\theta_2 &= 2 \pi - \arccos{\left(\dfrac{-z^2-(\sqrt{x^2+y^2} -l_0)^2+l_2^2+l_1^2}{2 l_1 l_2}\right)}
\end{aligned} θ 2 θ 2 = 2 π − arccos ( 2 × B M × A B − A M 2 + B M 2 + A B 2 ) = 2 π − arccos ( 2 l 1 l 2 − z 2 − ( x 2 + y 2 − l 0 ) 2 + l 2 2 + l 1 2 )
Quelques exemples
Ressources