%
% Manipulator.tex
%

\documentclass{beamer}

\usepackage{beamerthemeshadow}
\usepackage{listings}
\usepackage{graphics}
\usepackage{times}
\usepackage{algorithm2e}

\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
% \usepackage{amsmath,amssymb} \usepackage[latin1]{inputenc}
% \usepackage{colortbl}
\usepackage[english]{babel}

\newcommand{\erlang}{
\lstset{language=Prolog, basicstyle=\ttfamily\footnotesize,frame=trBL,
  frameround=fttt}}

\newcommand{\erlangsmall}{
\lstset{language=Prolog, basicstyle=\ttfamily\scriptsize,frame=trBL,
  frameround=fttt}}

\newcommand{\clang}{
\lstset{language=Prolog, basicstyle=\ttfamily\footnotesize,frame=trBL,
  frameround=fttt}}

\newcommand{\clangsmall}{
\lstset{language=Prolog, basicstyle=\ttfamily\scriptsize,frame=trBL,
  frameround=fttt}}

\newcommand{\clangtiny}{
\lstset{language=Prolog, basicstyle=\ttfamily\tiny,frame=trBL,
  frameround=fttt}}

\erlang

\newcommand\blue{\color[rgb]{0,0,1}}
\newcommand\green{\color[rgb]{0,0.5,0}}
\newcommand\red{\color[rgb]{1,0,0}}
\newcommand\black{\color[rgb]{0,0,0}}

