\chapter{SimMechanics Simulator}\label{chapter:simm}
\thispagestyle{myheadings}
% -------------------------------------------------------------
% intro
% -------------------------------------------------------------
The PHUA robot full body model simulator and results are presented in this chapter. This simulator is a MATLAB SimMechanics construction, built according to the actual robot mechanical and dimensional specifications, designed to assess the robot's hybrid actuation system and, if possible, study its behaviour. The model expects the joint course data input (position, velocity, acceleration and time vectors) and returns the calculated joint torques developed for the movement. It is also equipped to track the robot's center-of-gravity position, velocity and acceleration. To study the model and simulator's capabilities, a simple movement from a step climbing locomotion pattern is simulated, and its fundamental mathematical expressions are presented. The complete SimMechanics model is presented at Appendix \ref{appendix_simmech_model}, for future reference.
% -------------------------------------------------------------
% simmechanics
% -------------------------------------------------------------
\section{SimMechanics Short Overview}\label{sec:simul_overview}
MATLAB SimMechanics is a multibody simulation environment for mechanical systems, included within the Simscape suite. The multibody systems are modelled using blocks (representing bodies), joints, constraints, and force elements, whose equations of motion (for the complete mechanical system) are then formulated and solved.

All geometrical information, including masses, inertial properties, joints configurations, constraints, and three-dimensional geometry can be imported into the model bodies, or can also be given through CAD model importing. During (and after) calculations, a 3D animation allows the visualization of the resulting system dynamics.

The model's parametrizations can be done using regular MATLAB variables and expressions. SimMechanics allows to use other toolkit as complementary systems, as control systems from Simulink or electrical, hydraulic, or pneumatic systems from Simscape, and test them altogether in a single simulation environment.

One of the main key features of this MATLAB toolkit are its simulation modes for analysing motion and calculating forces/torques in a dynamical environment. This dynamical analysis allows to study certain intrinsic properties and behaviour of the mechanical constructions that would be strenuous to handle otherwise.

The SimMechanics model construction is very similar to the standard Simulink block-based approach, but is based on defining three-dimensional bodies and their respective mechanical connections. In this case, the robot bodies are all connected \textit{via} rotational joints, actuated in position, velocity and acceleration, while the robot connection to the ground is rigid, through the tip of the robot's support leg foot. Joint actuation is made through an actuator block, and the required joint information is retrieved through a joint sensor block. An example of these constructions is given in Figure \ref{fig:simul_construct_examples}. The hybrid actuation system is installed on the knee and ankle joint systems using spring and damper blocks. The models can also account for a gravity acceleration vector, defined with an environment block.

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth]{Imagens/simmech_example_1}
\caption[SimMechanics body to body construction example.]{SimMechanics body to body construction example. joint blocks can be of rotational or prismatic joint types, allow for multiple DOF and different types combinations.}
\label{fig:simul_construct_examples}
\end{figure}
% -------------------------------------------------------------
% model
% -------------------------------------------------------------
\section{Model Construction}\label{sec:simul_model_construct}
The SimMechanics toolkit had already been approached in past works, but only for the purpose of  studying the elastic elements on the knee. Thus, in order to build all the bodies that compose the robot, the geometrical information, such as physical dimensions (lengths, centres of gravity), masses, and  inertial matrices were taken from the robot CAD model, shown in Figure \ref{fig:simul_construct_cad}, in \textit{CATIAv5} environment. The joint properties, such as actuation type and course limitations, as well as the elastic elements properties, were based on previous studies on the hybrid actuation system, the robot construction and other simulators \cite{sabino_estrutura_2009, godinho_desenvolvimento_2011, tokhi_modeling_2006}.

\begin{figure}[H]
\centering
\includegraphics[height=80mm]{Imagens/humanoide_frente.png}
\includegraphics[height=80mm]{Imagens/humanoide_esquerda.png}\qquad \qquad \qquad
\includegraphics[height=80mm]{Imagens/humanoide_completo_alterado.png}
\caption[PHUA platform CAD design model.]{PHUA platform CAD design model.}
\label{fig:simul_construct_cad}
\end{figure}

