Biped Model and Simulator: Configuration
Biped Model and Simulator: Configuration
CHAPTER 2
2.1 Introduction
This chapter gives an introduction to the SimMechanics software, with all essential
components involved in the making and visualisation of a biped model explained. Settings,
configurations and procedures chosen for the creation of the mobile robot simulator are
mentioned here, and a simple example of getting started with SimMechanics is also provided.
The methods used to connect and control the joints of the biped model, and the types of
sensor values that are used for the biped model are discussed. The division of the complete
biped model into several subsystems for ease of understanding are also covered, and the
extremely useful capabilities of system functions that allow immediate control of the biped
model through the MATLAB command window are explored. A description of how rigid
bodies within SimMechanics can be visualised, and the effect of such visualisation on the
simulation speed are also covered. Finally, the effect of ODE solvers on the speed and
accuracy of simulation form an essential aspect of the SimMechanics environment, and hence
Developed by MathWorks, Simulink is used for modelling, simulating and analysing multi-
domain dynamic systems, with a primarily graphical block diagram interface. Within the
further improves the scope of systems that can be modelled by providing the tools required
directly. Its purpose is the engineering design and simulation of multi-body mechanical
systems, and representing the system through the use of rigid bodies, joints, constraints and
force elements, all under the rules determined by the standard Newtonian dynamics of forces
and torques. The differential algebraic equations (DAE) that characterises the system’s
behaviour are automatically created by the Simscape component, and allowed to interact
with other Simulink models, with variables for the components in the different physical
3D Translational and rotational motions of mechanical systems are available for visualisation
with the suite of tools provided by SimMechanics. Rigid bodies can be defined by their mass
properties, inertia tensors, kinematic constraints, coordinate systems and with means of
initiating and measuring their motions. With such capabilities that provide gravity and
surgical devices, landing gears and a variety of other systems. To further enhance the
properties of the rigid bodies, the software allows for the importing of CAD assemblies,
where the geometrical and physical definitions are more easily obtained. Once within the
SimMechanics environment, the model can be combined with other Simulink functions, as
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 17
well as other physical system modelling products within Simulink, for more complex
interactions in the multi-domain physical system. Other physical system modelling products
SimHydraulics for hydraulic systems as well as foundation modelling, as shown in Figure 2.1.
Figure 2.1: Simscape environment. Simscape is an extension of the Simulink component within
MATLAB. It allows for physical system modelling by providing physical system blocks for different
engineering areas, and can communicate to other Simulink models through the automatic creation and
simultaneous solving of DAEs
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 18
With the ease of integration with other existing toolboxes within MATLAB and Simulink
components, SimMechanics is chosen as the tool that will be used for the analysis of
movement and postures of a biped model. By making use of existing functions within the
For our biped model being considered, the Bodies, Joints, and Sensors & Actuators sets will
make up the majority of the blocks used. Hence, these blocks will be looked at in more detail
in this chapter.
Unless otherwise stated, all vectors, tensors and coordinates used throughout this report are
represented by the Cartesian coordinates system. The reference frame (RF) that we use is the
master SimMechanics inertial RF, and unless otherwise noted, all coordinates will be with
respect to this inertial RF. Sometimes, it will be called the world coordinates or the global
coordinates, and it does not necessarily have a coordinates of [0 0 0]. All the rigid bodies
within our system will be represented relative to the world coordinates, as shown in Figure
2.2, and for ease of analysis, the world coordinates will be set to [0 0 0] throughout our
research work.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 19
Figure 2.2: Coordinates system. The origin of a rigid body coordinates can be translated and rotated
with respect to the world coordinates
The equation representing the position of the rigid body relative to the world body at a
= [ − −
−
]
(2.1)
The orientation of the rigid body can be represented using the quaternion, rotation matrix or
Euler angle representation (Goldstein, 1980). In the model considered, the rotation matrix
will be used to represent the orientation of the rigid body and is given by:
=
(2.2)
Calculations related to equations (2.1) and (2.2) are performed automatically by the
SimMechanics environment, and updated at each simulation step to reflect the motions of
Even though SimMechanics models can be imported from the CAD software, several
modifications will be required for a mobile robot system. Hence, it is a good idea to
understand the different blocks involved in the model design. Bodies and joints form the
basic building blocks for any SimMechanics models, and they can take several forms, as
Figure 2.3: Bodies and Joints in SimMechanics. A functional SimMechanics model must consist of at
least Bodies and Joints blocks
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 21
Table 2.1 gives a more detailed description of the Bodies block that will be used in our biped
model machine environment. The machine environment can also be called the simulation
Dimensionality: 3D Only
Represents an immobile ground point at rest in the absolute world reference frame. It
Ground is considered as a body that cannot be moved under any circumstances and at least
one of these ground blocks must be present in the machine environment. It should be
noted that the ground block is not a flat surface, but rather is a reference point. As
mentioned in subsection 2.2.2, in order to have the world coordinates as [0 0 0], the
settings for this ground block should be:
Location [x, y, z]: [0 0 0] m
The body block is a basic element of a mechanical system and is defined through its
mass and inertia tensor, position and orientation in space, and multiple attached body
coordinates system that allow it to be connected to multiple joints, constraints, or
drivers. It has no DoFs but has a CoM, and is regarded as a rigid body. The body
properties will be automatically dealt with if a proper CAD assembly is imported into
Body
the SimMechanics environment, with position and orientation convention as
described in equations (2.1) and (2.2) and the inertia tensor as a real and symmetric 3-
by-3 matrix.
The body block also allows for the rigid body geometry to be defined. Based on the
properties set for the block, it can be viewed as a convex hull from body coordinates
locations, as an equivalent ellipsoid from mass properties, or from an external
graphics file using the stereolithographic (STL) format.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 22
While many joints are available, only a selected few is considered in our biped model. Most
of the joints are defined during the CAD design phase, and are converted to matching types
of joint in SimMechanics during the CAD assembly import phase. With respect to our biped
model, the essential types of joint to take note of are tabulated in Table 2.2.
A composite joint with three translational DoFs as three prismatic primitives and
three rotational DoFs as three revolute primitives, it allows for the biped model to
move within the environment with limited freedom. In order to prevent the joints
from becoming singular, none of the prismatic primitives or revolute primitives
should be parallel and create a “gimbal lock”, as simulation errors will then occur.
Brushing The “gimbal lock” can occur when the biped model is required to rotate more than
90° in any direction from its default position. In other words, while the biped model
will be able to move forward and sideways within the simulation environment, it
must not turn backwards. This joint is useful if there is a need to fix part of the biped
body such that it does not move. It allows for all six DoFs to be actuated, unlike the
six-DoF joint type. With world coordinates reference, the initial axis of actions [x y z]
settings for brushing joint were set to:
Unlike CAD software that does not provide the required tools for the designing of controllers,
SimMechanics provides tools like sensors and actuators, shown in Figure 2.4, to allow
Figure 2.4: Sensors & actuators. Joints and Bodies can be controlled using actuators, and sensors
provide feedback related to the specific joints or bodies
The most commonly used blocks from the sensors and actuators set in our biped model are
Sensors &
Description and Configuration
Actuators
Body Actuator Given a rigid body, it is possible to apply a force for translational motion or
torque for rotational motion on a specific point of the rigid body. This block will
be used within the biped model in cases where a force needs to be applied to
the biped model, for example, a push on the back of the model to see how it
behaves and how it falls down.
If there is a need to track a specific point on a rigid body, the body sensor is
Body Sensor ideal for the task. With respect to the world coordinates system, it provides
information like position, velocity, angular velocity, acceleration, angular
acceleration and the rotation matrix for the orientation.
The use of position tracking and velocity tracking for our model is essential, as
the ground surface and ground friction will be modelled based on these two
measurements.
A joint between two bodies represent the relative DoF between them, and in
order to control their relative motion, a joint actuator block is required. There
are two methods of actuation with the use of this block and they will affect the
way the control of the actuation is modelled in our biped model. The method of
actuation can be done through a generalised force or through a motion.
Joint Actuator A generalised force: The actuation signal is interpreted as a force between the
two bodies if they are connected by a prismatic primitive. If the joint between
the two bodies is of the revolute type, the signal to the joint is interpreted as a
torque signal.
A motion: With the connection being of the prismatic type, the position,
velocity and acceleration for the linear position motion actuation will need to be
specified. If a revolute primitive is being used, angular motion actuation will be
determined by the angular position, angular velocity and angular acceleration.
For our case, control of the joint actuator through a motion signal is preferred
for its ease of control.
Each joint sensor can measure a combination of outputs that depends on the
joint primitive that it is attached to. For translational motion through prismatic
primitive, the linear position, linear velocity and linear acceleration at a
particular simulation step can be obtained in various types of measurement
Joint Sensor units. If the joint is a revolute primitive, the angle, angular velocity and angular
acceleration can be sensed in different types of measurement units. In a
spherical primitive, measurements of the quaternion, quaternion first derivative
and quaternion second derivative are obtainable. The joint sensor also allows
for computed and reaction force to be calculated for prismatic joints and
computed and reaction torque for revolute joints. Spherical joint allows only for
reaction force and reaction torque to be obtained. Specific to the SimMechanics
environment that makes use of base body and follower body, the difference
between the reaction and computed force or torque are explained as:
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 26
Reaction force and reaction torque are three-component vectors of the force
and torque that the joint transfers from the base body to the follower body.
Computed force is the component of the reaction force projected along the
prismatic primitive axis. It is also the force along the prismatic axis that
reproduces the follower motion with respect to the base.
Computed torque is the component of the reaction torque projected along the
revolute primitive axis. It is also the torque about the revolute axis that
reproduces the follower motion with respect to the base
With regards to our model, particularly for the revolute joints representing the
28 DoFs, the useful set of sensor data would include the angle, angular velocity
and computed torque. The reaction torque is not required as only the torque
along the revolute axis is essential for us outside of the simulation world.
The computed torque provided will also have a direction sign, depending on
which is the follower body and which is the base body. The sign is of no
importance to us, with the focus placed on the magnitude instead.
(a) (b)
Figure 2.5: Joint reaction and computed values (a) Reaction and computed force on a prismatic joint
(b) Reaction and computed torque on a revolute joint
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 27
As mentioned in subsection 2.2.3, the machine environment block determines how the
machine should behave in the simulation environment. Given the importance of the
simulation environment and machine behaviour, some details about the settings handled by
Starting with a simple case of machine dimensionality, there are two main choices: “2D only”
and “3D only”. For a 3D model, like our biped that can move in 3D, the obvious choice is the
“3D only”. Choosing “2D only” allows for movement in 2D and any attempt to make the
model move in the third dimension will cause the whole simulation to stop with an error.
Given SimMechanics uses ODE solvers to solve Newton’s equations by integrating applied
forces and torques, and obtaining the resulting motions, the possibility exists for position
errors to occur between bodies connected by prismatic or revolute joints. These position
errors increase as the accuracy of the ODE solvers is reduced. By setting linear assembly
tolerance for prismatic joints and angular assembly tolerance for the revolute joints, the
simulation can continue provided that the position error is within the defined tolerance
value. We set linear assembly tolerance to 0.025e-3 metres and angular assembly tolerance to
1e-3 radians to allow the simulation to continue without significant deformation of the model
Next, the analysis mode (Moler, 2004) needs to be chosen, and it defines the type of solution
for the machine’s motion. The four options presented for this parameter are described in
Table 2.4, and given that our focus is not on the analysis mode, detailed descriptions are
avoided.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 28
Similar to inverse dynamics, where the forces and torques are determined in
order to make the actuators produce user-specified motions, with the
exception that it is used for closed topologies instead of open topologies.
Even though our biped model is a closed loop machine, this mode of analysis
Kinematics is not used as one of the independent DoFs is not kinematically actuated,
and hence making the mechanical model action not completely specified.
The independent DoF in question is the joint that links the biped model to
the ground block, and which is the one responsible for allowing the biped to
move within the simulation world.
After consideration of the four modes of analysis for the model, the only option for the biped
model is the forwards dynamics mode, and which is also the most flexible mode among the
four and can be used with any topologies. Forward dynamics can be used to analyse inverse
dynamics and kinematics when required, though it is less efficient than inverse dynamics and
kinematics and takes more time when computing the forces on a system.
(a)
(b)
Figure 2.6: Open and closed topologies. The topology of a machine diagram is the global connectivity
of all its elements, with bodies as elements and its connections being joints, constraints and drivers (a)
A simple pendulum modelled as an open topology (b) A four bar mechanism modelled as a closed
topology
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 30
SimMechanics is a simulation tool that does not contain a complete set of physics engine,
with only the presence of a gravity vector to determine the motion of rigid body machines.
The physics engine needs to be taken care of by the user through the use of other Simulink
blocks. It is very important to understand how to model some components for physics
effects, as without such knowledge, the creation of a mobile biped system within
SimMechanics is impossible. In Figure 2.7, an example is shown on how to model air drag on
a projectile motion, and our horizontal ground surface and ground friction modelling method
Figure 2.7: Modelling air drag. In SimMechanics, several physics effects have to be modelled as they
are not readily available
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 31
value of [0 -9.81 0] m/s2 in the x-y-z Cartesian system. With reference to Figure 2.7, having a
value of zero for the “Drag Coeff” block is similar to having the default simulation
environment of SimMechanics. In such case, suppose an initial velocity of 100 m/s in the
horizontal x-axis and 75 m/s in the vertical y-axis is given to a point particle with a mass of
100 kg. SimMechanics will make use of ODE solvers to find the motion of the particle. The
particle itself is considered to be two prismatic primitives in the x-axis and y-axis for 2D
motion. The case where the input to the “Drag Coeff” block is set to 0.5 is also simulated for
the same initial velocities and the combined results are as shown in Figure 2.8.
Projectile motion
350
X: 759.6 Air drag coefficient = 0.0
Y: 286.7
300 Air drag coefficient = 0.5
250
y displacement (m)
200
150
100
50
X: 1529
Y: 8.514e-012
0
0 200 400 600 800 1000 1200 1400 1600
x displacement (m)
Figure 2.8: Projectile motion. With an air drag coefficient of 0.0, the simulation is same as if
SimMechanics is running only with its default physics effect that includes only gravity. With an air drag
coefficient of 0.5, the motion is dependent on how the user has modelled the physics effect
In order to check whether the gravity vector is working properly in the SimMechanics
environment while the ODE solvers are being used, a manual check involving basic projectile
equations (Hayen, 2003) is considered in finding the maximum vertical displacement, ℎ .
The maximum vertical displacement ℎ for a point particle in space can be obtained by
=
(2.3)
1
! = "ℎ
2
(2.4)
!
ℎ =
(2.5)
2"
where and are the kinetic energy and potential energy of the point particle
respectively. Mass of the point particle is 100 kg, with the y-component of the initial
velocity being = 75 m/s and the gravity value " being 9.81 m/s2.
The result is ℎ = 286.6972477 m, which is what the ODE solver within SimMechanics has
been able to match closely. It should be noted here that the accuracy of the results and
smoothness of the plot in SimMechanics depends on the ODE solver and simulation step size
It is also noted from Figure 2.7 that there exists a “PositionSensor” subsystem that tells the
simulation to stop when the particle falls below the horizontal ground reference value of 0
during a particular simulation time step. This further reinforces the conclusion that
SimMechanics does not have a readily available physics engine to model a horizontal ground
surface, as the particle would have continued its downward fall until the simulation was
From this example of projectile motion and air drag modelling, it was concluded that several
physics effects, particularly ground surface friction and collision detection, would have to be
modelled with the use of Simulink blocks in order to have a functional mobile robot
simulator. As for the gravity and motion aspect, SimMechanics is able to deal with it in an
In the process of making the biped model in SimMechanics, there will be many instances
when several blocks will be grouped together to form a subsystem. An example could be the
grouping of the blocks for the right wrist, right elbow and right shoulder into a subsystem
called the right upper limb. For our biped model, Figure 2.9 shows how the different biped
body parts are manually divided into six subsystems. In this way, it is easier to understand
which actuators, sensors or body parts belong to which section, as well as making it easier to
remove limbs from the model for design updates or testing purposes.
Figure 2.9: Division of the biped model into subsystems. It becomes easier to understand and manage
the biped model if the body parts are divided several distinct groups
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 34
The overall process in creating a subsystem is illustrated in Figure 2.10, as well as the useful
case of masking the custom subsystems that have been created. Several of the subsystems
within our biped model are masked to make these custom-made blocks easily accessible
through the Simulink library. Modifying the masked custom-made blocks through the library
causes the update to be propagated throughout the model, thereby eliminating the error-
prone and tiresome process of manually updating each blocks had the custom-made
Figure 2.10: Overall process for subsystem creation and masking. The biped model makes frequent use
of subsystem creation and masking as it facilitates understanding and management
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 35
Simulink provides many common library blocks for use during modelling. However, in many
cases, blocks that can provide the desired functions for a specific model might not be
available within the Simulink library. In the case of the biped model that is being designed,
there are no blocks that can readily meet most of our requirement. This is where system
functions (S-functions) written within S-function blocks become essential throughout the
S-functions provide a powerful mechanism for extending the capabilities of the Simulink
environment, and can be written in MATLAB, C, C++ or Fortran language. It uses a special
calling syntax called the S-function application programming interface (API), and which
enables interaction with the Simulink engine. In order to get a brief understanding of S-
functions, we need to look at the mathematical relationship between the inputs, states,
outputs of a Simulink block, as these will be very helpful in creating S-functions for our biped
model.
A Simulink block consists of a set of inputs, a set of states and a set of outputs, as illustrated
in Figure 2.11(a) for continuous states and Figure 2.11(b) for discrete states.
(a) (b)
Figure 2.11: Mathematics of Simulink blocks. Outputs are a function of the simulation time, the inputs
and the states (a) Continuous system with continuous states (b) Discrete system with discrete states
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 36
In the continuous system, Simulink solvers integrate a set of continuous states using the
following equations:
# = $% (', )* , +) (2.6)
where the output # and derivative )*- are functions of the simulation time ', the current
system states )* and the input +. $% indicates the output function, while $. indicates the
derivative function.
# = $% (', ). , +) (2.8)
where the output # and the discrete system update )./0 are functions of the simulation time
', the current system states ). and the input +. $% indicates the output function, while $1
Systems can have both continuous and discrete states at the same time.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 37
With the exception of an S-function that keeps track of the simulation time by making use of
continuous sampling, the other S-functions within the biped model makes use of discrete
sampling, as tabulated in Table 2.5. Note that pseudonyms are used instead of the actual S-
function names in MATLAB, as these make it easier to understand the main purpose of the S-
With regards to our biped model, the main advantage in setting the S-function to be accessed
manner. While the biped model will be running in a mostly continuous manner in the
simulation environment, it is not always necessary to access certain S-functions at each and
every simulation time step. Hence, by accessing certain S-functions only when required, the
simulation can be made to run at a faster speed since less processing would be need.
For example, sometimes there is a need to just examine how the biped model moves in the
simulation environment without a need for CoM or support polygon details. In such
instances, setting the next sample time hit of the S-functions dealing with the centre of mass
and support polygon to occur at a much later stage will help alleviate the processing
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 38
requirement of the SimMechanics system. Knowing that the calculation of the CoM and
support polygon involves many computationally intensive algorithms, reducing the rate at
which they are required will speed up the simulation. Some brief numerical details on the
Before ending this explanation of the S-functions in our biped model, with the general
simulation stages illustrated in Figure 2.12, it should be noted that a Level-1 MATLAB S-
function was used, with the programming codes written in MATLAB language and a MATLAB
interpreter used during the simulations. This limited the speed of simulation, with restricted
access to rapid acceleration mode. More quantitative details on this speed aspect are
available in Appendix A. For this current research work, it is not an easy process to update the
Table 2.6, but it will be a useful consideration for future work, in order to have faster
Figure 2.12: How the Simulink engine performs simulation. Depending on the settings chosen by the
user, certain simulation steps from the general stages of S-functions are omitted during the simulation
of the biped model in the SimMechanics environment
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 40
Provides access to a more extensive set of the S-function API and supports code
Level-2 MATLAB
generation. Level-2 MATLAB S-functions supersede Level-1 MATLAB S-functions,
S-function
and is the recommended implementation method in most cases
As a summary, S-functions allows for customised blocks within the biped model, while making
toolboxes and other functions within MATLAB more accessible. For example, each time an S-
function is called, within that S-function could include the instruction codes to access the
MATLAB toolboxes or other functions. The S-functions play an extremely important role in
customising the simulation of the biped model, without which it would not have been
2.3.1 Overview
3D. The initial default colour of a visualised rigid body is red, but the colour can be modified
independently for each one of the rigid bodies when required. There are three ways to
custom body geometry with external graphics file. With a Stewart platform (Stewart, 1965) as
the example, the three types of visual representation are shown in Figure 2.13
2.13. A Stewart
Figure 2.13: Three ways of representing bodies in SimMechanics. The convex hull geometry is the
initial default geometry for all visualised bodies (a) Convex hull representation (b) Ellipsoid
representation (c) Custom body geometry
The convex hull geometry for a body is based on the coordinate system (CS) of the body. Each
body CS has an origin point, and the collection of all these CS points, in general, defines a
One origin is displayed just as a point. To illustrate the meaning of these convex hull
(a)
(b)
Figure 2.14: Convex hull geometry in SimMechanics. Any rigid body with at least one CS can be
represented in convex hull geometry (a) Representation as a nonzero volume shape (b) Representation
as a triangle, line or point
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 43
The ellipsoid representation for a body is based on its mass properties and CoG position.
Generally, the inertia tensor of a rigid body is real and symmetric, with three real eigenvalues
(20 , 2! , 23 ) and three orthogonal eigenvectors, with the latter forming the principle axes of the
body. In the CS defined by the three axes, the inertia tensor is diagonal. When the origin of a
rigid body is at the CoG of the body, the trace of the inertia tensor is the same in such CS and
is given by
45(6) = 20 + 2! + 23 (2.10)
Every rigid body has a unique equivalent homogenous solid ellipsoid that has the same inertia
tensor. In the Cartesian system, an ellipsoid of mass has a surface given by the equation
) ! # = !
!
8 : +; < +8 : = 1
9 9 9>
(2.11)
5[45(6) − 22 ]
9 =?
2
(2.12)
where A = 1, 2, 3
Visualisation as the equivalent ellipsoid is only possible if the principal moments (20 , 2! , 23 )
2! + 23 ≥ 20 (2.13)
23 + 20 ≥ 2! (2.14)
20 + 2! ≥ 23 (2.15)
Any violation of this rule leads to an imaginary generalised radius 9 . In special cases, as
tabulated in Table 2.7, the equivalent ellipsoid might not be a true ellipsoid. The labels
Inertia Tensor
2A 0 0
Example
0 2D 0
Triangle Shape in SimMechanics
Description
0 0 2E
Inequalities Visualisation Window
Ellipsoid
Ellipse
2G + 2H = 2J
2 0 0
2H + 2J I 2G
Zero volume but nonzero
K0 1 0L area,, where one axis 9 is
0 0 1
2J + 2G I 2H
zero.
Line
2G + 2H = 2J
1 0 0
2H + 2J = 2G K0 1 0L
Zero volume and zero area,
where two axes 9 are zero.
0 0 0
2J + 2G I 2H
Point
2G + 2H = 2J
0 0 0
2H + 2J = 2G K0 0 0L
No spatial size, where all
three 9 are zero
0 0 0
2J + 2G = 2H
zero.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 46
The custom body geometry option makes use of external graphics files of the STL format
(Stroud and Xirouchakis, 2000). STL specifies how the rigid body looks like in 3D (Rypl and
Bittnar, 2006), through the use of an arbitrary number of elementary triangles with vertices
at arbitrary points in space, and whose orientation of edges and vertices determines the
“inside” and “outside” of the surface. The usage of STL file is illustrated in Figure 2.15,
whereby a body can be represented as a closed volume mesh comprised of triangles (Zorin et
al., 1996). The quantity of triangles used for the design determines the accuracy of
representation (Szilvasi-Nagy and Matyasi, 2003) with respect to the original material, with a
higher number of triangles necessitating larger storage size and longer time to process when
To verify how simulation speed might vary when different methods of geometry
representation for visualisation are used, a Stewart platform is simulated for 100 seconds of
simulation time. The Stewart platform, as previously illustrated in Figure 2.13, is chosen due
to its complex custom body representation and relatively demanding dynamics. Before
continuing, it is worth noting that throughout this research work, there will be mention of
three different “time”. To prevent confusion, they are briefly described in Table 2.8.
Word Description
Time, or Real Time The time taken in the real world, such as time from wrist watches
The time within the simulation world. For example, if something is simulated in
the virtual world for 100 seconds and the speed of simulation is such that it
Simulation Time
takes 2 seconds of real time to see the 1 second in the virtual world, then the
real time taken will be 200 seconds for 100 seconds of simulation time
While testing the effect of visualisation on simulation speed, the computing hardware and all
software parameters are kept constant, with the exception of the method of geometry
representation. To minimise system bottlenecks, such that the effect that can be analysed is
processing unit (GPU) with 1344 cores and 32 GB of system memory are used on a quad core
processor running at 3.4 GHz with 8 threads. The visualisation window size is set to 960 x
1080 pixels and the model is viewed in 3D. The real time results and central processing unit
(CPU) percentage usage rate for the 100 seconds of simulation time, with visualisation time
that includes 10 ms, 100ms, 1s and 10s, are summarised in Figure 2.16. Inherited time means
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 48
that the visualisation time depends on the simulation step size, and no visualisation means
Assuming Real Time: Simulation Time = 1:1 No Visualisation 10 s 1s 100 ms 10 ms Inherited Time
No Visualisation 11.198
Custom 12.384
Ellipsoid 12.609
Visualisation Geometry
Custom 13.368
Ellipsoid 13.840
Convex hull 13.500
Custom 58.536
Ellipsoid 23.783
Convex hull 22.145
Custom 462.817
Ellipsoid 130.535
Convex hull 130.544
Custom 462.838
Ellipsoid 130.540
Convex hull 130.552
0 50 100 150 200 250 300 350 400 450 500
Time taken (s)
(a)
Average CPU utilisation percentage for 100 seconds of simulation time
for the Stewart platform for different visualisation time
Assuming Real Time: Simulation Time = 1:1 No Visualisation 10 s 1s 100 ms 10 ms Inherited Time
Simulation Time
No Visualisation
Custom
Ellipsoid
Visualisation Geometry
Convex hull
Custom
Ellipsoid
Convex hull
Custom
Ellipsoid
Convex hull
Custom
Ellipsoid
Convex hull
Custom
Ellipsoid
Convex hull
0 5 10 15 20 25
Average CPU utilisation (%)
(b)
Figure 2.16: Visualisation effect on simulation speed and CPU usage. Selecting the appropriate
visualisation time and method can speed up the simulations (a) Real time taken for different
visualisation times (b) Average CPU utilisation for different visualisation times
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 49
It can be concluded that the ellipsoid representation tends to be less resource demanding but
offers no significant simulation speed gains over convex hull representations. Custom body
representation is generally more resource demanding and leads to lower simulation speed.
However, the most significant impact comes from the visualisation time. While having a
lower value for the visualisation time will generally make the simulation animation smoother,
making it too low will in fact degrade the smoothness of simulation because the bottle neck
then comes from the CPU not being able to keep up with the instructions for graphics update
while managing the ODE solvers at the same time. On a quad core processor, a CPU
utilisation of 25% indicates the application is single-threaded and fully utilising the single
core.
Hence, with respect to the visualisation of our biped model, the visualisation time will need
to be adjusted according to the desired smoothness, and there are no fixed values for it. This
is due to the visualisation time being dependent on the simulation time, which in turn can
have different ratios with the real time depending on the simulation complexity. As a
guideline, for a ratio of 1:1 for simulation time: real time, a visualisation time of 50 ms is
reasonable enough, leading to a frame per second (fps) rate of 20. Movies generally run
fluidly at 24 or 30 fps. In some cases, the visualisation will be completely disabled when not
required, in order to spend less time for the completion of the simulation. If visualisation is
still required, disabling the CoG and CS visibility option, as previously shown in Figure 2.14,
Before ending the part on visualisation, it might be helpful to mention that recording of the
animation can also be performed, with each updated and displayed frame captured by
SimMechanics itself. Additionally, since the translational and rotational parameters for each
rigid body within a model can be obtained easily through Sensor blocks, SimMechanics
visualisation can be bypassed and a mechanical animation in a virtual world of one’s own
design can be made. The rigid bodies can be represented as virtual objects using a virtual
reality modelling language (VRML) in a world created by Simulink 3D Animation (Marrin and
Campbell, 1997; Li et al., 2011). However, our purpose is not to beautify the environment in
which the biped model is in but to get useful parameters from the biped model, and hence it
will not be covered any further but can be considered in future improvements. Figure 2.17
depicts some possibilities of combining SimMechanics, or other Simulink products, with the
(a) (b)
(c) (d)
Figure 2.17: Simulink 3D Animation. SimMechanics visualisation can be replaced with Simulink 3D
Animation if required, with more views and details present, such as lighting effects (a) A manipulator
(b) Plane on the runway (c) Car driving simulation and animation (d) Driver’s view inside car
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 51
2.4.1 Overview
Even though models can be imported from the CAD software, several important
modifications will be required for a mobile system. The CAD biped model that is imported
into SimMechanics does not contain any actuated joints, nor does it have any sensors
attached. Even the ground surface on which the biped will be standing needs to be created in
SimMechanics after the model import. A simple example of how to make a functional model
and simulation world is explained in this section, and the unmodified biped model that is
imported from the CAD software will go through the same processes mentioned in this
section in order to make it fully functional. The overall process that we will describe is
summarised in a simple flow chart in Figure 2.18, while Figure 2.19 will be used as the
example for the basic model to be built in SimMechanics throughout this section, and making
it into a fully functional model. By the end of this section, it should be easy to make the biped
model into a SimMechanics system that can be controlled as desired, with sensor values
obtained whenever required and not neglecting the possibility for visualisation.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 52
Figure 2.18: Making a fully functional model in SimMechanics. These steps will be used in explaining
how to make a fully functional model. The biped model imported from the CAD software does not
have any useful abilities and needs multiple modifications before being fully functional
Figure 2.19: Basic model to be designed using SimMechanics. The model is assumed to be a pole with
base at coordinates (0,0,0), and the base is connected to a revolute joint that is controlled through
motion. At the end of the pole at (0,2,0), a stick is connected by using another revolute joint, and
which is controlled through force
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 53
Each model that is being made using SimMechanics requires at minimum a “Machine
Environment” block that represents the machine’s mechanical settings and a “Ground” block
to represent an immobile point at rest in absolute space. Based on Figure 2.19, there are two
revolute joints and two rigid bodies present, and hence, two “Body” block representing the
rigid bodies and two “Joint” blocks for relative motions between the “Body” blocks to which
they are connected are also needed. Figure 2.20 represents the model at this stage.
Figure 2.20: Selecting and positioning the blocks. The essential blocks to create the required basic
model have been chosen and positioned in the modelling window
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 54
Most of the block settings will be left at default values and their names will not be changed
for this basic model. Table 2.9 shows the settings for the six blocks present in Figure 2.20,
This analysis mode is most appropriate for the modelling of simple models, as it does
not have to abide by the rules of open or closed model topologies. Nevertheless, this
mode can be less efficient than the other modes of analysis.
Location [x,y,z]: [0 0 0] m
This block, with the name set to “Revolute”, will represent the revolute joint located
at (0,0,0).
For now, there will not be any actuator or sensor connected to this joint. The rigid
body, with the name set to “Body”, will only be actuated by the force due to gravity,
without the presence of any frictional forces or air resistances.
This block, with the name set to “Revolute1”, will represent the revolute joint located
at (0,2,0).
The revolute joint has a DoF in the z-axis with respect to the world RF.
This block, with the name “Body”, represents the pole from Figure 2.19. The
properties of the “Body” block can be more easily obtained if SimMechanics is used
together with the CAD software. Here, the parameters are manually set to:
Mass: 1 kg
1 0 0
Inertia: eye(3) = K0 1 0L
0 0 1
Position:
It is easier to deal with world coordinates and world RF in our case, as the
coordinates given in Figure 2.19 are in terms of world coordinates
Orientation:
This block, with the name “Body1”, represents the stick from Figure 2.19. The
parameters are manually set to:
Mass: 1 kg
1 0 0
Inertia: eye(3) = K0 1 0L
0 0 1
Position:
Orientation:
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 56
(a) (b)
(c) (d)
Figure 2.21: Block settings window. Configuration windows for the blocks involved in the basic model
(a) “Machine Environment” block (b) “Joint” block (c) “Ground” block (d) “Body” block
The blocks from Figure 2.20 can be connected to form a system by drawing lines between
them. Some block configurations are available only after connections between different block
are made. Three important things to note for any models, as illustrated in Figure 2.22, are:
(1) Exactly one “Machine Environment” block can be connected to a “Ground” block
(2) A body can have several joints attached in order to create branches, but each joint
(3) At least a “Machine Environment” block, a “Ground” block, a “Joint” block and a
Figure 2.22: Valid block connections. Some rules for block connections have to be followed in order for
the simulation to be valid. For example, “Body” blocks cannot be connected directly to other “Body”
blocks, and “Joint” blocks cannot be connected directly to other “Joint” blocks. A valid connection
always include a “Joint” block in between two “Body” blocks
Finally, the complete and valid model for our basic model will be as shown in Figure 2.23.
Pressing the “Play” button will run the simulation for the specified amount of time.
Figure 2.23: Connected and valid model. The simulation can be run for the specified amount of time by
pressing the “Play” button.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 58
At this stage, though the basic model can run, there is no visualisation window. Hence, the
“Simulation Configuration Parameters” need to be set to have a visual view of the model, as
Figure 2.24: Enabling the machine model visualisation. “Display machines after updating diagram” and
“Show animation during simulation” needs to be enabled for visualisation of the machine model
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 59
With the visualisation of the basic model enabled, the machine model can be visualised, as
shown in Figure 2.25, where screenshots of the model are taken every 100 ms for the first
Figure 2.25: Machine model window. The model made by the connection of SimMechanics blocks can
be visualised in the machine model window
Similar to the basic model shown in Figure 2.19, the machine model in Figure 2.25 shows the
pole and stick, as well as their CoG as defined in their respective body blocks. The animation
speed would need to be reduced as 10 seconds of simulation for such a simple model can be
As noted, there is no controlled motion of the two revolute joints in the model at this stage,
with the motion currently determined by gravity and the mass and inertia properties of the
rigid bodies. To have more useful analysis in the field of robotics, the joints should generally
The settings for the two revolute “Joint” blocks can be updated to have values as shown in
Table 2.10, whereby ports on the “Joint” blocks are created to allow for sensor blocks or an
A joint cannot have more than 1 “Joint Actuator” block connected to it, but it can be
connected to several” Joint Sensor” blocks.
The connections to be made between the newly added blocks are as shown in Figure 2.26.
Figure 2.26: Basic model with sensors and actuators. “Joint Actuator” blocks allow for controlled
motion of the joints while “Joint Sensor” blocks provide feedback values
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 61
The settings for the newly added blocks can be set as indicated in Table 2.11, with other
values left at default. Such settings are generally only available for modification when the
The joint is expecting a motion signal vector for its angle, angular velocity and angular
acceleration in terms of degrees and seconds.
The joint is expecting a torque value for actuation in terms of Newton and metres.
The sensor will provide the computed torque experienced by the block named
“Revolute”
The sensor will provide the angular velocity experienced by the block named
“Revolute1”
Connected to block named “Joint Actuator”, it will indicate to the joint holding the
pole to lean 45 degrees to the left. The direction of rotation is based on the sign of
the value, and the base and follower body of the “Joint” block to which “Joint
Actuator” is connected
Constant value: -2
Connected to block named “Joint Actuator1”, it will indicate to the joint holding the
stick that a constant torque of 2 Nm is constantly being applied, with the force acting
in the clockwise direction. If the value was positive, the direction of the force would
have been in the anticlockwise direction
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 62
Simulation of Figure 2.26 would have resulted in a scope display as shown in Figure 2.27.
Figure 2.27: Scope for simulation of basic model. The upper plot represents the computed torque, in
Nm, experienced by the joint at the base of the pole. The lower plot represents the angular velocity, in
degrees per second, experienced by the joint at the base of the stick, as the force supplied to the joint
is sometimes in phase and sometimes in anti-phase with the force due to gravity
Many of the results obtained from the simulation in SimMechanics can be quite surprising
increasingly faster rotation of the stick causes the torque experienced by the joint at the base
of the pole to have larger maximum amplitude, while maintaining its angle. Eventually,
SimMechanics should be able to provide very valuable analysis details for the simulation of
Furthermore, after going through this whole section, it should be possible to perform more
complex modifications of the biped model that will be imported from the CAD software. An
imported model does not contain a horizontal ground surface, nor does it have any blocks for
controlled motion and sensing. A very good grasp of the basics covered here is essential in
order to make the base biped model into a fully functional one.
Finally, note that the ODE solver used was changed from the variable-step ODE solver ode45
to a fixed-step ODE solver ode8. The ODE solver is an extremely important part of
SimMechanics as it determines the speed and accuracy of the results while solving the
An ODE solver computes the dynamic system’s states at successive time steps over a
specified time span, using information provided by the Simulink model (Schwerin, 1999).
There are two broad categories of ODE solvers: fixed-step solver, which is generally required
for code generation, and variable-step solver, which is preferred in models whose states
change rapidly or which contain discontinuities (Ashino et al., 2000). Our biped model is
simulated using the variable-step solver. By using such solver, the simulation step size is
reduced when the model changes state rapidly so as to maintain accuracy, and increases
when the model state changes slowly, in order to speed up the simulation by avoiding
unnecessary steps. Within variable-step ODE solvers in SimMechanics, there are multiple
ode113 Adams-Bashforth-Moutlon
(Shampine, 1975)
Numerical Differentiation
(Shampine, 1997)
Second-order, modified
ode23s
Rosenbrock formula
TR-BDF2
ode23tb
(Shampine and Hosea, 1996)
Runge-Kutta,
One-step method refers to the need of only the solution at the preceding time point, whereas
multistep method refers to the need of solutions at several preceding time points in order to
Explicit one-step method involves the calculation of the system’s state at the next time step
where (') is the current system state, (' + ∆') is the state at the next time step, and
indicates a function.
Implicit one-step method involves the calculation of the system’s state at the next time step
by using both the current system state and the next system’s state, and can be obtained by
The implicit method requires extra computation, but is optimal in solving stiff problems,
while the explicit method takes little computation time but are not efficient in dealing with
stiff systems.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 67
ODE problem is stiff if the solution being sought varies slowly but nearby solutions change
rapidly, hence requiring the simulation step size to be reduced down to unacceptably small
values. For our research work, we are mainly focusing on the efficiency aspect for
computational time. While explicit solvers will solve stiff problems, they take too long to do
them because the step size is reduced to extremely small values. Hence, there is a need to
select a solver that will help our simulations to complete at a faster pace at reasonable
accuracies, given that there are situations where our biped model will encounter stiff
situations. This selection of ODE solver is one of the most essential steps when creating the
To understand what stiffness is and how it will affect the simulation speed, we look at one
example, which is that of a simple combustion model (Abelman and Patidar, 2008) and whose
dynamics is similar, in terms of stiffness, to the reaction force dynamics obtained in our biped
model during ground surface contact. We will not go into the details of linear stability and
eigenvalues of the Jacobian equations, but only look at the computational time aspect in
using different ODE solvers. In the combustion model, when one lights up a match, the ball of
flame grows rapidly until it reaches a critical size, where it remains because the amount of
oxygen consumed by the combustion in the interior of the ball balances the amount available
W#
= #! − #3
W' (2.18)
#(0) = X (2.19)
2
0<#<
X
(2.20)
where the scalar variable #(') represents the radius of the ball and the # ! and # 3 terms
comes from the surface and area of the volume. X is the critical parameter and is the initial
With respect to our biped model, the simulation step size will be reduced to very small values
whenever the biped model is about to touch the ground surface, and which could lead to
stiffness in the system. Having a step size which is too high will make the model go below the
ground surface by the next simulation step, due to the force of gravity. Having too low a
value for the step size will adversely affect the speed of simulation. However, while reducing
the step size will likely improve the accuracy of the simulation, the simulation speed and real
time taken will be negatively affected, as indicated through Figure 2.28 for the simple
combustion model. The combustion model is being used here for its simplicity in getting to
understand the relationship between simulation step sizes, ODE solvers, and computational
time taken. The usage of the actual biped model will be much more complicated and will be
δ = 0.1, Real time taken = 0.01 s Magnified plot for δ = 0.1 near critical point
1 1.0002
0.5 1
0 0.9998
0 5 10 15 20 10 10.5 11
δ = 0.01, Real time taken = 0.05 s Magnified plot for δ = 0.01 near critical point
1.5 1.0002
1
1
0.5
0 0.9998
0 50 100 150 200 100 105 110
δ = 0.001, Real time taken = 0.33 s Magnified plot for δ = 0.001 near critical point
1.5 1.0002
1
y 1
0.5
0 0.9998
0 500 1000 1500 2000 980 1000 1020 1040 1060 1080 1100 1120
δ = 0.0001, Real time taken = 3.05 s Magnified plot for δ = 0.0001 near critical point
1.5 1.0002
1
1
0.5
0 0.9998
0 0.5 1 1.5 2 0.98 1 1.02 1.04 1.06 1.08 1.1 1.12
4 4
x 10 x 10
δ = 0.00001, Real time taken = 28.03 s Magnified plot for δ = 0.00001 near critical point
1.5 1.0002
1
1
0.5
0 0.9998
0 0.5 1 1.5 2 0.98 1 1.02 1.04 1.06 1.08 1.1 1.12
5 5
x 10 x 10
δ intervals
Figure 2.28: X analysis. Reducing the simulation step size increases the accuracy of the results at the
expense of computational time taken
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 70
The real time taken for different values of X is now examined from Figure 2.28. The ODE
solver used is an explicit variable-step one not optimised for stiff problems, but which
provides good accuracy (Shampine, 1994), as mentioned in Table 2.13. It is called the ode45
solver, which makes used of the Runge-Kutta and Dormand-Prince (4,5) pair. The absolute
and relative tolerance values are set to 1e-4, meaning that the computed state is accurate to
within 0.01%, with any error that exceeds this tolerance value leading to a reduction in the
solver’s time step size and taking additional computational time for a solution satisfying the
tolerances.
ODE Order of
Comments
Solver Accuracy
ode113 can be more efficient than ode45 at stringent tolerances or for Variable, Low
ode113
computationally intensive problems. to High
Numerical differentiation formulas are related to, but are more efficient
Variable, Low
ode15s than the backward differentiation formulas, which are also known as Gear's
to Medium
method. ode15s is efficient for stiff problems.
ode23 is more efficient than ode45 at crude tolerances and in the presence
ode23 Low
of mild stiffness.
ode23s is more efficient than ode15s at crude tolerances, and can solve
ode23s Low
stiff problems for which ode15s is ineffective.
ode23t is used if the problem is only moderately stiff and a solution with no
ode23t Low
numerical damping is needed.
ode23tb is more efficient than ode15s at crude tolerances, and can solve
ode23tb Low
stiff problems for which ode15s is ineffective.
Generally, ode45 is the best to apply as a first try for most problems. ode45
ode45 is more accurate and faster than ode23. If ode45 is slow computationally, Medium
the problem may be stiff and thus in need of an implicit solver.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 71
Initially, the problem is not stiff, but becomes stiff as the solution approaches steady state.
Unlike at the beginning, when only a few steps were required to plot the value of 0, once the
rapidly changing solution is encountered, the ODE solver starts to compute significantly more
steps in order to be able to plot the value of 1 within the tolerance value.
Our biped model will encounter similar situations, at the instant when parts of the biped are
about to touch the ground surface. While above the ground surface, no normal reaction force
will be encountered by the body parts, but once the ground surface gets into contact, the
normal reaction force will rapidly change to another value, and thereby potentially making
our biped system stiff. This stiffness has a significant role in our biped system, particularly
with regards to the simulation speed, because the normal reaction force will be used by the
ODE solver in order to obtain positions and velocities of the rigid bodies within the system.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 72
2.5.3 Implicit and explicit ODE solvers for the biped model
After looking at how the simulation time step affects the computational time and overall
accuracy of solutions, the remaining variable-step ode solvers from Table 2.13 are considered
to see how well they deal with stiff problems. Continuing with the flame combustion model,
due to its similarity to the biped model but with the advantage of being easier to understand
and get conclusions from, X is set to a fixed value of 0.0001 for its reasonable results in Figure
2.28. The absolute and relative tolerances are set to be either 1e-4 or 1e-10, but both types of
tolerance have the same value during any one simulation. The results for explicit ODE solvers
are shown in Figure 2.29, and those for implicit ODE solvers are presented in Figure 2.30.
Full plot for chosen Magnified plot with Magnified plot with
explicit ODE solver both tolerances = 1e- 4 both tolerances = 1e- 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
δ intervals
Figure 2.29: Explicit ODE solvers. Effect of tolerances for different explicit variable-step ODE solvers
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 73
Full plot for chosen Magnified plot with Magnified plot with
implicit ODE solver both tolerances = 1e- 4 both tolerances = 1e- 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
y 4 4 4
x 10 x 10 x 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
1
1 1
0.5
0 0.9998 0.9998
0 1 2 1 1.05 1.1 1 1.05 1.1
4 4 4
x 10 x 10 x 10
δ intervals
Figure 2.30: Implicit ODE solvers. Effect of tolerances for different implicit variable-step ODE solvers
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 74
Based on the plots obtained in Figure 2.29 and Figure 2.30, a summary of the real time taken
and number of steps present in the solutions are shown Figure 2.31. It should be noted that
running the same simulation multiple times will lead to negligible differences in the real time
taken but the number of steps taken to obtain the solution while using a specific ODE solver
Time taken for solution for a stiff Time taken for solution for a stiff
problem when both tolerances = 1e-4 problem when both tolerances = 1e-10
Explicit ODE Solver Implicit ODE Solver Explicit ODE Solver Implicit ODE Solver
ode113 ode113
ode23 ode23
ODE solver
ODE solver
ode45 ode45
ode15s ode15s
ode23s ode23s
ode23t ode23t
ode23tb ode23tb
0 1 2 3 4 0 1 2 3 4
Time taken (s) Time taken (s)
(a) (b)
Steps taken for solution for a stiff Steps taken for solution for a stiff
problem when both tolerances = 1e-4 problem when both tolerances = 1e-10
Explicit ODE Solver Implicit ODE Solver Explicit ODE Solver Implicit ODE Solver
ode113 ode113
ode23 ode23
ODE solver
ODE solver
ode45 ode45
ode15s ode15s
ode23s ode23s
ode23t ode23t
ode23tb ode23tb
0 5,000 10,000 15,000 0 5,000 10,000 15,000
Number of steps Number of steps
(c) (d)
Figure 2.31: Summary of time taken and number of steps for different ODE solvers (a) The real time
taken when the absolute and relative tolerances are set to 1e-4 (b) The real time taken when the
absolute and relative tolerances are set to 1e-10 (c) Number of steps in the solution when the absolute
and relative tolerances are set to 1e-4 (d) Number of steps in the solution when the absolute and
relative tolerances are set to 1e-10
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 75
Based on Figure 2.29, Figure 2.30, and Figure 2.31, the following conclusions could be
(1) ode15s could be an appropriate ODE solver given it takes very few steps and less time
(3) Compared to explicit ODE solvers, implicit ODE solvers lose a significant amount of
time advantage at very stringent tolerance values, with the exception of the ode15s.
(4) Given that a tolerance value close to 1e-4 is good enough for our biped model, implicit
(5) Among explicit ODE solvers, ode23 is the better choice at crude tolerance values in
(6) With the highest amount of steps present for a solution by using ode45 in the tested
cases, the latter is likely to be more accurate than the other ODE solvers.
(7) At crude tolerance values, ode45 is less efficient than the other explicit ODE solvers in
terms of real time taken. However, it is the only one among the explicit ODE solvers
in being able to lie within the tolerance limits set near the rapidly changing solution.
(8) Overall, the explicit ODE solvers are primarily concerned with accuracy. They reduce
the step sizes whenever stiff problems are encountered, and unfortunately making
(9) Overall, implicit solvers are less concerned about efficient integration, favouring
larger step sizes while retaining numerical stability. Hence, for crude tolerances, they
tend to lose accuracy while gaining significant advantages in terms of real time taken
Using the conclusions obtained from this section on the selection of an appropriate ODE
solver for the biped model, it appears that implicit ODE solvers would be more efficient in
terms of real time taken, but later analysis while using the actual biped model does not give
such a straightforward conclusion. However, with a better understanding of the ODE solvers
available within the SimMechanics environment, and a basic idea about stiff and nonstiff ODE
solvers, the conclusions in terms of speed and accuracy for the biped model will be easier to
follow. The analysis for the biped model is covered in subsection 4.4.4, where the horizontal
ground surface modelling and other parameters within the SimMechanics environment have
significant effects on the performance and accuracy of the different ODE solvers.
Chapter 2. Biped Model and Simulator: Configuration, Visualisation and Accuracy 77
2.6 Conclusion
This chapter presented all the essential components involved in the development of a fully
functional model within the SimMechanics software. Configurations and procedures chosen
for the creation of the mobile robot simulator and biped model were explained, and the
different methods of visualising SimMechanics models were covered. Conclusions from the
computational aspects of the different ODE solvers within Simulink were obtained, and also
with regards to the presence of stiffness in the biped model. Based on the understanding of
the ODE solvers covered in this chapter, appropriate settings and tolerances for the ODE
solvers will be made during the simulation of the biped model, and depending on the need
Combining all the configurations, steps and explanations covered in this chapter, the fully
functional biped model can be created. Taking one of the simplest subsystems in the biped
model, with only two actuated joints, as an example, a fully functional neck and head
subsystem of the biped model will have the structure shown in Figure 2.32. As an indication,
the whole biped model will consist of 28 actuated joints in total, and hence it is easier to
learn how to make just a subsystem fully functional before dealing with the complete biped
model in SimMechanics. In conclusion, Figure 2.32 acts as the summary to most of the
Figure 2.32: A fully functional subsystem of the biped model. Combining all the configurations, steps
and explanations covered in this chapter, a fully functional biped model, consisting of fully functional
subsystems, within the SimMechanics environment will be realisable