I am currently studying flatness based control using the book: Sira-Ramirez, Hebertt, and Sunil K. Agrawal. Differentially flat systems. CRC Press, 2004.
I have two questions on a particular example from this book.
1.)
They study an example there, a flexible joint manipulator with the following equations:
$$ \begin{split} \dot{x}_1 &= x_2 \\ \dot{x}_2 &= -\frac{m g L}{I}\sin(x_1) - \frac{k}{I}(x_1 - x_3) \\ \dot{x}_3 &= x_4 \\ \dot{x}_4 &= \frac{k}{J}(x_1 - x_3) + \frac{1}{J}u \end{split} $$
with the flat output $y = x_1$. This is shown by expressing the state variables using this flat output and its derivatives as follows:
$$ \begin{split} x_1 &= y \\ x_2 &= \dot{y} \\ x_3 &= \frac{I}{k}\Big(\ddot{y} + \frac{m g L}{I}\sin(y)\Big) + y \\ x_4 &= \frac{I}{k}\Big(y^{(3)} + \frac{m g L}{I}\dot{y}\Big) + \dot{y} \,. \end{split} $$
Now I understand the first three expressions $x_1, x_2$ and $x_3$. However, I don't get how they derive $x_4$ here or more specifically, why the $\sin$ term disapears in $x_4$. Since to get $x_4$ you would have to take the time derivative of $x_3$, wouldn't the correct solution be
$$ x_4 = \frac{I}{k}\Big(y^{(3)} + \frac{m g L}{I}\cos(y)\dot{y}\Big) + \dot{y} $$
or do I miss something here?
2.)
The input $u$ is derived in the book as
$$ u = J\Big[\Big(y^{(4)} + \frac{m g L}{I}(\ddot{y}\cos(y) - \dot{y}^2\sin(y))\Big) + \ddot{y}\Big] + k I \Big( \ddot{y} + \frac{m g L}{I}\sin(y) \Big) \,. $$
How can I use this input now if I construct for example a Simulink model of this system? I would just feedback $y = x_1$ and feed that through 3 derivatives blocks to compute $\dot{y}, \ddot{y}$ and $y^{(3)}$ (to use them in $u$) and define $v = y^{(4)}$ as new input... is that correct? How to proceed from there?
Apparently, there is a typo in the book. The expression for $x_4$ must contain a $\cos y$ and you can easily see it if you look at the expression for $u$. It contains $(\ddot{y}\cos y - \dot{y}^2 \sin y)$ which clearly comes from differentiating $\dot{y}\cos y$.
As far as I know, the standard approach in flatness-based control is to define a sufficiently smooth (desired) trajectory $y(t)$ s.t. $y(0)=y_0$, $y(1)=y_1$ and some other constraints hold. Differentiating $y(t)$ with respect to $t$ you get all required derivatives which are then substituted into $u$.