It was determined that one of the most hampering limitations of the SimMechanics is the lack of a ground/floor interaction system, that is, a way for bodies to interact dynamically with blocks that are rigid to a static element. It is because of this limitation that the unactuated joints in the robot's feet are not represented in this model. As only the tip of the foot is linked rigidly to the ground block, the gravity acceleration made the foot rotate freely around the unactuated joint, although the ground block occupied the space below them. Some strategies were attempted, like mirroring the foot's weight vector from the ground as a contact force, maintaining the foot and the floor plane together, but the toolkit is not prepared for this workaround and the results were unsatisfactory.

The SimMechanics model bodies are built from a reference frame to a destination frame, thus requiring at least two frames. Other frames can be defined in between, and can be given on any previous reference. This model was built from the ground up, defining bodies consecutively. In the legs, the model is built from the tip of the support leg's foot to the tip of the free leg's foot. The distinction between support and free leg is necessary because SimMechanics currently does not support parallel configurations. Table \ref{table:simul_construct_dim} details the geometrical data used to build all the robot body blocks, specifying their mass and centre of mass translation vector (and respective reference frame), as well as the respective inertia matrices, given in the frames of the centres of mass.

\begin{table}[H]
  \centering
	\captionof{table}[SimMechanics PHUA robot model geometrical data.]{SimMechanics PHUA robot model geometrical data used to build the body blocks (positive is for left limbs, negative is for right).}
	\label{table:simul_construct_dim}
	\begin{tabular}{@{\hskip -1mm}c|c|@{\hskip -1mm}c@{\hskip -1mm}|@{\hskip -1mm}c@{\hskip -1mm}}
	\textbf{Body} & \textbf{Mass} (kg) & \textbf{Center of Mass} (mm) & \textbf{Inertia Matrix} ($kg.m^{\minus 2}$)\\ 
	\hline
	Feet & 0.444 & \begin{tabular}{c}[$\pm$2.746$\,;\,$-18.300$\,;\,$9.060]\\\small{(ankle joints frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	9.30\times 10^{-4} & \pm2.20\times 10^{-5} & \mp1.10\times 10^{-5}\\
   	\pm2.20\times 10^{-5}  &  7.6\times 10^{-4} &  1.50\times 10^{-4}\\
    \mp1.10\times 10^{-5} &   1.50\times 10^{-4} & 3.80\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Legs & 0.343 & \begin{tabular}{c}[$\pm$15.861$\,;\,$88.519$\,;\,$0.182]\\\small{(ankle flexion joint frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	5.10\times 10^{-4} & \pm4.80\times 10^{-5} &\mp6.50\times 10^{-7}\\
    \pm4.80\times 10^{-5}  &  2.30\times 10^{-4} &  \pm2.0\times 10^{-5}\\
    \mp6.50\times 10^{-7} &   \pm2.00\times 10^{-5} & 6.80\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Thighs & 0.243 & \begin{tabular}{c}[$\pm$1.418$\,;\,$101.284$\,;\,$-2.262]\\\small{(knee flexion joint frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	5.30\times 10^{-4} & \pm1.10\times 10^{-4} & -4.00\times 10^{-6}\\
    \pm1.10\times 10^{-4}  &  1.40\times 10^{-4} &  4.60\times 10^{-6}\\
    -4.00\times 10^{-6} &   4.60\times 10^{-6} & 5.70\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Pelvis & 0.883 & \begin{tabular}{c}[0.000$\,;\,$-34.800$\,;\,$8.110]\\\small{(torso rotation joint frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	6.39\times 10^{-4} & 7.39\times 10^{-8} & -5.60\times 10^{-8}\\
    7.39\times 10^{-8}  &  0.002 &  -6.80\times 10^{-8}\\
    -5.60\times 10^{-8} & -6.80\times 10^{-8} & 0.002\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Torso Base & 0.089 & \begin{tabular}{c}[0.000$\,;\,$13.411$\,;\,$0.220]\\\small{(torso joints frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	3.65\times 10^{-5} & -7.55\times 10^{-14} & -3.83\times 10^{-9}\\
    -7.55\times 10^{-14}  & 1.23\times 10^{-4} & 4.68\times 10^{-7}\\
    -3.83\times 10^{-9} & 4.68\times 10^{-7} & 1.22\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Torso & 1.849 & \begin{tabular}{c}[2.255$\,;\,$100.867$\,;\,$-18.896]\\\small{(torso joints frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	0.007 & 8.48\times 10^{-5} & -2.73\times 10^{-5}\\
    8.48\times 10^{-5}  & 0.006 & 5.85\times 10^{-4}\\
    -2.73\times 10^{-5} & 5.85\times 10^{-4} & 0.01\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Shoulders & 0.077 & \begin{tabular}{c}[$\pm$18.640$\,;\,$0.000$\,;\,$-2.170]\\\small{(shoulder abduction joint frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	2.30\times 10^{-5} & \mp2.00\times 10^{-9} & 4.24\times 10^{-6}\\
    \mp2.00\times 10^{-9}  & 3.68\times 10^{-5} & \pm2.00\times 10^{-9}\\
    4.24\times 10^{-6} & \pm2.00\times 10^{-9} & 2.30\times 10^{-5}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Arms & 0.250 & \begin{tabular}{c}[$\pm$0.500$\,;\,$-62.457$\,;\,$0.000]\\\small{(shoulder flexion joint frame)}\end{tabular} & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	5.17\times 10^{-4} & \pm6.14\times 10^{-6} & \pm7.60\times 10^{-8}\\
    \pm6.14\times 10^{-6}  & 4.08\times 10^{-5} & -6.70\times 10^{-6}\\
    \pm7.60\times 10^{-8} & -6.70\times 10^{-6} & 5.16\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Forearms & 0.048 & \begin{tabular}{c}[$\pm$3.418$\,;\,$-26.603$\,;\,$0.000]\\\small{(elbow flexion joint frame)}\end{tabular}  & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	4.18\times 10^{-5} & \pm4.34\times 10^{-6} & 8.23\times 10^{-12}\\
    \pm4.34\times 10^{-6}  & 1.87\times 10^{-5} & \mp8.37\times 10^{-12}\\
    8.23\times 10^{-12} & \mp8.37\times 10^{-12} & 5.76\times 10^{-5}\end{bmatrix}$\\~\end{tabular}}\\
	\hline
	Head & 0.333 & \begin{tabular}{c}[0.000$\,;\,$22.400$\,;\,$-11.300]\\\small{(head tilt joint frame)}\end{tabular}  & \scriptsize{\begin{tabular}{c}~\\$\begin{bmatrix}
	1.95\times 10^{-4} & 4.60\times 10^{-7} & -1.60\times 10^{-7}\\
    4.60\times 10^{-7}  & 2.48\times 10^{-4} & -1.80\times 10^{-5}\\
    -1.60\times 10^{-7} & -1.80\times 10^{-5} & 2.75\times 10^{-4}\end{bmatrix}$\\~\end{tabular}}\\
	\end{tabular}
\end{table}

The model was built to have as inputs each joint position, velocity and acceleration curves, and is equipped to measure and output the active/passive torques in all the joints. It was also implemented a mechanism that tracks the full body center of gravity position, velocity and acceleration curves, which is then represented using the three orthogonal lines (red, green and blue) that represent the COG frame, allowing to detect its movement even when it is occluded within the robot.

Also, the robot model bodies were created with redundant frames that help SimMechanics draw an approximate volume that enriches the graphical visualization of the model, shown in Figure \ref{fig:simul_graph_vizu}. This volume is created with the outermost frame origins of each body, so the geometry is not exact, but it is also not used on any calculations.

\begin{figure}[H]
\centering
\includegraphics[height=65mm]{Imagens/simmech_model_vizu_1.png}
\includegraphics[height=65mm]{Imagens/simmech_model_vizu_2.png}\quad\quad
\includegraphics[height=65mm]{Imagens/simmech_model_vizu_3.png}
\caption[SimMechanics model graphical visualization.]{SimMechanics model graphical visualization. The robot is represented in red and the step and floor bodies in gray. The three orthogonal lines that represent the COG are also represented in their red-green-blue color order.}
\label{fig:simul_graph_vizu}
\end{figure}

In preparation for the step climbing simulation, the body blocks for the step and floor plane were included in the model. All of the step's dimensions are pre-defined, with the exception of its height. The step height $h$ is a parameter of the simulation, used to define the foot trajectories. Figure \ref{fig:simul_step_steps} shows a series of acceptable step heights with the robot on its final pose of the simulation.

\begin{figure}[H]
        \centering
        \begin{subfigure}[b]{0.197\textwidth}
                \centering
                \includegraphics[height=39mm]{Imagens/simmechanics_25_side}
                \caption{h=25mm}
                \label{fig:simm_25}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.197\textwidth}
                \centering
                \includegraphics[height=39mm]{Imagens/simmechanics_50_side}
                \caption{h=50mm}
                \label{fig:simm_50}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.197\textwidth}
                \centering
                \includegraphics[height=39mm]{Imagens/simmechanics_75_side}
                \caption{h=75mm}
                \label{fig:simm_75}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.197\textwidth}
                \centering
                \includegraphics[height=39mm]{Imagens/simmechanics_100_side}
                \caption{h=100mm}
                \label{fig:simm_100}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.197\textwidth}
                \centering
                \includegraphics[height=39mm]{Imagens/simmechanics_125_side}
                \caption{h=125mm}
                \label{fig:simm_125}
        \end{subfigure}
        \caption[SimMechanics step heights visual comparison.]{SimMechanics step heights visual comparison, ranging from 25 to 125mm.}\label{fig:simul_step_steps}
\end{figure}

% -------------------------------------------------------------
% step climbing
% -------------------------------------------------------------
\section{Step Climbing}\label{sec:simul_step}
The definition of the step climbing joint position curves was based on an analysis on the humans stair ascent and descent natural joint courses \cite{protopapadaki_hip_2007}. The data is shown, in Figure \ref{fig:simul_joint_courses}, for the spans of the leg flexion joints of the ankle, knee and hip for the humans. Due to the SimMechanics floor plane interaction limitations, the whole step climbing movement can not be performed at once using the same model. The support leg becomes a free leg when the current free leg presses the step to project the body upwards. Therefore, this simulation only covers half of the step climbing movement.

\begin{figure}[H]
\centering
\includegraphics[width=0.85\textwidth]{Imagens/step_climbing_joint_courses.png}
\caption[Mean angles for the human hip, knee, and ankle joints during stair ascent and descent.]{Mean sagittal plane angles for the human hip, knee, and ankle flexion joints during stair ascent and descent \cite{protopapadaki_hip_2007}.}
\label{fig:simul_joint_courses}
\end{figure}

From the analysis of the human step climbing movement, a 4 stage approximate movement was designed for the robot, as shown in Figure \ref{fig:simul_step_movement}. On the first stage the robot lowers the hip backwards to leave the singularity point of the upright posture and increase the joint ranges. The second and third stage represent the leg swing, where the robot will pull the thigh upwards and swing the leg and foot forward. The last stage is the beginning of the support leg switch stances, where the foot approaches and steps on the target step. Each stage duration was timed to approximately match the timings of the human natural stances.

\begin{figure}[H]
        \centering
        \begin{subfigure}[b]{0.195\textwidth}
                \centering
                \includegraphics[height=35mm]{Imagens/simmechanics_movement_1}
                \caption{0\%}
                \label{fig:simm_movement_1}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.195\textwidth}
                \centering
                \includegraphics[height=35mm]{Imagens/simmechanics_movement_2}
                \caption{35\%}
                \label{fig:simm_movement_2}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.195\textwidth}
                \centering
                \includegraphics[height=35mm]{Imagens/simmechanics_movement_3}
                \caption{56.7\%}
                \label{fig:simm_movement_3}
        \end{subfigure}%
        %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.195\textwidth}
                \centering
                \includegraphics[height=35mm]{Imagens/simmechanics_movement_4}
                \caption{78.3\%}
                \label{fig:simm_movement_4}
        \end{subfigure}%
        \:%add desired spacing between images, e. g. ~, \quad, \qquad etc. 
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.195\textwidth}
                \centering
                \includegraphics[height=35mm]{Imagens/simmechanics_movement_5}
                \caption{100\%}
                \label{fig:simm_movement_5}
        \end{subfigure}
        \caption[SimMechanics step climbing movement.]{SimMechanics step climbing movement, with the correspondent time fractions, examplified for a 100mm step.}\label{fig:simul_step_movement}
\end{figure}

For the implementation of this simulation with the developed model, the joint course curves must be fed into the model. The limb joint space trajectories were translated from the Cartesian space using the standard inverse kinematics expressions for the RRR planar robot(three consecutive parallel rotational joints), shown on equations \eqref{equation_simul_ik_theta2}, \eqref{equation_simul_ik_theta1} and \eqref{equation_simul_ik_theta3}, applied to both the support leg and the free leg, whereas on the support leg the end-effector is the hip and on the free leg the end-effector is the foot. The end-effector pose is determined by the Cartesian position $Pw_x$ and $Pw_y$, and by the orientation $\phi$. $L_1$ and $L_2$ stand for the limb lengths.

\begin{align}
\theta_2 &= \pm \arccos\left(\frac{Pw_x^2+Pw_y^2-L_1^2-L_2^2}{2\,L_1\,L_2}\right) \label{equation_simul_ik_theta2}\\
\theta_1 &=	\arctan\left(\frac{Pw_y(L_1+L_2\,\cos\,\theta_2\,)-Pw_x\,L_2\,sin\,\theta_2}{Pw_x(L_1+L_2\,\cos\,\theta_2\,)+Pw_y\,L_2\,sin\,\theta_2}\right) 	\label{equation_simul_ik_theta1}\\[2mm]
\theta_3 &= \phi - \theta_1 - \theta_2	\label{equation_simul_ik_theta3}
\end{align}

The individual joint trajectory curves are then built using a 5\textsuperscript{th} degree polynomial, from the initial joint position $\theta_i$ to the final position $\theta_f$. The time frame is defined by the initial and final time values, $t_i$ and $t_f$. Parameters $a$, $b$ and $c$ \eqref{equation_simul_joint_course_parameters} are used to create the time dependent curves for the joint position $q$, velocity $v$ and acceleration $a$, represented in equations \eqref{equation_simul_joint_course_qq}, \eqref{equation_simul_joint_course_qqv} and \eqref{equation_simul_joint_course_qqa}.

\begin{equation}
a = -\frac{10\left(\theta_i-\theta_f\right)}{\left(t_f-t_i\right)^3};\quad b = \frac{15\left(\theta_i-\theta_f\right)}{\left(t_f-t_i\right)^4};\quad c = -\frac{6\left(\theta_i-\theta_f\right)}{\left(t_f-t_i\right)^5}	\label{equation_simul_joint_course_parameters}
\end{equation}
\begin{align}
q &= \theta_i + a\,t^3 + b\,t^4 + c\,t^5	\label{equation_simul_joint_course_qq}\\
v &=\dot{q} = 3\,a\,t^2 + 4\,b\,t^3 + 5\,c\,t^4	\label{equation_simul_joint_course_qqv}\\
a &=\dot{v} = 6\,a\,t + 12\,b\,t^2 + 20\,c\,t^3	\label{equation_simul_joint_course_qqa}
\end{align}

Using a 5\textsuperscript{th} degree polynomial function for the position description ensures the acceleration curve is continuous in its domain. Figure \ref{fig:simul_joint_course_example} shows an example of the three curves used to define a joint movement.

\begin{figure}[H]
\centering
\includegraphics[width=0.62\textwidth]{Imagens/joint_course_example.pdf}
\caption[Example of a joint course description curve set.]{Example of a joint course description curve set, for the support leg knee in a 75mm step height 10 second climbing movement.}
\label{fig:simul_joint_course_example}
\end{figure}

The model uses the joint information data sets to generate the robot motion and dynamical behaviour. As the model is parametrized by the step height and all of robot's 25 joints are analysed, the data produced is extensive. Figures \ref{fig:simul_support_leg_torques} and \ref{fig:simul_free_leg_torques} show two examples of torque curves that can be extracted from this simulator.

\begin{figure}[H]
\centering
\includegraphics[width=0.73\textwidth]{Imagens/support_leg_torques_h50_t10.pdf}
\caption[Example of a joint torque data set for the support leg.]{Example of a joint torque data set for the support leg in a 10 second movement with a step height of 50mm.}
\label{fig:simul_support_leg_torques}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[width=0.73\textwidth]{Imagens/free_leg_torques_h50_t10.pdf}
\caption[Example of a joint torque data set for the free leg.]{Example of a joint torque data set for the free leg in a 10 second movement with a step height of 50mm.}
\label{fig:simul_free_leg_torques}
\end{figure}

However, this model also calculates passive torque for the joints actuated with constant values, corresponding to the still torque the motor would have to produce to hold its position, as shown in the examples of Figures \ref{fig:simul_torso_leg_torques} and \ref{fig:simul_left_arm_leg_torques}, for the same case as before.

\begin{figure}[H]
\centering
\includegraphics[width=0.73\textwidth]{Imagens/torso_torques_h50_t10.pdf}
\caption[Example of a joint torque data set for the torso.]{Example of a joint torque data set for the torso in a 10 second movement with a step height of 50mm.}
\label{fig:simul_torso_leg_torques}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics[width=0.73\textwidth]{Imagens/left_arm_torques_h50_t10.pdf}
\caption[Example of a joint torque data set for the left arm.]{Example of a joint torque data set for the left arm in a 10 second movement with a step height of 50mm.}
\label{fig:simul_left_arm_leg_torques}
\end{figure}

By examining the data collected for the knee and ankle joints using several simulations with different step heights, it was possible to verify that although the results for the ankle joints with the elastic elements in placed produced expectable results, the curves produced for the knee joint were not consistent to what was expected. It was expectable that the knee joint torque curves would show less energy spending while the knee was recovering from a given position, due to the torque gained from the elastic elements, just as it was seen for the ankle joints, but that was not the case.

The spring and damper block used to create the elastic elements of the robot (with a zeroed damping factor), simulates a rigid spring connected between two different bodies in space. On the knee, these connection points are placed on the leg and thigh, at approximately 30mm from the joint axis. When the knee is upright, the force vector from the spring is correctly applied to the bodies due to the spring being defined as pre-tensioned. Then, as the knee flexes, and as SimMechanics does not yet possess interaction mechanisms between bodies, the model solver sees the two end points of the spring coming closer, instead of farther. Naturally, neither the force direction nor its magnitude are well calculated by the algorithms and the joint torque influence that was expected from the hybrid actuation system is not verified in the resulting curves. 

The force generation from the elastic elements in the knee is non-linear and very hard and time consuming to simulate using other Simulink blocks due to the closed form of the SimScape suite (in which SimMechanics is inserted). It was then decided that the simulation of the second half of the step climbing movement was not to be pursued because the results for the hybrid actuation of one of the most critical joint in that movement, the knee, could not be trusted.
\clearpage
~\\[5mm]
\thispagestyle{empty}