\newcommand\tape[9]{
\framebox{#1}
\framebox{#2}
\framebox{#3}
\framebox{#4}
\framebox{#5}
\framebox{#6}
\framebox{#7}
\framebox{#8}
\framebox{#9}}

\newcommand\two[2]{
\framebox{#1}
\framebox{#2}}

\newcommand\six[6]{
\framebox{#1}
\framebox{#2}
\framebox{#3}
\framebox{#4}
\framebox{#5}
\framebox{#6}}

\newcommand\three[3]{
\framebox{#1}
\framebox{#2}
\framebox{#3}}

\title[Cinematica dei Manipolatori]{Cinematica diretta e inversa\\
di un manipolatore}
%%

\author[Corrado Santoro]
       {Corrado Santoro}

\date{ }

\institute[University of Catania]
  {
    \begin{center}
      \textbf{\red{}ARSLAB - Autonomous and Robotic Systems Laboratory}\\
      Dipartimento di Matematica e Informatica - Universit\`{a} di Catania, Italy\\
      \texttt{santoro@dmi.unict.it}\\
      \includegraphics[width=60pt]{robotEscher_Eura_blur.eps}\\%%~~~~\includegraphics[width=80pt]{logo_dmi.png}
      Programmazione Sistemi Robotici\\
    \end{center}
  }



\begin{document}


%%
\frame{\titlepage}
%%


%%
\begin{frame}[fragile]
%%
  \frametitle{Manipolatore Robotico}
%%
%%
\begin{itemize}
\item\footnotesize{}Un \textbf{\red{}manipolatore}  \`{e} un sistema
  robotico costituito da un insieme di \textbf{bracci} connessi da
  opportuni \textbf{\red{}giunti di movimento}
\item Un manipolatore \`{e} detto:
  \begin{itemize}
  \item\footnotesize{}\textbf{\red{}seriale} (foto a sinistra) se i giunti sono
    connessi in cascata (e quindi dipendono l'uno dall'altro in serie)
  \item\textbf{\red{}parallelo} (foto al centro) se i giunti sono
    indipendenti
\end{itemize}
\item Ad un manipolatore \`{e} in genere collegato un
  \textbf{\red{}end-effector} (foto a destra), cio\`{e} l'\textbf{utensile}
  necessario per
  effettuare il tipo specifico di manipolazione (pinza, fresa, spruzzatore,
  ventosa, etc.)
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.3]{kuka.eps}~~~~\includegraphics[scale=0.3]{manipolatore_parallelo.eps}%%
~~~~\includegraphics[scale=0.3]{end-effector.eps}
\end{center}
%%
\end{frame}




%%
\begin{frame}[fragile]
%%
  \frametitle{Spazio e Sistemi di Riferimento}
%%
%%
\begin{itemize}
\item\footnotesize{}Ogni manipolatore robotico presenta \textbf{\red{}tre}
  sistemi di riferimento:
  \begin{itemize}
  \item\footnotesize{}il sistema \textbf{\red{}solidale con la base}
    ({\red{}base frame}), di tipo \textbf{cartesiano}
  \item il sistema \textbf{\red{}solidale con l'end-effector} ({\red{}tool
    frame}), di tipo
    \textbf{cartesiano}
  \item il sistema delle \textbf{\red{}variabili di giunto}, non
    cartesiano; esse rappresentano la \textbf{posizione di ogni giunto} del
    manipolatore; nel caso in figura, le variabili di giunto sono gli
    \textbf{\red{}angoli 1, 2, 3 e 4} che ogni braccio forma con il successivo
\end{itemize}
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.5]{manipulator_frame.eps}
\end{center}
%%
\end{frame}






%%
\begin{frame}[fragile]
%%
  \frametitle{Spazio e Sistemi di Riferimento}
%%
%%
\begin{itemize}
\item\footnotesize{}Lo \textbf{spazio di giunto} \`{e} quello che noi
  possiamo controllare (possiamo impostare le posizioni degli angoli di
  ogni giunto)
\item Lo \textbf{spazio della base} (base frame) \`{e} invece
  il sistema di riferimento di ``lavoro'' del manipolatore
\item Il controllo di un manipolatore implica dunque trovare i valori delle
  \textbf{variabili di giunto} che permettono all'end-effector di
  raggiungere una posizione specificata nel \textbf{base frame}
\item In altre parole, dette:
  \begin{itemize}
  \item\footnotesize{}$\{q_1, q_2, \dots, q_n\}$ le variabili di giunto
  \item e $\{x,y,z,\theta,\phi,\psi\}$ la \textbf{posa} del manipolatore, in termini
    di posizione $\{x,y,z\}$ dell'end-effector nel base frame e rotazione
    $\{\theta,\phi,\psi\}$ rispetto al base frame
  \end{itemize}
\item il problema \`{e} trovare la trasformazione $T()$
\[
\{q_1, q_2, \dots, q_n\} = T(x,y,z,\theta,\phi,\psi)
\]
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.2]{manipulator_frame.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Esempio in 2D}
%%
\begin{itemize}
\item\footnotesize{}Il manipolatore in figura \`{e} detto \textbf{\red{}manipolatore
  planare}, perch\`{e} il suo base frame \`{e} in due dimensioni (un piano)
\item L'esempio mostra \textbf{tre giunti}, \textbf{due bracci} e un
  \textbf{end-effector}
\item La \textbf{posa} dell'end-effector $\red{}\{X_t,Y_t, \alpha\}$ \`{e}
  rappresentata dalla
  posizione $\red{}\{X_t,Y_t\}$ del suo giunto e dall'angolo $\red{}\alpha$
  formato con l'asse $x$
\item Le \textbf{variabili di giunto} sono gli \textbf{angoli} che ogni
  braccio forma con il successivo $\red{}\{\theta_1, \theta_2, \theta_3\}$
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.2]{manipolatore_2d.eps}
\end{center}
%%
\end{frame}




%%
\begin{frame}[fragile]
%%
  \frametitle{Problema Cinematico Diretto e Inverso}
%%
\begin{itemize}
\item\footnotesize{}\textbf{\red{}Cinematica Diretta}: data la posizione
  nello spazio dei giunti
 $\{\theta_1, \theta_2, \theta_3\}$, trovare la trasformazione $T_D$
  tale che:
\[
\red\{X_t,Y_t,\alpha\} = T_D(\theta_1, \theta_2, \theta_3)
\]
\item\textbf{\red{}Cinematica Inversa}: data la posa nel base frame
$\{X_t,Y_t,\alpha\}$, trovare la trasformazione $T_I$
  tale che:
\[
\red\{\theta_1, \theta_2, \theta_3\} = T_I(X_t,Y_t,\alpha)
\]
%%
\item Entrambi i problemi si affrontano applicando le formule delle
  \textbf{roto-traslazioni}
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.2]{manipolatore_2d.eps}
\end{center}
%%
\end{frame}




%%
\begin{frame}[fragile]
%%
  \frametitle{Roto-traslazioni in 2D}
%%
\begin{itemize}
\item\footnotesize{}Siano dati il sistema di riferimento $XOY$ e il sistema
  di riferimento $X'O'Y'$ \textbf{traslato} (rispetto a $XOY$) sul
  punto $\red{}(X_0,Y_0)$ e \textbf{ruotato} (rispetto a $XOY$) di un
  angolo $\red{}\alpha$
%%
\item Dato un punto $\red{}(x',y')$ definito in $X'O'Y'$, le sue coordinate in
  $XOY$ saranno date da:
{\red{}%%
\begin{eqnarray*}
x & = & X_0 + x'\cos\alpha - y'\sin\alpha\\
y & = & Y_0 + x'\sin\alpha + y'\cos\alpha
\end{eqnarray*}}
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.2]{rototrasl.eps}
\end{center}
%%
\end{frame}





%%
\begin{frame}[fragile]
%%
  \frametitle{Roto-traslazioni in 2D}
%%
\begin{itemize}
\item\footnotesize{}Siano dati il sistema di riferimento $XOY$ e il sistema
  di riferimento $X'O'Y'$ \textbf{traslato} (rispetto a $XOY$) sul
  punto $\red{}(X_0,Y_0)$ e \textbf{ruotato} (rispetto a $XOY$) di un
  angolo $\red{}\alpha$
%%
\item Se adottiamo un sistema di \textbf{\red{}coordinate omogenee}, la
  trasformazione pu\`{o} essere rappresentata dalla seguente equazione matriciale:
{\red{}%%
\begin{eqnarray*}
\begin{bmatrix}
x \\ y \\ 1
\end{bmatrix}
& = &
\begin{bmatrix}
\cos\alpha & - \sin\alpha & X_0\\
\sin\alpha & \cos\alpha & Y_0\\
0 & 0 & 1
\end{bmatrix}
%%
\begin{bmatrix}
x' \\ y' \\ 1
\end{bmatrix}
\end{eqnarray*}}
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.2]{rototrasl.eps}
\end{center}
%%
\end{frame}



%%
\begin{frame}[fragile]
%%
  \frametitle{Roto-traslazioni in 2D}
%%
\begin{itemize}
\item\footnotesize{}La matrice:
{\red{}
\begin{eqnarray*}%%
\begin{bmatrix}
\cos\alpha & - \sin\alpha & X_0\\
\sin\alpha & \cos\alpha & Y_0\\
0 & 0 & 1
\end{bmatrix}
& = &
\begin{bmatrix}
R & ~ & T\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\item \`{e} la \textbf{\red{}matrice di rototraslazione} composta
\item dalla \textbf{matrice di rotazione}:
\[R=
\begin{bmatrix}
\cos\alpha & - \sin\alpha\\
\sin\alpha & \cos\alpha
\end{bmatrix}
\]
%%
\item e dal \textbf{vettore di traslazione}:
\[T=
\begin{bmatrix}
X_0\\Y_0
\end{bmatrix}
\]
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.15]{rototrasl.eps}
\end{center}
%%
\end{frame}

%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta del Manipolatore}
%%
\begin{itemize}
\item\footnotesize{}Ogni \textbf{giunto} implica una
  \textbf{\red{}rototraslazione} dove:
  \begin{itemize}
  \item La \textbf{rotazione} si basa sulle caratteristiche cinetiche del
    giunto
  \item La \textbf{traslazione} \`{e} data dalla lunghezza del braccio
  \end{itemize}
\item Ogni giunto $\red{}i$ definisce una matrice di rototralsazione
  $\red{}^{i-1}_{i}A$ che permette il passaggio dal sistema di riferimento $\red{}i-1$
  al sistema di riferimento $\red{}i$
\item La matrice $\red{}^b_tA$ che permette il passaggio dal base frame al tool frame
  \`{e} dunque data dal \textbf{prodotto} delle varie matrici di giunto
\[\red{}%%
^b_tA = ~ ^b_1A ~ ^1_2A ~ ^2_3A \dots ^{i-1}_tA
\]
\end{itemize}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Consideriamo il manipolatore planare in figura, costituito da
\textbf{\red{}tre giunti} di rotazione
\item Il passaggio da base frame a sistema $(x_1,y_1)$ \`{e} basato su una
  semplice rotazione
\end{itemize}
%%
{\red{}%%
\begin{eqnarray*}
^b_1A & = &
\begin{bmatrix}
\cos\theta_1 & - \sin\theta_1 & 0\\
\sin\theta_1 & \cos\theta_1 & 0\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}



%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Il passaggio da sistema $(x_1, y_1)$ a sistema $(x_2,y_2)$
  \`{e} basato su una rotazione $\theta_2$ e una traslazione $L_1$ lungo
  l'asse $x_1$, dove $L_1$ \`{e} la lunghezza del primo braccio:
\end{itemize}
%%
{\red{}%%
\begin{eqnarray*}
^1_2A & = &
\begin{bmatrix}
\cos\theta_2 & - \sin\theta_2 & L_1\\
\sin\theta_2 & \cos\theta_2 & 0\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Il passaggio da sistema $(x_2, y_2)$ a sistema
  $(x_3,y_3)$ (tool frame)
  \`{e} basato su una rotazione $\theta_3$ e una traslazione $L_2$ lungo
  l'asse $x_2$, dove $L_2$ \`{e} la lunghezza del secondo braccio:
\end{itemize}
%%
{\red{}%%
\begin{eqnarray*}
^2_tA & = &
\begin{bmatrix}
\cos\theta_3 & - \sin\theta_3 & L_2\\
\sin\theta_3 & \cos\theta_3 & 0\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}La trasformazione completa si esprime con il prodotto
  delle tre matrici:
\end{itemize}
%%
{\red{}\scriptsize%%
\begin{eqnarray*}
^b_1A ~ ^1_2A ~ ^2_tA & = &
\begin{bmatrix}
\cos(\theta_1 + \theta_2 + \theta_3) & - \sin(\theta_1 + \theta_2 +
\theta_3) &
L_1\cos\theta_1 + L_2\cos(\theta_1+\theta_2)\\
\sin(\theta_1 + \theta_2 + \theta_3) & \cos(\theta_1 + \theta_2 + \theta_3)
&
L_1\sin\theta_1 + L_2\sin(\theta_1+\theta_2)\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Se tuttavia consideriamo la \textbf{trasformazione
  diretta} da sistema $(x,y)$ a $(x_3,y_3)$, avremo:
\end{itemize}
%%
{\red{}%%
\begin{eqnarray*}
^b_tA & = &
\begin{bmatrix}
\cos\alpha & - \sin\alpha & X_t\\
\sin\alpha & \cos\alpha & Y_t\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}A questo punto abbiamo le due rappresentazioni:
%%
{\red{}\scriptsize%%
\begin{eqnarray*}
^b_1A ~ ^1_2A ~ ^2_tA & = &
\begin{bmatrix}
\cos(\theta_1 + \theta_2 + \theta_3) & - \sin(\theta_1 + \theta_2 +
\theta_3) &
L_1\cos\theta_1 + L_2\cos(\theta_1+\theta_2)\\
\sin(\theta_1 + \theta_2 + \theta_3) & \cos(\theta_1 + \theta_2 + \theta_3)
&
L_1\sin\theta_1 + L_2\sin(\theta_1+\theta_2)\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
\\
{\red{}\scriptsize%%
\begin{eqnarray*}
^b_tA & = &
\begin{bmatrix}
\cos\alpha & - \sin\alpha & X_t\\
\sin\alpha & \cos\alpha & Y_t\\
0 & 0 & 1
\end{bmatrix}
\end{eqnarray*}}
%%
\item Dalle quali ricaviamo le equazioni \textbf{finali} della cinematica
  diretta ....
%%
\end{itemize}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Diretta di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Equazioni finali:
\end{itemize}
%%
{\red{}%%
\begin{eqnarray*}
X_t & = & L_1\cos\theta_1 + L_2\cos(\theta_1+\theta_2)\\
Y_t & = & L_1\sin\theta_1 + L_2\sin(\theta_1+\theta_2)\\
\alpha & = & \theta_1 + \theta_2 + \theta_3
\end{eqnarray*}}
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_sistemi_riferimento.eps}
\end{center}
%%
\end{frame}



%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}La \textbf{\red{}cinematica inversa} implica
  l'inversione delle equazioni:
%%
{\red{}%%
\begin{eqnarray*}
X_t & = & L_1\cos\theta_1 + L_2\cos(\theta_1+\theta_2)\\
Y_t & = & L_1\sin\theta_1 + L_2\sin(\theta_1+\theta_2)\\
\alpha & = & \theta_1 + \theta_2 + \theta_3
\end{eqnarray*}}
%%
\item al fine di determinare $\theta_1$, $\theta_2$ e $\theta_3$ a partire
  da $X_t$, $Y_t$ e $\alpha$
%%
\item Per brevit\`{a} poniamo\\
$c_1 = \cos\theta_1$, $s_1 = \sin\theta_1$,
  $c_{12} = \cos(\theta_1+\theta_2)$, $s_{12} = \sin(\theta_1+\theta_2)$
%%
\end{itemize}
%%
\end{frame}



%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Abbiamo:
%%
{\red{}%%
\begin{eqnarray*}
X_t & = & L_1c_1 + L_2c_{12}\\
Y_t & = & L_1s_1 + L_2s_{12}\\
\alpha & = & \theta_1 + \theta_2 + \theta_3
\end{eqnarray*}}
%%
\item Eleviamo al quadrato le prime due equazioni:
{\red{}%%
\begin{eqnarray*}
X_t^2 & = & L_1^2c_1^2 + L_2^2c_{12}^2 + 2 L_1L_2c_1c_{12}\\
Y_t^2 & = & L_1^2s_1^2 + L_2^2s_{12}^2 + 2 L_1L_2s_1s_{12}
\end{eqnarray*}}
%%
\item Sommiamo membro a membro:
{\red{}%%
\begin{eqnarray*}
X_t^2 + Y_t^2 & = &
L_1^2c_1^2 + L_2^2c_{12}^2 + 2 L_1L_2c_1c_{12} + L_1^2s_1^2 + L_2^2s_{12}^2 + 2 L_1L_2s_1s_{12}
\end{eqnarray*}}
%%
\item poich\`{e}:
{\red{}%%
\begin{eqnarray*}
c_1^2 + s_1^2 & = & 1\\
c_{12}^2 + s_{12}^2 & = & 1
\end{eqnarray*}}
%%
\end{itemize}
%%
\end{frame}


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Otteniamo:
%%
{\red{}%%
\begin{eqnarray*}
X_t^2 + Y_t^2 & = &
L_1^2 + L_2^2 + 2 L_1L_2c_1c_{12} + 2 L_1L_2s_1s_{12}
\end{eqnarray*}}
%%
\item Applichiamo le formule di somma:
%%
{\red{}%%
\begin{eqnarray*}
c_{12} & = & \cos\theta_1\cos\theta_2 - \sin\theta_1\sin\theta_2 = c_1c_2 - s_1s_2\\
s_{12} & = & \sin\theta_1\cos\theta_2 + \cos\theta_1\sin\theta_2 = s_1c_2 + c_1s_2
\end{eqnarray*}}
%%
\item\footnotesize{}Otteniamo:
%%
{\red{}%%
\begin{eqnarray*}
X_t^2 + Y_t^2 & = &
L_1^2 + L_2^2 + 2 L_1L_2c_1(c_1c_2 - s_1s_2) + 2 L_1L_2s_1(s_1c_2 + c_1s_2)\\
X_t^2 + Y_t^2 & = &
L_1^2 + L_2^2 + 2 L_1L_2c_1^2c_2 - 2 L_1L_2c_1s_1s_2 + 2 L_1L_2s_1^2c_2 +\\
& & + 2 L_1L_2s_1c_1s_2\\
X_t^2 + Y_t^2 & = & L_1^2 + L_2^2 + 2 L_1L_2c_1^2c_2 + 2 L_1L_2s_1^2c_2\\
X_t^2 + Y_t^2 & = & L_1^2 + L_2^2 + 2 L_1L_2(c_1^2 + s_1^2) c_2\\
X_t^2 + Y_t^2 & = & L_1^2 + L_2^2 + 2 L_1L_2c_2
\end{eqnarray*}}
%%
\end{itemize}
%%
\end{frame}
%%


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}abbiamo:
{\red{}%%
\begin{eqnarray*}
X_t^2 + Y_t^2 & = & L_1^2 + L_2^2 + 2 L_1L_2c_2
\end{eqnarray*}}
%%
\item Risolvendo rispetto a $c_2$:
\[\red{}
\cos\theta_2 = \frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}
\]
\item E poich\`{e}:
\[\red{}%%
\sin\theta_2 = \pm\sqrt{1 - \cos^2\theta_2}
\]
%%
\item otteniamo:
\[\red{}%%
\theta_2 = atan2\left(
\pm\sqrt{1 - \left(\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)^2},
\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)
\]\\
dove $atan2(a,b) = \arctan\frac{a}{b}$ calcolata sui quattro
quadranti.
%%
\end{itemize}
\end{frame}
%%

%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}La soluzione:
\[\red{}%%
\theta_2 = atan2\left(
\pm\sqrt{1 - \left(\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)^2},
\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)
\]\\
implica due possibili soluzioni per l'angolo $\theta_2$
\item In effetti, come si nota dalla figura, la \textbf{stessa posa}
  pu\`{o} essere ottenuta tramite \textbf{\red{}due possibili
    configurazioni} degli angoli $\theta_1, \theta_2, \theta_3$
%%
\end{itemize}
\begin{center}
\includegraphics[scale=0.3]{manipolatore_soluzioni.eps}
\end{center}
\end{frame}
%%


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Per calcolare $\red{}\theta_1$ consideriamo:
%%
{\red{}%%
\begin{eqnarray*}
X_t & = & L_1c_1 + L_2c_{12}\\
Y_t & = & L_1s_1 + L_2s_{12}
\end{eqnarray*}}
%%
\item Applichiamo le formule di somma:
{\red{}%%
\begin{eqnarray*}
X_t & = & L_1c_1 + L_2(c_1c_2 - s_1s_2)\\
Y_t & = & L_1s_1 + L_2(s_1c_2 + s_2c_1)\\
& & \\
X_t & = & L_1c_1 + L_2c_1c_2 - L_2s_1s_2\\
Y_t & = & L_1s_1 + L_2s_1c_2 + L_2s_2c_1\\
& & \\
X_t & = & (L_1 + L_2c_2)c_1 - (L_2s_2)s_1\\
Y_t & = & (L_1 + L_2c_2)s_1 + (L_2s_2)c_1
\end{eqnarray*}}
%%
%%
\end{itemize}
%%
\end{frame}



%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{}Notiamo che le relazioni ottenute:
%%
{\red{}%%
\begin{eqnarray*}
X_t & = & (L_1 + L_2c_2)c_1 - (L_2s_2)s_1\\
Y_t & = & (L_1 + L_2c_2)s_1 + (L_2s_2)c_1
\end{eqnarray*}}
%%
rappresentano una \textbf{\red{}rotazione del punto di coordinate $(L_1 +L_2c_2, L_2s_2)$}
 di un angolo $\red\theta_1$;
%%
\item posto $\red{}X^* = L_1 +L_2c_2, Y^* = L_2s_2$, otteniamo:
{\red{}%%
\begin{eqnarray*}
X_t & = & X^*c_1 - Y^*s_1\\
Y_t & = & X^*s_1 + Y^*c_1
\end{eqnarray*}}
%%
\end{itemize}
%%
\end{frame}
%%


%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{} per determinare $\red{}\theta_1$, rappresentiamo graficamente il
  modello delle equazioni:
{\red{}%%
\begin{eqnarray*}
X_t & = & X^*c_1 - Y^*s_1\\
Y_t & = & X^*s_1 + Y^*c_1
\end{eqnarray*}}
%%
\end{itemize}
\begin{center}
\includegraphics[scale=0.3]{rotazione.eps}
\end{center}
%%
\begin{itemize}
\item\footnotesize{}abbiamo:
{\red{}%%
\begin{eqnarray*}
\beta = atan2(Y^*,X^*) & \gamma = atan2(Y_t,X_t) & \theta_1 = \gamma - \beta
\end{eqnarray*}}
\end{itemize}
%%
%%
\end{frame}
%%

%%
\begin{frame}[fragile]
%%
  \frametitle{Cinematica Inversa di un Manipolatore Planare}
%%
\begin{itemize}
\item\footnotesize{} Otteniamo pertanto le soluzioni finali:
{\red{}%%
\begin{eqnarray*}
\theta_2 & = & atan2\left(
\pm\sqrt{1 - \left(\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)^2},
\frac{X_t^2 + Y_t^2 - L_1^2 - L_2^2}{2 L_1L_2}\right)\\
%%
 \theta_1 &  =  & atan2(Y_t,X_t) - atan2(L_2\sin\theta_2, L_1
 +L_2\cos\theta_2)\\
%%
\theta_3 & = & \alpha - \theta_1 - \theta_2
%%
\end{eqnarray*}}
%%
\end{itemize}
%%
%%
\begin{center}
\includegraphics[scale=0.25]{manipolatore_2d.eps}
\end{center}
%%
%%
\end{frame}
%%



%%
\frame{\titlepage}
%%



%%
%%
\end{document}
%%
%%

