\documentclass[a4paper,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{graphicx} %BIlder einbinden
\usepackage{amsmath} %erweiterte Mathe-Zeichen
\usepackage{amsfonts} %weitere fonts
\usepackage[utf8]{inputenc} %Umlaute & Co
\usepackage{hyperref} %Links
\usepackage{ifthen} %ifthenelse
\usepackage{enumerate}
\usepackage{pdfpages}
\usepackage{algpseudocode} %Pseudocode
\usepackage{dsfont} % schöne Zahlenräumezeichen
\usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen
\usepackage{tikz} %TikZ ist kein Zeichenprogramm
\usetikzlibrary{trees,automata,arrows,shapes}

\pagestyle{empty}


\topmargin-50pt

\newcounter{aufgabe}
\def\tand{&}

\newcommand{\makeTableLine}[2][0]{%
  \setcounter{aufgabe}{1}%
  \whiledo{\value{aufgabe} < #1}%
  {%
    #2\tand\stepcounter{aufgabe}%
  }
}

\newcommand{\aufgTable}[1]{
  \def\spalten{\numexpr #1 + 1 \relax}
  \begin{tabular}{|*{\spalten}{p{1cm}|}}
    \makeTableLine[\spalten]{A\theaufgabe}$\Sigma$~~\\ \hline
    \rule{0pt}{15pt}\makeTableLine[\spalten]{}\\
  \end{tabular}
}

\def\header#1#2#3#4#5#6#7{\pagestyle{empty}
\begin{minipage}[t]{0.47\textwidth}
\begin{flushleft}
{\bf #4}\\
#5
\end{flushleft}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{flushright}
#6 \vspace{0.5cm}\\
%                 Number of Columns    Definition of Columns      second empty line
% \begin{tabular}{|*{5}{C{1cm}|}}\hline A1&A2&A3&A4&$\Sigma$\\\hline&&&&\\\hline\end{tabular}\\\vspace*{0.1cm}
\aufgTable{#7}
\end{flushright}
\end{minipage}
\vspace{1cm}
\begin{center}
{\Large\bf Assignment #1}

{(Hand-in date #3)}
\end{center}
}



%counts the exercisenumber
\newcounter{n}

%Kommando für Aufgaben
%\Aufgabe{AufgTitel}{Punktezahl}
\newcommand{\Aufgabe}[2]{\stepcounter{n}
\textbf{Exercise \arabic{n}: #1} (#2 Punkte)\\}




\begin{document}
    %\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
    \header{1}{}{2015-05-05}{Mobile Robots}{
    	\textit{Jan-Peter Hohloch}\\ \textit{Maximus Mutschler}
    }{SS 15}{4}
    \vspace{1cm}

    \Aufgabe{}{6}
        \begin{enumerate}[(a)]
            \item Forward kinematic velocity: calculation of the robots' current pose with knowledge about the velocity and position of the last pose  \\
            inverse kinematic velocity: given a pose the velocity and position needed to reach this pose are calulated
            \item $^R\mathbf{v}=\begin{pmatrix}
                    0.2\frac{m}{s} \\ 1 \frac{1}{s}
                \end{pmatrix}$, $l=0.2m$\\
                \begin{align}
                    v_l &= \frac{2\cdot 0.2-0.2}{2}&=0.1\\
                    v_r &= \frac{2\cdot 0.2+0.2}{2}&=0.3
                \end{align}
                $\Rightarrow \mathbf{u}_t=\left(0.1\frac{m}{s}, 0.3\frac{m}{s}\right)^T$
            \item \begin{align}
                    v &= \frac{0.3+0.5}{2}\frac{m}{s} &=0.4\frac{m}{s}\\
                    \omega &= \frac{0.5-0.3}{0.2}\frac{1}{s}&=1\frac{1}{s}
                \end{align}
                    $\Rightarrow \mathbf{v}_t=\left(0.4\frac{m}{s},1\frac{1}{s}\right)$
            \item \begin{align}
                    \frac{1}{2}v_r+\frac{1}{2}v_l &=v\\
                    \frac{1}{l}v_r -\frac{1}{l}v_l &=\omega
                \end{align}$\Leftrightarrow$\begin{align}
                    v_r+v_l &= 2v\\
                    v_r-v_l &=l\omega\\
                \end{align}
                $\Rightarrow 2v_r =2v+l\omega\Leftrightarrow v_r=\frac{2v+l\omega}{2}$\\
                $\Rightarrow \frac{2v+l\omega}{2}+v_l =2v \Leftrightarrow v_l=2v-\frac{2v+l\omega}{2}=\frac{2v-l\omega}{2}$\qed
        \end{enumerate}
     \Aufgabe{}{8}
        \begin{enumerate}[(a)]
            \item $s_l=s_r=s,\ \theta_{t-1}=\theta_t=\theta$\\
                $\mathbf{x}_t=\mathbf{x}_{t-1}+\mathbf{Rot}(z,\theta)\begin{pmatrix}
                    s\\0\\0
                \end{pmatrix}=\mathbf{x}_{t-1}+\begin{pmatrix}
                    \cos\theta & -\sin\theta & 0\\
                    \sin\theta & \cos\theta & 0\\
                    0&0&1
                \end{pmatrix}\begin{pmatrix}
                    s\\0\\0
                \end{pmatrix}=\mathbf{x}_{t-1}+\begin{pmatrix}
                    s\cos\theta\\s\sin\theta\\0
                \end{pmatrix}$
            \item $r\left(\begin{pmatrix}
                2l\\l
            \end{pmatrix}\right)=-\frac{3}{2} l$\\
            $\frac{\partial r}{\partial s_r}=\frac{(s_l+s_r)'(s_r-s_l)-(s_l+s_r)(s_r-s_l)'}{(s_r-s_l)^2}\cdot\frac{l}{2}=\frac{-2s_l}{(s_r-s_l)^2}\cdot\frac{l}{2}\overset{s=\overline{s}}{=}\frac{-4}{l}\cdot\frac{l}{2}=-2$\\
            $\frac{\partial r}{\partial s_l}=\frac{(s_l+s_r)'(s_r-s_l)-(s_l+s_r)(s_r-s_l)'}{(s_r-s_l)^2}\cdot\frac{l}{2}=\frac{2s_r}{(s_r-s_l)^2}\cdot\frac{l}{2}\overset{s=\overline{s}}{=}\frac{2}{l}\cdot\frac{l}{2}=1$\\
            $\Rightarrow r(\mathbf{s})\approx -\frac{3}{2}l-2\left(s_r-l\right)+\left(s_l-2l\right)=-\frac{3}{2}l-2s_r+s_l$
        \end{enumerate}
     \Aufgabe{}{6}
        \begin{enumerate}[(a)]
            \item $\mathbf{x}_1=\begin{pmatrix}
                    p_x\\p_y\\\Delta\theta
                \end{pmatrix}=\begin{pmatrix}
                    r\sin(\Delta\theta)\\
                    -r\cos(\Delta\theta)+r\\
                    \Delta\theta
                \end{pmatrix}$, $\Delta\theta=\sin^{-1}\left(\frac{p_x}{r}\right)$\\
                $p_y=-r\cos\sin^{-1}\left(\frac{p_x}{r}\right)+r=-r\sqrt{1-\frac{p_x^2}{r^2}}+r=-\sqrt{r^2-p_x^2}+r$\\
                $(r-p_y)^2=r^2-p_x^2 \Leftrightarrow r^2-2p_yr+p_y^2=r^2-p_x^2 \Leftrightarrow r=\frac{p_x^2+p_y^2}{2p_y}$
            \item $\Delta\theta=\sin^{-1}\left(\frac{p_x}{r}\right)=\sin^{-1}\left(p_x\cdot \frac{2p_y}{p_x^2+p_y^2}\right)=\sin^{-1}\left(\frac{2p_xp_y}{p_x^2+p_y^2}\right)$
            \item $s_l=\left(r-\frac{l}{2}\right)\Delta\theta=\left(\frac{p_x^2+p_y^2}{2p_y}-\frac{l}{2}\right)\sin^{-1}\left(\frac{2p_xp_y}{p_x^2+p_y^2}\right)=\frac{p_x^2+p_y^2-lp_y}{2p_y}\sin^{-1}\left(\frac{2p_xp_y}{p_x^2+p_y^2}\right)$\\
            $s_r=\left(r+\frac{l}{2}\right)\Delta\theta=\frac{p_x^2+p_y^2+lp_y}{2p_y}\sin^{-1}\left(\frac{2p_xp_y}{p_x^2+p_y^2}\right)$
            \item $r=\frac{p_x^2+p_y^2}{2p_y}=\frac{16+4}{4}m=5m$\\
                $\Delta\theta=\sin^{-1}\left(\frac{p_x}{r}\right)=\sin^{-1}\left(\frac{4}{5}\right)\approx 0.927$\\
                $s_l=\left(r-\frac{l}{2}\right)\Delta\theta=\left(5m-\frac{1}{2}m\right)\sin^{-1}\left(\frac{4}{5}\right)=4.5m\cdot \sin^{-1}\left(\frac{4}{5}\right)\approx 4.173$\\
                $s_l=\left(r+\frac{l}{2}\right)\Delta\theta=\left(5m+\frac{1}{2}m\right)\sin^{-1}\left(\frac{4}{5}\right)=5.5m\cdot \sin^{-1}\left(\frac{4}{5}\right)\approx 5.100$\\
        \end{enumerate}

\end{document}

