Professional Documents
Culture Documents
AUTOMATION DEPARTMENT
In cooperation with
GHENT UNIVERSITY, FACULTY OF ENGINEERING
ELECTRICAL ENERGY, SYSTEMS & AUTOMATION DEPARTMENT
MODEL PREDICTIVE CONTROLLER APPLIED ON
WALKING LOCOMOTION OF A HUMANOID ROBOT
DIPLOMA THESIS
Student: Rbert MARC
Project Mentor: Eng. Abhishek DUTTA, MSc
Project Supervisor: Prof. Eng. Robin DE KEYSER, PhD
Project Supervisor: Prof. Eng. Ioan NACU, PhD
2010
FACULTY OF AUTOMATION AND COMPUTER SCIENCE
AUTOMATION DEPARTMENT
VISED,
DEAN, HEAD OF DEPARTMENT,
Prof. Eng. Sergiu NEDEVSCHI, PhD Prof. Eng. Liviu MICLEA, PhD
Student: Rbert MARC
MODEL PREDICTIVE CONTROLLER APPLIED ON WALKING
LOCOMOTION OF A HUMANOID ROBOT
1. The Problem: The project proposes t o i mplement, appl y and validat e an
MPC controll er on a three link biped robot, wit h point f eet .
2. Project Content: Cover pages, Declarati on of aut horship, Synthesis,
Acknowledgements, List of figures, Li st of t abl es, Abbreviations,
Nomenclat ure, Abst ract , Table of cont ents, Introducti on i nto bi ped
locomotion, Modelli ng of planar point feet bipedal robot, Feedback
cont rol of a bi ped, Model predi cti ve control of nonlinear pl ant ,
Conclusi ons, Ref erences, Appendi x.
3. Place of documentation: Ghent University, Ghent, Belgium
4. Consultant: Eng. Abhishek DUTTA, MSc.
5. Thesis emission date: February, 10, 2009
6. Thesis delivery date: June, 10, 2009
Student signature______________
Projects supervisor signature_______________
i
Declaration of authorship
I Rbert MARC, graduate student of Faculty of Automatics and Computer Science
from Technical University of Cluj-Napoca, declare that the ideas, analysis, design,
development, results and conclusions within this Diploma Thesis represent my own
effort except for those elements which do not and will be highlighted accordingly in
the document.
I also declare that from my knowledge this thesis is in an original form and was never
presented in other places or institutions but those explicitly indicated by me.
Date: June, 10, 2010 Student: Rbert MARC
Matriculate number: 21020139
Signature: _________________
ii
Synthesis
Of the Diploma Thesis:
MODEL PREDICTIVE CONTROLLER APPLIED ON WALKING
LOCOMOTION OF A HUMANOID ROBOT
Student: Rbert MARC
Project Mentor: Eng. Abhishek DUTTA, MSc.
Project Supervisor: Prof. Eng. Robin DE KEYSER, PhD
Project Supervisor: Prof. Eng. Ioan NACU, PhD
1. Problem definition:
The control problem of bipedal robots can be defined as choosing a proper input such
that the system behaves stable with semi erect torso, and two walking legs. The present
thesis proposes a model predictive controller to regulate the walking motion of a three link
biped model with point feet.
2. Application domain:
Model predictive control with application to robotics.
3. Obtained Results:
The obtained MPC controller drives the outputs quicker to zero then the classical
computed torque feedback linearized controllers.
4. Testing and Verification:
Classical controls (computed torque with feedback linearization) along with the MPC
control were tested. The comparison was made in a biped simulator package. For
simulation purposes MATLAB 7.9.0.529 (R2009b) was used.
5. Personal Contributions:
The swing phase model was implemented in Simulink, along with the model predictive
control.
6. Documentation Sources:
Library of Ghent University (Universiteitsbibliotheek Gent), Internet
Date: June, 10, 2010 Student signature ______________
Projects supervisor signature_______________
iii
Acknowledgements
My deepest gratitude goes to my family for their unflagging love and support
throughout my life, especially during my student years, without them it would be
impossible to graduate. Moreover, I would like to thank to my girlfriend and my sister
for their moral support, love and courage, especially during my stay in Belgium.
Secondly, I would like to show my gratitude Professor Robin De Keyser (from Ghent
University) for offering me the possibility to do this thesis, for his advices and for the
wonderful trips that we made. Many thanks go to my promoter at the Technical
University of Cluj-Napoca, Professor Ioan Nacu, for allowing me to come to study in
Ghent.
I am heartily thankful to my direct supervisor, Abhishek Dutta, whose
encouragement, guidance and support from the initial to the final level enabled me to
develop an understanding of the subject. I am very grateful to my colleague Istvn,
who has been the best friend of mine, during our stay in Belgium. Lots of thanks go to
the other people in the lab, Daniel, Ramona, Ernesto, Yu, Andres, Adrian, Cristina and
Bogdan. Thank you all!
The financial support from the Technical University of Cluj-Napoca, through
the Erasmus Placement Scholarship is greatly appreciated. Without their support, my
ambition to study abroad can hardly be realized.
Lastly, I offer my regards to all of those who supported me in any respect
during the completion of the project.
Rbert Marc
iv
List of figures
Figure 1.1 Timeline: development of biped robots 2
Figure 1.2 Biped robots controlled by ZMP scheme: WL-10RD
(left), ASIMO (right)
3
Figure 1.3 Famous robots: Johnnie, HRP-2L, WL-16R, HUBO 3
Figure 1.4 Underactuated in SSP (a) and over-actuated in DSP (b) 8
Figure 1.5 The human planes of section 8
Figure 1.6 Walking cycle of a biped 9
Figure 2.1 Representation of the three link biped walker with torso 11
Figure 2.2 Key position and force nomenclature. 13
Figure 2.3 Configuration of a link 14
Figure 2.4 The model is indicated in: a) Generalized coordinates b)
Body coordinates
18
Figure 2.5 Hybrid model of walking with point feet 22
Figure 3.1 High level view of the present MIMO system 25
Figure 3.2 The inputs applied in the case of Bernstein Bhat controller 31
Figure 3.3 The inputs applied in the case of the feedback linearized
controller
31
Figure 3.4 Output of the MIMO system during three steps 32
Figure 3.5 Output of the MIMO system during five steps 32
Figure 4.1 MPC principle 35
Figure 4.2 MPC strategy as a block scheme 36
Figure 4.3 Simulink implementation of the swing phase model 40
Figure 4.4 Implementation of the inertia matrix (D) in Simulink 41
Figure 4.5 Sub block for a column in D 41
Figure 4.6 Fcn1 block parameters 41
Figure 4.7 Implementation of the Coriolis matrix (C) in Simulink 42
Figure 4.8 Sub block for a column in C 42
Figure 4.9 Fcn2 block parameters 42
Figure 4.10 First integrator block 43
Figure 4.11 Second integrator block 43
Figure 4.12 Output together with the optimization parameters 44
Figure 4.13 Nonlinear model plant 46
Figure 4.14 Step response generated 47
Figure 4.15 MPC scheme of the Model Predictive Control Toolbox 48
Figure 4.16 Signal properties in MPC toolbox 48
Figure 4.17 Simulated MPC controller inputs 49
Figure 4.18 Simulated MPC controller outputs 49
Figure 4.19 Simulink representation of swing phase dynamics together
with MPC controller
50
Figure 4.20 Initial call-back function associated with model, with
initial parameters
51
Figure 4.21 The two inputs generated by the simulation, after
resampling
51
Figure 4.22 Resulting outputs during one step after the 2D simulation 52
Figure 4.23 Forces calculated on the stance leg 53
Figure 4.24 Graphical representation of the states 53
Figure 4.25 Three link biped representation in the simulator 54
v
List of tables
Table 1 Biped parameters 23
Table 2 Optimizing the virtual constraints for minimal energy
consumption
26
vi
Abbreviations
COM Centre of Mass
COP Centre of Pressure
DC Direct Current
DOF Degree of Freedom
DSP Double Support Phase
EPSAC Extended Predictive Self-Adaptive Control
FES Functional Electrical Stimulation
FNS Functional Neuromuscular Stimulation
FRI Foot Rotation Indicator
GUI Graphical User Interface
MBPC Model Based Predictive Control
MIMO Multiple Input Multiple Output
MPC Model Predictive Control
SISO Single Input Single Output
SPP Single Phase Support
ZMP Zero Moment Point
vii
Nomenclature
Absolute orientation or the absolute angle of link i
Body coordinates
Cartesian coordinates
Configuration and state manifolds
Gravitational constant
Gravitational matrix
Horizontal Cartesian coordinate
Horizontal position of the centre of mass of link i
Identity matrix
Input
Input disturbance
Input matrix
Interval of DSP
Kinetic and potential energies
Total mass
Weight matrix
Zero matrix
; where
.
It is emphasized that all of the above will be illustrated on one of the simplest possible
biped robot models. The robot consists of a torso, hips, and two legs of equal length, with no
ankles and no knees. The two legs are actuated. The reason for this choice of model is
twofold: firstly, asymptotically stable walking has never been proved for such a model, and
thus this simplest problem is still open; secondly, from a pragmatic standpoint, it did not seem
advantageous to obscure the main elements of the control approach with the computational
complexity of a more complete biped model.
2.1. Robot, gait and impact hypotheses
With the terminology described in the previous chapter in mind, complete lists of
hypotheses are now enumerated for the robot model, the desired walking gaits, and the impact
model identical to [21].
2.1.1. Robot with Point Feet Hypotheses
The robot is assumed to be:
12
HR1) comprised of N rigid links connected by ideal revolute joints (i.e., rigid and
frictionless) to form a single open kinematic chain; furthermore, each link has nonzero mass
and its mass is distributed (i.e., each link is not modeled as a point mass);
HR2) planar, with motion constrained to the sagittal plane;
HR3) bipedal, with two symmetric legs connected at a common point called the hip, and both
leg ends are terminated in points;
HR4) independently actuated at each of the ideal revolute joints;
HR5) not actuated at the point of contact between the stance leg and ground and
HR6) the model is expressed in body coordinates
plus one
absolute angular coordinate
.
2.1.2. Gait Hypotheses for Walking
Conditions on the controller will be imposed and shown to ensure that the robot's
consequent motion satisfies the following properties consistent with the notion of a simple
walking gait:
HGW1) there are alternating phases of single support and double support;
HGW2) during the single support phase, the stance leg end acts as an ideal pivot, that is,
throughout the contact, it can be guaranteed that the vertical component of the ground reaction
force is positive and that the ratio of the horizontal component to the vertical component does
not exceed the coefficient of static friction so it does not slip;
HGW3) the double support phase is instantaneous and the associated impact can be modelled
as a rigid contact [24];
HGW4) at impact, the swing leg neither slips nor rebounds, while the former stance leg
releases without interaction with the ground;
HGW5) in steady state, the motion is symmetric with respect to the two legs;
HGW6) in each step, the swing leg starts from strictly behind the stance leg and is placed
strictly in front of the stance leg at impact and
HGW7) walking is from left to right and takes place on a level surface.
In particular, Hypotheses HGW5 and HGW6 impose the swapping of the roles of the
two legs at impact so that walking does not consist of rocking back and forth on the same
support leg. The symmetric nature of the gait is a natural requirement for a simple walking
motion, but is not a necessary condition for applying the methods.
Remark: Hypotheses HR1 and HR2 imply the robot has (N+2)-degrees of freedom (DOF) (N
joint angles plus the Cartesian coordinates of the hip, for example). Hypothesis HGW2
implies that in single support, the robot has N-DOF (the N joint angles, for example).
Hypotheses HR4, HR5 and HGW2 imply that in single support, the robot has one degree of
under actuation, i.e., one less actuator than DOF.
2.1.3. Rigid Impact Model Hypotheses
An impact occurs when the swing leg contacts the ground. The impact is modelled as
a contact between two rigid bodies. There are many rigid impact models in the literature and
all of them can be used to obtain an expression for the generalized velocity just after the
13
impact of the swing leg with the walking surface in terms of the generalized velocity and
position just before the impact. The model from [24] is used here for walking. The model is
essentially identical in the two cases. The one difference is noted in the list of hypotheses:
HI1) an impact results from the contact of the swing leg end with the ground;
HI2) the impact is instantaneous;
HI3) the impact results in no rebound and no slipping of the swing leg;
HI4) in the case of walking, at the moment of impact, the stance leg lifts from the ground
without interaction (after impact the vertical component of the velocity of the swing leg end
must be positive.);
HI5) the externally applied forces during the impact can be represented by impulses;
HI6) the actuators cannot generate impulses and hence can be ignored during impact and
HI7) the impulsive forces may result in an instantaneous change in the robot's velocities, but
there is no instantaneous change in the configuration.
2.1.4. Some Remarks on Notation
While developing the dynamic models of walking, the generalized coordinates for the
stance (or single-support) phase will be denoted by
with respect
to the inertial frame. Some points and forces of particular interest are identified in Figure 2.2,
namely, the ends of the stance and swing legs, denoted respectively by
and
, t he
position of the hips,
is easily indicated.
The configuration space of the link is
in the inertial
frame using
:
*
+ *
+ (
) *
+ (2.1)
Where:
(
) *
(
) (
)
(
) (
)
+
(2.2)
The velocity of the link in the inertial frame is given by
15
*
+ *
+ *
+ (
) *
(2.3)
Where
*
+
(2.4)
That is
*
(
) (
)
(
) (
)
+
*
+ *
(
) (
)
(
) (
)
+
(2.5)
When the link is free, its configuration and velocity can take on any value in
link and one says that the link has 3 DOF. Recall that it is assumed that a link has
nonzero mass, length, and moment of inertia about the centre of mass. The position of the
centre of mass of link i in the world frame can be expressed as:
*
+ *
+ (
) *
+
(2.6)
And its velocity is given by
*
+ *
+ *
+ (
) *
(2.7)
The position and velocity of the centre of mass will now be used to determine the
potential energy and kinetic energy of a link. Potential energy of one link is simply:
(2.8)
Where
represents vertical position of the centre of mass of link i (assuming that the gravity is
directed downward along the vertical axis of the inertial frame).
Kinetic energy is defined as:
((
(2.9)
The moment of inertia about the centre of mass of link i is denoted by
.
2.2.2. Kinetic and potential energy of N links in the case of pinned open kinematic chains
In the case of N links, one could simply sum up the Eq. (2.8) and Eq. (2.9) for
links to compute the total potential and the total kinetic energy.
Given the set of generalized coordinates,
+ *
+
(2.10)
And the velocities are computed, via the chain rule
16
*
+ (
+)
(2.11)
The first ingredient required to calculate the Lagrangian is the total potential energy of
the robot. Calculation of the potential energy is considerably less complicated than calculation
of the kinetic energy.
Substituting Eq. (2.10) into Eq. (2.8), the total potential energy results:
(2.12)
Where
((
(2.13)
denotes the moment of inertia about the centre of mass of link i. Total kinetic energy is:
(2.14)
The total kinetic energy is always a positive definite, quadratic function of the
generalized velocities, and can be written as:
(2.15)
Where
(2.17)
Where are joint torques and other non-conservative forces affecting the i
th
generalized coordinate.
17
If the kinetic energy is quadratic, then Eq. (2.17) becomes a second-order differential
equation, which is a general equation:
(2.18)
It is denoted
(2.19)
Where
and
and
(2.20)
Eq. (2.20) is rewritten in state space form:
[
]
] (2.21)
A normalized form is given, and
.
(2.22)
The input torque is denoted by
.
18
Figure 2.4. The model is indicated in: a) Generalized coordinates b) Body coordinates
It is clear that not all configurations of the model are compatible with our notion of the
single support phase of walking. For example, with the exception of the end of the stance leg,
all points of the robot should be above the walking surface, and for human-like walking, the
knees should not hyperextend. In addition, there are kinetic constraints, such as, for the leg
end to act like a pivot, the forces on the leg end must lie in the static friction cone, and the
normal component of the reaction force must be positive.
Consider
parameterizes the stance leg,
inertia matrix,
Coriolis matrix,
which maps the joint torques to generalized forces are given in below in Eq. (2.23), Eq.
(2.24), Eq. (2.25) and Eq. (2.26):
(2.23)
(2.24)
(2.25)
[
]
(2.26)
19
2.4. Dynamic model of walking: impact model
The impact between the swing leg and the ground is modelled as a contact between
two rigid bodies. The standard model from [24] is used. The motion of the robot is only
analysed for the case that the contact of the swing leg with the ground results in no rebound
and no slipping of the swing leg and the stance leg naturally lifting from the ground without
interaction [21]. The conditions for these assumptions to be valid will be indicated.
The contact model requires the full five degrees of freedom of the robot. Let
be the
generalized coordinates used in the single support model and complete these to a set of
generalized coordinates for the unpinned model by letting
be the Cartesian
coordinates of some fixed point on the robot or its centre of mass. Using the generalized
coordinates
(2.27)
The external forces acting on the robot at the contact point(s) is represented by
.
The basic premises in [24] are that:
the impact takes place over an infinitesimally small period of time;
the external forces during the impact can be represented by impulses;
impulsive forces may result in an instantaneous change in the velocities of the
generalized coordinates, but the positions remain continuous;
the torques supplied by the actuators are not impulsional.
With these assumptions, Eq. (2.27) is "integrated" over the "duration" of the impact to
obtain:
(2.28)
Where
, as is affirmed by
Hypothesis HI7.
By definition, the velocity just before impact is determined from the single support
model. During the single support phase,
; denote this by
. Thus:
]
(2.29)
From Hypothesis HI4,
denote the position of the end of the swing leg with respect to the
inertial frame, it follows from the principle of virtual work that
(2.30)
Where,
and
and
and
. In order to be able to
solve for all of the unknowns, the above equations must be augmented with additional
equations that proscribe what happens at the two contact ends. Since the stance leg is assumed
to detach from the ground without interaction, the external forces acting at the pivot point are
zero. The two additional required equations come from the no slip and rebound condition of
Hypothesis HI3:
20
(2.31)
The impact equations Eq. (2.28) and Eq. (2.31), taken together, become
[
] *
+ *
+
(2.32)
Where,
(2.33)
This has the entries as in [20]:
The solvability of Eq. (2.32) is equivalent to the invertibility of the matrix on the left
hand side. The invertibility of this matrix follows from the fact that D
e
is positive definite and
E has full rank; indeed, the determinant of the left hand side of Eq. (2.28) can be computed to
be
This is non-zero everywhere.
The result of solving Eq. (2.28) and Eq. (2.31) yields an expression for
in term
of
, which should then be used to re-initialize the model Eq. (2.25). The coordinates must
be relabelled because the roles of the legs must be swapped: the former swing leg is now in
contact with the ground and is poised to take on the role of the stance leg. The result of the
impact and the relabeling of the states is then an expression
(2.34)
21
Where
expressed in terms of
, and pick-off
; since
only depends on
expressed as a function of
.
Step 2: transform the coordinates so that
(2.35)
In conclusion there are some remarks: (a) Computing in closed form would mean
inverting a matrix; hence this is only done numerically, (b) The no-rebound, no-slip
condition of the impact, ensures that the impact results in the end of the swing leg being at
rest, and hence, after doing the coordinate transformation, the end of the stance leg will be at
rest, (c) For the impact model to be valid, it must be verified a posteriori that no-slipping
was a valid assumption (that is |
(2.36)
The switching set is chosen to be {
} which
is considered in our specific case
, where
is the desired
stance leg angle. In simple words, a trajectory of the robot is specified by the mechanical
model until an impact occurs. Impact occurs when the state "attains" the set S , which
represents the walking surface. In order for the swing leg end to be at ground level at the end
of the step, it must be the case that:
At this point, the impact with the surface results in a very rapid change in the velocity
components of the state vector. The impulse model of the impact compresses the impact event
into an instantaneous moment in time, resulting in a discontinuity in the velocities. The
ultimate result of the impact model is a new initial condition from which the mechanical
model evolves until the next impact. In order for the state not to be obliged to take on two
values at the "impact time", the impact event is, roughly speaking, described in terms of the
values of the state "just prior to impact" at time
. These
values are represented by the left and right limits,
and
respectively.
A step of the robot is a solution of Eq. (2.35) that starts with the robot in double
support, ends in double support with the configurations of the legs swapped, and contains
only one impact event. Walking is a sequence of steps.
22
Figure 2.5. Hybrid model of walking with point feet
The above figures key elements are the continuous dynamics of the single support
phase, written in state space form as
(2.38)
This condition establishes the Poincar section. The discrete map obtained by
following the procedure described above can be written in the following general form:
(2.39)
24
Note that is a reduced dimension state vector, and the subscripts denote the i
th
and (i
1)
th
return values, respectively. Periodic motions of the biped correspond to the 6xed points
of P where
(2.40)
Where
is the k
th
iterating. The stability of
, of the
linearized map,
(2.41)
Have moduli less than one. This technique employed by numerous researchers has
several advantages. Using this approach the stability of gait conforms to the formal stability
definition accepted in nonlinear mechanics. The eigenvalues of the linearized map provide
quantitative measures of the stability of bipedal gait. Finally, to apply the analysis to
locomotion one only requires the kinematic data that represent all the relevant degrees of
freedom. No specific knowledge of the internal structure of the system is needed. This feature
also makes it possible to extend the analysis to the study of human gait.
25
Chapter 3. Feedback control of a biped
The method of computed torque, also known as inverse dynamics, is ubiquitous in the
field of robotics. It consists of defining a set of outputs, equal in number to the inputs, and
then designing a feedback controller that asymptotically drives the outputs to zero.
3.1. MIMO system
In the following the Multiple Input Multiple Output system will be introduced, outputs
will be defined and later on the controlling factors will be chosen.
Many real world systems are non-linear. And more often they are Multiple Input-
Multiple Output based systems, which one can run up against with daily basis, even though
the person did not realise.
MIMO systems are typically more complex than SISO systems. The interactions of the
dynamics make simple linear predictions of system performance difficult. For MIMO systems
the SISO frequency domain techniques require some adjustment.
SISO techniques exist for transfer functions and state equations. The same is true for
MIMO. However, most of the effort and focus is on state equations for MIMO and transfer
functions for SISO.
However, the focus in MIMO control system theory appears to be on optimal and
robust controls which involve designing a controller that minimizes a cost function. An
example cost function would energy required for control (in our specific case).
Often these optimal and robust techniques require full observability of all states and so
a state estimator is required. The most common state estimator is the Kalman Filter, which is
used also by Matlabs Model Predictive Control Toolbox. The Kalman filter produces
estimates of the true values of measurements and their associated calculated values by
predicting a value, estimating the uncertainty of the predicted value, and computing a
weighted average of the predicted value and the measured value.
The Multi Input Multi Output system of the biped robot model can be seen at Figure
3.1 . Two torques are applied between the legs and the torso and the outputs will be defined as
follows in the next paragraphs.
Figure 3.1. High level view of the present MIMO system
3.2. The controlled variables
At the most basic level, walking consists of two things: posture control, that is,
maintaining the torso in a semi-erect position, and swing leg advancement, that is, causing the
swing leg to come from behind the stance leg, pass it by a certain amount, and prepare for
contact with the ground. This motivates the direct control of the angles
(describing the
torso) and
(describing the swing leg). In a normal walking motion, it is clear that the
horizontal motion of the hips is monotonically strictly increasing. For the three-link walker
strictly increasing at every step of the walking cycle. Thus, for any desired trajectories
and
that express a desired walking pattern for the biped, it is therefore reasonable
26
to assume that the corresponding trajectory for
is strictly
monotonic.
The simplest version of posture control is to maintain the angle of the torso at some
constant value, say
. Thus the
behavior of walking can be encoded into the dynamics of the robot by defining outputs with
the control objective being to drive the outputs to zero as it can be seen in Eq. (3.1). Driving y
to zero will force
and
(here,
being a constant).
*
+ [
] [
] (3.1)
With the outputs defined as in Eq. (3.1), suppose that the desired inclination angle of
the torso is
, as it
is assumed in the simulation.
The virtual constraints selected in Eq. (3.1) have the advantage of being simple and
intuitive. They do not, however, provide very much design freedom. The only parameter that
may be varied is the torso lean angle, which can be used to vary walking speed to a certain
extent, but there is no possibility of minimizing torque requirements for a given walking
speed, for example. For this reason, [30] considers a set of outputs of the form
*
+ [
]
(3.2)
Where
(3.3)
(3.4)
The rather particular form of
) 1, which is the condition needed for the swing leg end to have height zero
at impact. A gradient descent algorithm was used to minimize the cost function, initialized at
values of the parameters for which the new outputs were equivalent to the original outputs
with
; see Table 2. The process of minimizing the integral of squared torque also
fortuitously reduced the peak torque magnitude [30].
Original values
Optimized values
Table 2 Optimizing the virtual constraints for minimal energy consumption
In the following sections it will be introduced the feedback control principle, just to
have a rough idea of it. This section identifies the swing phase zero dynamics for a particular
class of outputs that has proven useful in constructing feedback controllers for bipedal
walkers. The purpose of this is that the preliminary study phase of the biped robot
locomotion, based on the work of Grizzle et al. [20].
27
3.3. The zero dynamics of walking
A geometric task for the robot may be encoded into a set of outputs in such a way that
the zeroing of the outputs is asymptotically equivalent to achieving the task, whether the task
is asymptotic convergence to an equilibrium point, a surface, or a time trajectory. For a
system modelled by ordinary differential equations (in particular, without impact dynamics),
the maximal internal dynamics of the system that is compatible with the output being
identically zero is called the zero dynamics. Hence, the method of computed torque can be
seen as an indirect means of designing a set of zero dynamics for the robot.
Since, in general, the dimension of the zero dynamics is considerably less than the
dimension of the model itself, the task to be achieved by the robot is implicitly encoded into a
lower-dimensional system.
One of the main points of [31] is that this process can be explicitly exploited in the
design of feedback controllers for walking mechanisms, even in the presence of impacts.
This following section identifies the swing phase zero dynamics for a particular class
of outputs that have proven useful in constructing feedback controllers for bipedal walkers
Since no impact dynamics are involved, the work here is simply a specialization of the
general results. The results summarized here will form the basis for defining a zero dynamics
of the complete hybrid model of the planar biped walker, which is the desired. Note that if an
output depends only on the configuration variables, then, due to the second order
nature of the robot model, the derivative of the output along solutions does not depend
directly on the inputs. Hence its relative degree is at least two. Differentiating the output once
again computes the accelerations, resulting in
(3.5)
The matrix
, the decoupling
matrix
is a diffeomorphism onto its image;
HH4) there exists at least one point in
where vanishes.
Then,
1. {
. is
called the zero dynamics manifold and is called the zero dynamics.
From hypotheses HH1 and HH3, is a valid coordinate transformation on
and thus
(3.6)
28
(3.7)
Is a coordinate transformation on
(3.8)
(3.9)
Where is evaluated at
(3.10)
(
+
(3.11)
Enforcing results in (
(3.12)
While it is useful to know that the zero dynamics can be expressed as a second order
system, this form of the equations is very difficult to compute directly due to the need to
invert the decoupling matrix. However, this can be avoided. In a neighbourhood of any point
where the decoupling matrix is invertible, there exists a smooth scalar function such that
(3.13)
Is a valid coordinate transformation and
.
In the coordinate of Eq. (3.13), the zero dynamics become
(3.14)
Where there right hand side is evaluated at
(3.15)
(
]
(3.16)
3.4. Computed torque with finite-time feedback control:
Bernstein-Bhat controller
Since no impact dynamics are involved, the work here is simply a specialization of the
general results to a model of the form in Eq. (2.21) and an output that is independent of the
velocity. The results summarized here will form the basis for defining a zero dynamics of the
complete hybrid model of a planar bipedal walker.
The period of a step is finite, so controller should settle the system in finite time. The
control objective is considered as driving the outputs to zero. Since the outputs only depend
on the generalized positions, and the dynamical model is second order the relative degree of
each output component is at least two. Note that an output is of the form:
29
The derivative of the output along solutions of (5.29) does not depend directly on the inputs:
(3.17)
[
] [[
[ ]
]
]
(3.18)
[
] [
[ ]
]
] *
(3.19)
(3.20)
Because
] *[
[ ]
] *
+ +
(3.21)
[
] [
[ ]
]
(3.22)
(3.23)
In which was used standard Lie derivative notation, as the final calculation yields:
(3.24)
The matrix
(3.25)
The nonlinear system can be linearized as a double integral system and the controller
will be referred later on as a Bernstein-Bhat controller. The feedback functions are:
[
]
(3.26)
(3.27)
Where
is invertible. Let
and
be
positive definite matrices and let be a positive scalar tuning
parameter, as in [21]. Then the feedback is:
)
(3.28)
Eq. (3.16) applied to the swing phase portion of (2.35) results in:
(3.29)
The solutions of Eq. (3.28) converge exponentially to zero. In bipedal walking, the
impact map tends to increase the norm of at each impact. The parameter provides control
over the speed with which and converge to zero during the continuous phase, so
that, over a cycle consisting of an impact event followed by a swing phase, the contraction
taking place in the swing phase dominates the expansion coming from the impact. In this way,
the solution of the closed-loop system may converge to the hybrid zero dynamics, and hence
to an exponentially stable periodic orbit of the hybrid zero dynamics, as is defined more
rigorously in [21].
3.6. Comparison of the two controllers
Below one can find a graphical representation of the inputs and the outputs of the
MIMO system controlled through the two controllers introduced already, proportional and
derivative gains were tuned in order to achieve better performance (smaller settling time and
less overshoot).
As it can be seen (in Figure 3.2 respectively Figure 3.3) two torques are applied on the
system resulting two positions (Figure 3.4), measured in radian (y
1
, y
2
). Y1_BB refers to the
first output generated over three steps by the Bernstein-Bhat controller, similarly Y2_BB.
Y1_FL is denoted the first response of the system due to de feedback linearized controller.
Refer to Y2_FL in the same way.
The aim of this preliminary study was a better understanding of the nonlinear system
and to conclude a few things. Firstly as it can be clearly seen that after a rigorous tuning of the
parameters from Eq. (3.9) the nonlinear system has a better behaviour as the original
Bernstein-Bhat controller. In this specific case as shown in Figure 3.4 the derivative and
proportional gains are
respectively
.
Secondly the simulation of the biped results in a much smoother walking cycle. The
stability was fulfilled in both cases.
31
Figure 3.2. The inputs applied in the case of Bernstein Bhat controller
Figure 3.3. The inputs applied in the case of the feedback linearized controller
There is another representation of the outputs (with the same controllers), but this time
it is illustrated during five walking steps (Figure 3.5). It is shown the settling time positions,
in order to be able to calculate it. In these cases of the classical controls the settling time of
the outputs was around 30% respectively 34% of one step duration.
0 0.5 1 1.5 2 2.5 3 3.5
-60
-50
-40
-30
-20
-10
0
1
(
N
m
)
Control Signals
0 0.5 1 1.5 2 2.5 3 3.5
-50
-40
-30
-20
-10
0
10
20
2
(
N
m
)
time (sec)
0 0.5 1 1.5 2 2.5 3 3.5
-60
-50
-40
-30
-20
-10
0
1
(
N
m
)
Control Signals
0 0.5 1 1.5 2 2.5 3 3.5
-250
-200
-150
-100
-50
0
50
2
(
N
m
)
time (sec)
32
Figure 3.4. Output of the MIMO system during three steps
Figure 3.5. Output of the MIMO system during five steps
0 500 1000 1500 2000 2500 3000
-0.05
-0.04
-0.03
-0.02
-0.01
0
0.01
0.02
0.03
X: 114
Y: -0.001411 Y
1
t
X: 520.2
Y: 7.939e-009
X: 180
Y: 0.0002322
Y1_BB
Y1_PD
0 500 1000 1500 2000 2500 3000
-0.05
-0.04
-0.03
-0.02
-0.01
0
0.01
X: 524.5
Y: -0.0001659
Y
1
t
X: 204.3
Y: -4.595e-005
X: 158.2
Y: -0.0003146
Y2_BB
Y2_PD
33
Chapter 4. Model predictive control of nonlinear plant
Model Predictive Control, or MPC, is an advanced method of process control that has
been in use in the process industries since the 1980s. Model predictive controllers rely on
dynamic models of the process, most often linear empirical models obtained by system
identification.
Despite the fact that most real processes are approximately linear within only a limited
operating window, linear MPC approaches are used in the majority of applications with the
feedback mechanism of the MPC compensating for prediction errors due to structural
mismatch between the model and the process. In model predictive controllers that consist only
of linear models, the superposition principle of linear algebra enables the effect of changes in
multiple independent variables to be added together to predict the response of the dependent
variables. This simplifies the control problem to a series of direct matrix algebra calculations
that are fast and robust.
MPC will be applied to the nonlinear mathematical model, but not before linearization.
The three link biped robot model will be used for simulation purposes, introduced in Chapter
2, in order to maintain his torso at some constant angle.
4.1. Introduction
Model Based Predictive Control (MBPC) is a control methodology developed around
certain common key principles. Two of these principles are:
Explicit on-line use of a process model to forecast the process output at future time
instants;
Calculation of an optimal control action based on the minimization of one or more
cost functions, possibly including constraints on the process variables.
The various algorithms, members of the large MBPC-family, differ mainly in:
The type of model used to represent the process and its disturbances,
The cost function(s) to be minimized, with or without constraints.
The MBPC-strategy is simple to understand and makes good practical sense:
Use the process model to predict the evolution of the process output as a function of
future (intended) control actions and
Minimize (over these control actions) a specified cost index; this cost includes the
errors between desired and predicted process outputs, and possibly also the required
control effort.
Model Predictive Control (MPC) possesses many attributes which makes it a
successful approach to industrial control design:
Simplicity: the basic ideas of MPC do not require complex mathematics and are
intuitive.
Richness: all of the basic MPC components can be tailored to the details of the
problem in hand.
Practicality: it is often the resolution of problems such as satisfying control- or output
constraints, which determines the utility of a controller.
Demonstrability: it works, as shown by many real applications in industry where MPC
is routinely and profitably employed.
34
At present MPC is the most widely used multivariable control algorithm in the process
industry. While MPC is suitable for almost any kind of problem, it displays its main strength
when applied to problems with:
A large number of manipulated and control variables.
Constraints imposed on both the manipulated and controlled variables.
Changing control objective and/or equipment (sensor/actuator) failure.
Time delays.
Industrial developments in Europe (MAC: Richalet 1978) and in the USA (DMC:
Cutler 1980) resulted around 1980 in the first commercial control packages using explicitly a
process model to predict and to control the process variables. Simultaneously (although
independently) some European academic research groups, with a strong history in adaptive
prediction and control, started the development of controllers based on multistep predictors
(EPSAC: De Keyser 1981; EHAC Ydstie 1984; MUSMAR: Mosca 1984; GPC: Clarke 1987)
as stated in [33].
These names are only stated to be indicative and represent a few of the (earlier) MBPC
algorithms. Since the beginning of the 1990s, a real boom in the number of industrial MBPC
applications has been reported (first in the USA and Japan, later also in Europe), in parallel
with a dramatic increase of the academic research activity on MBPC-related topics.
Today, commercial MPC packages typically contain tools for model identification and
analysis, controller design and tuning, as well as controller performance evaluation. The
commercially available packages include:
FLSmidth Automation ECS/Process Expert for Cement and Mineral Applications
Connoisseur control and identification package (Invensys)
INCA (linear, non-linear, Batch) from IPCOS
Pavilion8 (Pavilion Technologies)
ADMC & DMCX1 (both Cutlertech)
DMC Plus (Aspen Technology)
RMP(Honeywell)
3dMPC & Expert Optimizer (both ABB)
DeltaV Predict and PredictPRO (Emerson)
APC Library (Siemens|PCS 7)
MACS (Capstone Technology)
eMPC (eposC) and Control Station's LOOP-PRO
ControlMV, PharmaMV and WaterMV from Perceptive Engineering
MATLAB Model Predictive Control Toolbox
Prime (RandControls)
4.2. MPC principle
Model Predictive Control is a form of control in which the current control action is
obtained by solving on-line, at each sampling instant, a finite horizon open-loop optimal
control problem, using the current state of the plant as the initial state; the optimization yields
an optimal control sequence and the first control in this sequence is applied to the plant.
At time the current plant state is sampled and a cost minimizing control strategy is
computed (via a numerical minimization algorithm) for a relatively short time horizon in the
future:[ ] Specifically, an online or on-the-fly calculation is used to explore state
trajectories that emanate from the current state and find (via the solution of Euler-Lagrange
equations) a cost-minimizing control strategy until time . Only the first step of the
control strategy is implemented, then the plant state is sampled again and the calculations are
35
repeated starting from the now current state, yielding a new control and new predicted state
path. One can see the principle of Model Predictive Control in Figure 4.1.
Figure 4.1. MPC principle
Referring to Figure 4.1, the MBPC principle is characterized by the following strategy,
as in [33]:
At each current moment t (whi ch is k on the above fi gure) , the process output
is predicted over a time horizon. The value is called the prediction horizon. The
prediction is done by means of a model of the process; it is assumed that this model is
available. The forecast depends on the past inputs and outputs, but also on the future
control scenario |(i.e. the control actions that is intended to apply from the
present moment on);
A reference trajectory |, starting at | and evolving towards
the set point, is defined over the prediction horizon, describing how it is wanted to
guide the process output from its current value to its set point; in case the process has
a time-delay (dead-time), it is reasonable to start the reference trajectory after the time-
delay;
The control vector |is calculated in order to minimize a specified cost
function, depending on the predicted control errors | |;
Also, in most methods there is some structuring of the future control law
|and there might also be constraints on the process variables;
The 1
st
element | of the optimal control vector | is actually applied to
the real process. All other elements of the calculated control vector can be forgotten,
because at the next sampling instant all time-sequences are shifted, a new output
measurement is obtained and the whole procedure is repeated;
This leads to a new control input | , which is generally different from the
previously calculated |; this approach is called the receding horizon principle.
In above strategy, some important elements characterizing MBPC can be recognized:
prediction by means of a process model;
specification of a reference trajectory;
structuring of the future (postulated) control law;
definition of a cost function (and constraints);
calculation of the optimizing control scenario.
36
Figure 4.2. MPC strategy as a block scheme
The prediction horizon keeps being shifted forward and for this reason MPC is also
called receding horizon control. Although this approach is not optimal, in practice it has given
very good results. Much academic research has been done to find fast methods of solution of
Euler-Lagrange type equations, to understand the global stability properties of MPCs local
optimization, and in general to improve the MPC method. To some extent the theoreticians
have been trying to catch up with the control engineers when it comes to MPC.
4.3. Predictive Control of MIMO Systems
For simplicity of illustration the predictive control systems can be designed based on a
Single Input Single Output system. These are not the case here, but in order to have a better
understanding, please refer to [34]. The simple SISO case can be readily extended to Multi
Input Multi Output systems without much additional effort, because of the state-space
formulation.
4.3.1. General Formulation of the Model
Assume that the plant has m inputs, q outputs and n1 states. It is also assumed that the
number of outputs is less than or equal to the number of inputs (i.e., q m). If the number of
outputs is greater than the number of inputs, one cannot hope to control each of the measured
outputs independently with zero steady-state errors. In the general formulation of the
predictive control problem, one can also take the plant noise and disturbance into
consideration.
(4.1)
(4.2)
Where is the input disturbance, assumed to be a sequence of integrated white
noise. This means that the input disturbance is related to a zero-mean, white noise
sequence by the difference equation:
(4.3)
37
Note that from Eq. (4.1), the following difference equation is also true:
(4.4)
By defining
(4.5)
In order to relate the output to the state variable
, it is deduced that
(4.6)
Where .
Choosing a new state variable vector [
:
[
]
[
] [
] [
]
[
]
(4.7)
[
] [
]
(4.8)
Where
and
have dimension
, and , respectively.
For notational simplicity, it is denoted Eq. (4.6) by
(4.9)
Where A, B and C are matrices corresponding to the forms given in (1.38). In the
following, the dimensionality of the augmented state-space equation is taken to be
.
There are two points that are worth investigating here. The first is related to the
eigenvalues of the augmented design model. The second point is related to the realization of
the state-space model. Both points will help us understand the model.
4.3.2. Eigenvalues of the augmented model
Note that the characteristic polynomial equation of the augmented model is:
*
(4.10)
Here it is used the property that the determinant of a block lower triangular matrix
equals the product of the determinants of the matrices on the diagonal. Hence, the eigenvalues
of the augmented model are the union of the eigenvalues of the plant model and the
eigenvalue, . This means that there are integrators embedded into the augmented
design model. This is the means it is used to obtain integral action for the MPC systems.
38
4.3.3. Controllability and Observability of the Augmented Model
Because the original plant model is augmented with integrators and the MPC design is
performed on the basis of the augmented state-space model, it is important for control system
design that the augmented model does not become uncontrollable or unobservable,
particularly with respect to the unstable dynamics of the system. Controllability is a pre-
requisite for the predictive control system to achieve the desired closed-loop control
performance and observability is a pre-requisite for a successful design of an observer.
However, the conditions may be relaxed to the requirement of stabilizability and detectability;
if only closed-loop stability is of concern. A system is stabilizable if its uncontrollable modes,
if any, are stable. Its controllable modes may be stable or unstable. A system is detectable, if
its unobservable modes, if any, are stable. Its observable modes may be stable or unstable.
Stable modes here means that the corresponding eigenvalues are strictly inside the unit circle.
Because the augmented model introduced additional integral modes, one needs to
examine under what conditions these additional modes become controllable. The simplest
way for the investigation is based on the assumption of minimal realization of the plant
model. The discussion of minimal realization, controllability and observability can be found
in control textbooks.
4.3.4. Solution of Predictive Control for MI MO Systems
The extension of the predictive control solution is quite straightforward, and one needs
to pay attention to the dimensions of the state, control and output vectors in a MIMO
environment. Define the vectors Y and U as
[
(4.11)
[
(4.12)
Based on the state-space model (A, B, C), the future state variables are calculated
sequentially using the set of future control parameters:
)
(4.13)
With the assumption that
(4.14)
Where
39
[
The incremental optimal control within one optimization window is given by
(4.15)
Where matrix
has dimension
,
and
(4.16)
Where
and
]
]
(4.17)
For simplicity it is further modified:
[
]
(4.18)
The model has six states denoted by
and the acceleration by
. To obtain the speed and the position from them built in integrators
are used.
Figure 4.3. Simulink implementation of the swing phase model
41
The above block is called nonlinear_swing_model. This block will be an integral part
of the linearized model (4.5) and the control structure (4.6). It is based on Eq. (4.18), which is
the state space representation of the Single Support Phase of the biped model. It has two
inputs (
), representing the two torques applied at the hips, one is applied between one
leg and hip, similarly is the second. The Simulink model has four outputs, represented by
by the formula:
45
(4.19)
But since
is an equilibrium point,
.
Extending this to a system to two equations, for example to this autonomous system
{
(4.20)
Then find the partial derivative which constructs the Jacobian:
[
(4.21)
And the least but not last step is finding the eigenvalues of the Jacobian matrix and
deduce the fate of the solutions around the equilibrium point.
The theory presented seems to be easy, and straightforward in simple cases, but is not
the case here (several equations due to the fact that in it are three by three matrices). It is a
possibility to do it by hand, as you can see in the following equations, but is time consuming.
(4.22)
(4.23)
]
(4.24)
Another way would be: use specific computer programs to do this job for you. It was
chosen MATLAB, and one of the toolboxes provided by the company, namely Simulink
Control Design.
46
Simulink Control Design lets you design and analyse control systems modelled in
Simulink. With this product you can also find operating points and compute exact
linearization of Simulink model at various operating conditions. Simulink Control Design
provides tools for computing simulation-based frequency responses without modifying your
model. A graphical user interface (GUI) lets you design and analyse arbitrary control
structures modelled in Simulink.
In order to be able to linearize with the Simulink Control Design, the model
introduced in Chapter 2, one needs a Simulink model whit the exact representation of the
swing phase, introduced before. There was applied two step input 20 respectively -20 (Figure
4.13).
Figure 4.13. Nonlinear model plant
The operating point was selected at the simulation snapshot time (seconds).
The linearized model is given in state space representation below:
[
+
The same model represented as transfer functions in a decoupled way:
Transfer function from input "u1" to output:
(4.25)
(4.26)
Transfer function from input "u2" to output:
(4.27)
(4.28)
47
The state space model will be later used in the feedback simulation together with the
MPC controller.
Simulink Control Design computes the linearized model and visualizes the results in a
step response plot or Bode diagram. A Linearization Inspector is provided to visualize the
impact of each block in the Simulink model on the linearization. In order to be able to
investigate and analyse the behaviour of the linearized system one could apply a step. In
Figure 4.14 it can be seen the responses. It can be observed that oscillations are not present.
Although in the case of highly nonlinear systems it is expectable.
Figure 4.14. Step response generated
4.6. MPC controller design
Model Predictive Control Toolbox provides MATLAB functions, a GUI, and Simulink
blocks for designing and simulating model predictive controllers in MATLAB and Simulink.
These controllers optimize the performance of MIMO systems that are subject to input and
output constraints.
In the toolbox one can use a linearized Simulink model, or specify it directly as a
linear time invariant object, such as a state space model, which is the present case.
So the first step would be to import the linearized model, then to design a controller
for it, and finally make a pre-simulation, in order to see the response.
Step Response
Time (sec)
A
m
p
l
i
t
u
d
e
0 0.2 0.4 0.6 0.8 1
From: u2 load
0 0.2 0.4 0.6 0.8 1
0
0.1
0.2
0.3
0.4
T
o
:
n
o
n
l
i
n
e
a
r
s
w
i
n
g
m
o
d
e
l
/
2
-1
-0.8
-0.6
-0.4
-0.2
0
From: u1 load
T
o
:
n
o
n
l
i
n
e
a
r
s
w
i
n
g
m
o
d
e
l
/
1
48
Figure 4.15. MPC scheme of the Model Predictive Control Toolbox
The input (torques) and output (positions) signals and their properties are represented
below, as it can be seen in the toolbox:
Figure 4.16. Signal properties in MPC toolbox
In the following section it is presented the controller design in a few steps. One of the
most important parameters of the MPC controller is the control interval, prediction horizon
and control horizon. These parameters can be varied until one has a better performance
through simulations.
The values used in the MPC controller design are the following:
control interval (the sampling time): 0.004 (time units);
prediction horizon : 120 (intervals);
control horizon : 60 (intervals).
The prediction horizon of an MPC needs to be long enough to capture the major
dynamics of the plant. In practice typically the prediction horizon approximately coincides
with the settling time of the system. As it is known from the studied controllers and analysis
in Chapter 3, the simulation duration of one step is 1.128 seconds. And according to Figure
3.4 the settling time of the outputs it is around 0.45 seconds. That is the reason for why the
horizons were chosen in such way (the prediction horizon times control interval equals 0.48).
After choosing these parameters, it is the time to talk about the constraints. The
constraints of the manipulated variables were set as a minimum of -500 and as a maximum of
500, of course after doing some simulations.
49
Figure 4.17. Simulated MPC controller inputs
Constrains of the input variables were chosen also according to the preliminary study
in Chapter 3, as it never goes below -0.5, and above 0.5. To have some more freedom it was
used -1 as minimum, and 1 as maximum.
Least but not last, the weight of the controller is 0.95, which is the ratio between
robustness and faster response. It was tuned according the preliminary simulations which
were taken place in the Model Predictive Control Toolbox.
Preliminary simulations take place in a time interval of 0-1.2, which is approximately
equal with one step duration.
Concluding the fact that simulated MPC is fast enough to keep our system stable, one
can see in Figure 4.17 that the MPC controller behaves normally, meaning that it has a peak
input in the beginning, then reaches a low input then it settles.
In Figure 4.18 one can see the two outputs of the simulated MPC controller, with the
set points: 0.5236 and 0.3927. As it is visible, in order to keep the settling time as low as
possible (around 0.45 seconds) the responses have some considerable low overshoots, the first
approximately 3 % and the second is around 8%.
Figure 4.18. Simulated MPC controller outputs
-100
-50
0
50
100
150
u
1
0 0.2 0.4 0.6 0.8 1 1.2
-30
-20
-10
0
10
20
30
u
2
Plant Inputs
Time (sec)
0
0.2
0.4
0.6
0.8
o
u
t
p
u
t
1
0 0.2 0.4 0.6 0.8 1 1.2
0
0.1
0.2
0.3
0.4
0.5
o
u
t
p
u
t
2
Plant Outputs
Time (sec)
50
4.7. Simulation of the nonlinear model with MPC controller
As it was mentioned before the Matlabs control toolbox was used for linearization.
The hybrid model introduced in Eq. (2.29) was used, more specifically the state space
representation of the swing phase model (SSP), Eq. (2.21), which is implemented in the
noninear_swing_model in Figure 4.19.
The MPC designed in 4.6 was used for simulation. The purpose of the present
simulation is to obtain valid inputs which are introduced later on in a graphical simulation,
which simulates the biped in two dimensions, along with some useful graphs (position and
velocity changes, forces acting on the end of the leg along with the torques applied).
The model introduced in Simulink can be seen in Figure 4.19. In 4.4 is represented
more in detail the noninear_swing_model. Simulink predefined blocks were used to save the
data (inputs, outputs of the system) to the workspace.
When the simulation starts, MATLAB converts the model to discrete time, and also it
is assumed white noise on each measured output channel.
Figure 4.19. Simulink representation of swing phase dynamics together with MPC controller
In order to be able to run the model it is necessary to set some initial parameters (the
length and mass of the leg, mass of the hips and torso, the distance between the hips and torso,
and the acceleration due to gravity are defined according to Table 1) and initial positions and
velocities of the swing phase model defined in Eq. (2.21), as it can be seen in Figure 4.20.
The Simulink has a built in call-back functions, which are a way of customize
Simulink models. A call-back is a function that executes when you perform actions on your
model, such as starting a simulation. One can use call-backs to execute an M-file or other
MATLAB command. InitFcn is called at start of the model simulation.
If the sampling time would be lower, for example 0.0014, the simulation takes about
three hours on a Dell notebook which has Windows 7. It can be said that the computation time
rises when the sampling time is decreased, which is normal. That is why the sampling time
was picked to be 0.004 seconds. In this case the simulation takes about five minutes, which is
more preferable.
The discussion of results and the consequences are discussed in the next subchapter.
Please note that the resulting figures are visible also there.
51
Figure 4.20. Initial call-back function associated with model, with initial parameters
4.8. Discussion of the results
In this particular section will be discussed the results of the model predictive control
applied to the linearized plant. To be able to simulate the walking of a biped in two
dimensions it was necessary a simulation program. In order to be able to produce results in
such a short time, it was used a program package written originally by Eric Westervelt. The
package contains eight m files, mainly functions, which can be used to represent the robot in
the 2D workspace. During the work I carried out, the program package suffered slight
modifications. It can be consulted in Appendix A.
Figure 4.21. The two inputs generated by the simulation, after resampling
0 200 400 600 800 1000 1200
-150
-100
-50
0
50
100
150
Number of inputs
t
o
r
q
u
e
Input1
Input2
52
So, as this was said, lets move on to discuss the obtained results in the simulation.
Firstly, in Figure 4.21, it can be seen the two torque inputs expressed in Nm (Newton-meter).
These inputs were generated by the simulation discussed in 4.7. These vectors were applied as
input to the simulation in the program package, mentioned earlier. Please note that the inputs
were resampled, as it will be debated later.
The resulting behaviour of the three link biped was a stable one step walk. Please note
that in the following all the figures are referring to a single step, from a walk cycle, in order to
be suggestive.
Figure 4.22. Resulting outputs during one step after the 2D simulation
The resulting outputs are on Figure 4.22. Settling time for the first output is around
0.11 second, for the second its 0.28. Which are much better results obtained whit feedback
control discussed in Chapter 3. More specifically one should notice the obvious differences
between Figure 3.4 and Figure 4.22. It is clear that the MPC controlled MIMO system
behaves much better.
On the next picture (Figure 4.23) it is visualised the forces acting on the stance leg.
For calculations it was used Eq. (2.32) introduced in Chapter 2.
One should notice that in the beginning of a step it is clearly visible two peaks, on both
forces, namely the tangential and normal forces. This is due to the fact that at the beginning of
the first step the biped mechanics changes from the double support phase to a single support
phase. And his whole body weight concentrates on only one leg. Moreover to be able to move
a greater torque is applied between the leg and the hip. As it follows the forces acting on the
leg are greater at beginning, as it is visible as peaks.
Following the states of the biped is crucial, more specifically the joint positions and
their velocities. One can observe it in Figure 4.24. The meanings of the notations are taken
from Figure 2.4. Actually
the torso.
As it is noticeable that the torso position does not vary, which is desired. The position of the
stance and swing leg, namely
and
has a greater slope. That is due to the fact that it is the position of the
swing leg, and because it advances faster to the next position. This fact is obvious: the
0 0.2 0.4 0.6 0.8 1
-0.04
-0.03
-0.02
-0.01
0
0.01
y
1
Outputs
0 0.2 0.4 0.6 0.8 1
-0.02
-0.015
-0.01
-0.005
0
y
2
time (sec)
53
walking would not be possible with only one rigid link legs if both are advancing at the same
speed (Figure 4.24 second part).
Figure 4.23. Forces calculated on the stance leg
Figure 4.24. Graphical representation of the states (positions and states)
As a conclusion it can be stated that the designed MPC is a better controller. It has the
required stability, much lower settling time, and a perfect response, meaning that during
walking the simulated model maintains his semi erect position in a perfect manner.
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1
-400
-200
0
200
400
600
800
1000
1200
Forces on End of Stance Leg
F
tan
(N)
F
norm
(N)
0.2 0.4 0.6 0.8 1 1.2
-0.4
-0.2
0
0.2
0.4
0.6
Joint Positions
3
0 0.2 0.4 0.6 0.8 1
-2
-1
0
1
time (sec)
Joint Velocities
1
(dot)
2
(dot)
3
(dot)
54
Least but not last the biped simulator package is presented in a few world. The
MATLAB code can be consulted in Appendix A. It contains of the following: dynamic model
of the biped; the impact model; and finally controllers. The simulator is able to calculate the
positions, the velocities, the force on the stance leg, along with the inputs, and outputs of the
system. It also consist a real time simulation of the biped represented by Figure 4.25.
Figure 4.25. Three link biped representation in the simulator
55
Chapter 5. Conclusions
The present work proposed a model predictive controller to regulate a highly nonlinear
system, namely walking motion of a three link humanoid robot with point feet.
The control problem of the biped was defined as choosing a proper input such that
the system behaves stable with semi erect torso, and two walking legs.
As the preliminary studies revealed in Chapter 3 the problem of these kinds of MIMO
systems are the strong coupling between the inputs and outputs. In order to have a stable
walking biped one needs a master controller, it is not possible to control the system at low
level each joint separately. While the stability was not considered in this work as a main
objective one should not diminish it.
It was tested the classical control (computed torque with feedback linearization) along
with the MPC control. The comparison was made in a biped simulator package. It can be
stated, as a conclusion, that the proposed controller drives the outputs quicker to zero. In the
cases of the classical controls the settling time of the outputs was around 30% respectively
34% of one step duration. With the improved model predictive controller the output settles
within 8.4% (in the case of the first output) respectively 21% (in the case of the second
output). Note that the outputs were defined in Chapter 3.2. It is a major improvement in
controlling a highly nonlinear system which has multiple inputs multiple outputs. The
preliminary studies were necessary in order to compare those types of controllers which exist
till date with the implemented one.
The goal of the work was successfully fulfilled and implemented. Although a three
link biped with point feet was used, the most simple biped model after the compass one, it
was complicated enough to be able to make investigations and research in this direction.
Future work may aim the extension of the tree link model into five one with knee
(point feet), or a seven link model (with regular feet). That would complicate the things;
mainly the mathematical computations will be intricate. So the calculation time would be
much longer on a personal computer. Thats why is advised to use a more powerful computer,
if the present work will be a basis of a research in the humanoid robot controlling topic.
56
References
[1] B. Siciliano, O. Khatib et al., Springer Handbook of Robotics, Springer,
2008.
[2] M. Vukobratovic, B. Borovac, Zero-moment point - Thirty five years of its
life, International Journal on Humanoid Robot, 2004.
[3] T. McGeer, Passive dynamic walking, Int. J. Robot. Res. 9(2), 1990.
[4] C. Chevallereau, G. Abba, Y. Aoustin, F. Plestan, E.R. Westervelt, C.
Canudas-de-Wit and J.W. Grizzle, RABBIT: a testbed for advanced
control theory, IEEE Contr. Syst. Mag., 2003.
[5] K. Hirai, M. Hirose, Y. Haikawa and T. Takenaka, The Development of
Honda Humanoid Robot, Proc. International Conference on Robotics &
Automation, 1998.
[6] A. Takanishi, M. Ishida, Y. Yamazaki, I. Kato, The realization of
dynamic walking by the biped walking robot WL-10RD, Int. Conf. Adv.
Robot, 1985.
[7] M. Hirose, Y. Haikawa, T. Takenaka, K. Hirai, Development of
humanoid robot ASIMO, IEEE/RSJ Int. Conf. Intell. Robots Syst., 2001.
[8] M. Gienger, K. Lffler, F. Pfeiffer, Towards the design of a biped jogging
robot, IEEE Int. Conf. Robot. Autom., 2001.
[9] K. Kaneko, S. Kajita, F. Kanehiro, K. Yokoi, K. Fujiwara, H. Hirukawa,
T. Kawasaki, M. Hirata, T. Isozumi, Design of advanced leg module for
humanoid robotics project of METI, IEEE Int. Conf. Robot. Autom., 2002.
[10] Y. Sugahara, M. Kawase, Y. Mikuriya, T. Hosobata, H. Sunazuka, K.
Hashimoto, H. Lim, A. Takanishi, Support torque reduction mechanism
for biped locomotor with parallel mechanism, IEEE/RSJ Int. Conf. Intell.
Robots Syst., 2004.
[11] I.W. Park, J.Y. Kim, J. Lee, J.H. Oh, Online free walking trajectory
generation for biped humanoid robot KHR-3(HUBO), IEEE Int. Conf.
Robot. Autom., 2006.
[12] M. Vukobratovic, B. Borovac, D. Surla, and D. Stokic, Biped
locomotion, Springer-Verlag, Berlin, 1990.
[13] R. Katoh and M. Mori, Control method of biped locomotion giving
asymptotic stability of trajectory, Automatica, 1984
[14] G. Cabodevilla, G. Abba, and H. Sage, Energetically near optimal gait for
a biped robot with double supporting phases, Proc. of the Third France-
Japan Congress and First Europe-Asia Congress on Mechatronics, 1996.
[15] G. Cabodevilla, N. Chaillet, and G. Abba,Energy-minimized gait for a
biped robot , Autonome Mobile Systeme, Springer-Verlag, 1995.
[16] J. Furusho and M. Masubuchi, Control of a dynamical biped locomotion
system for steady walking, Journal of DynamicSystems, Measurement, and
Control, 1986.
[17] C. Chevallereau, A. Formal'sky, and B. Perrin, Control of a walking
robot with feet following a reference trajectory derived from ballistic
motion, Proc. of the IEEE International Conference on Robotics and
Automation, 1997.
57
[18] C. Canudas, L. Roussel, and A. Goswani, Periodic stabilization of a 1-dof
hopping robot on nonlinear compliant surface, Proc. of IFAC Symposium
on Robot Control, 1997.
[19] B. Thuilot, A. Goswani, and B. Espiau,Bifurcation and chaos in a simple
passive bipedal gait, Proc. of the IEEE International Conference on
Robotics and Automation, 1997.
[20] J. W. Grizzle, G. Abba and F. Plestan, Asymptotically Stable Walking for
Biped Robots: Analysis via Systems with Impulse Effects, IEEE Transactions
on Automatic Control, 2001.
[21] E. R. Westervelt, J. W. Grizzle, C. Chevallereau,J. H. Choi, and B.
Morris, Feedback Control of Dynamic Bipedal Robot Locomotion, CRC
Press, 2007.
[22] K. Berns, The Walking Machine Catalogue. http://www.walking-
machines.org/.
[23] D. H. Sutherland, K. R. Kaufman, and J. R. Moitoza, Kinematics of
normal human walking, Williams and Wilkins, 1994.
[24] Y. Hrmzl and D. B. Marghitu,Rigid body collisions of planar
kinematic chains with multiple contact points, International Journal of
Robotics Research, 1994.
[25] C.-L. Shih and W. A. Gruver,Control of a biped robot in the double
support phase, IEEE Transactions on Systems, Man and Cybernetics, 1992.
[26] Y. Hurmuzlua, F. Gnot and B. Brogliato, Modeling, stabilityand control
of biped robotsa general framework, Automatica, 2004.
[27] R. Findeisen et al., An Introduction to Nonlinear Model Predictive
Control, 21st Benelux Meeting on Systems and Control, 2002 .
[28] A. Bemporad, M. Morari and N. L. Ricker , Model Predictive Control
Toolbox Users Guide, Online only, 2010.
[29] The Mathworks, SIMULINK: Model-Based and System-Based Design,
Online only, 2001.
[30] J. W. Grizzle, G. Abba, and F. Plestan, Proving asymptotic stability of a
walking cycle for a five DOF biped robot model. In Proc. of the 1999 Int.
Conf. on Climbing and Walking Robots, 1999.
[31] E.R. Westervelt, J.W. Grizzle and D.E. Koditschek, Hybrid Zero
Dynamics of Planar Biped Walkers, IEEE Transactions on Automatic
Control, 2001.
[32] Liuping Wang, Model Predictive Control System Design and
implementation using MATLAB, Springer, 2009.
[33] R. De Keyser, A Gentle Approach to Predictive Control, UNESCO
Encyclopaedia of Life Support Systems, 2003.
[34] Rbert MARC, Abhishek DUTTA and Robin DE KEYSER,
Sophisticated humanoid robot control- poster, Dynamical systems, control
and optimization Study Day, 2010.
58
Appendix A: Biped simulator
% A MATLAB script to simulate a three-link, planar biped walker.
%
% This file is associated with the book Feedback Control of Dynamic
% Bipedal Robot Locomotion by Eric R. Westervelt, Jessy W. Grizzle,
% Christine Chevallereau, Jun-Ho Choi, and Benjamin Morris published
% by Taylor & Francis/CRC Press in 2007.
%
% Copyright (c) 2007 by Eric R. Westervelt, Jessy W. Grizzle, Christine
% Chevallereau, Jun-Ho Choi, and Benjamin Morris. This code may be
% freely used for noncommercial ends. If use of this code in part or in
% whole results in publication, proper citation must be included in that
% publication. This code comes with no guarantees or support.
%
% Eric Westervelt
% 20 February 2007
%
% Robert Marc
% 11 July 2010
% Contributions:
% implementing feedback feedback linearization with parameter tuning
% using MPC inputs for simulation
% optimisation for Matlab 2009b
function varargout = walker_main(t,x,flag,opt_param)
if nargin == 0
flag = 'demo';
end
switch flag
case '' % Return dx/dt = dynamics(t,x).
varargout{1} = f(t,x,opt_param);
case 'events' % Return
[value,isterminal,direction].
[varargout{1:3}] = events(t,x);
case 'demo' % Run a demo.
demo;
otherwise
error(['Unknown flag ''' flag '''.']);
end
%% ------------------------------------------------------------------------
--
%% This is the system dynamics function
function dx = f(t,x,a)
global t_2 torque y force
[D,C,G,B,~,~,~,~,~,H,LfH,dLfH] = dynamics_three_link(x(1:6),a);
Fx = D\(-C*x(4:6)-G);
Gx = D\B;
%
% % Bernstein-Bhat controller (uses feedback linearization)
% v = control_three_link(H,LfH);
%
% % Used for controller that use feedback linearization
% u = (dLfH*[zeros(3,2);Gx])\(v-dLfH*[x(4:6);Fx]);
59
% Used for controller with Linear Feedback Control(P,PD)
epsi=0.1;
% feedback linearization only with kp gain
% kp=1.95; %kp=1.5 - unstable; best solution kp=1.95
% KP=kp*eye(2,2);
% u = -(inv(dLfH*[zeros(3,2);Gx])*(dLfH*[x(4:6);Fx]+1/(epsi^2)*KP*H));
%feedback linearization
kd=10; %to be more robust kp=200 kd=25
kp=15; %the best possible solution without overshoot kd=10, kp=15
KD=kd*eye(2,2);
KP=kp*eye(2,2);
u = -
((dLfH*[zeros(3,2);Gx])\(dLfH*[x(4:6);Fx]+1/epsi*KD*LfH+1/(epsi^2)*KP*H));
%loading MPC inputs from Simulink simulation
load('U_good.mat');
if isempty(U)
u = -
((dLfH*[zeros(3,2);Gx])\(dLfH*[x(4:6);Fx]+1/epsi*KD*LfH+1/(epsi^2)*KP*H));
else
temp =U;
u = temp(1,:);
u=u';
temp(1,:) = [];
U = temp;
save('U_good.mat','U');
temp=[];
end
dx(1:3) = x(4:6);
dx(4:6) = Fx+Gx*u;
dx = dx';
torque = [torque ; u.'];
t_2 = [t_2 ; t];
y = [y ; H.'];
[f_tan,f_norm] = stance_force_three_link(x(1:6),dx(1:6),u);
force = [force ; f_tan f_norm];
%% ------------------------------------------------------------------------
--
%% Locate the time when critical angle of stance leg minus stance leg angle
%% passes through zero in a decreasing direction and stop integration.
function [value,isterminal,direction] = events(t,x)
persistent control_call_cnt
if isempty(control_call_cnt) || (t == 0)
control_call_cnt = 0;
else
control_call_cnt = control_call_cnt + 1;
end
%% th1d -- is the switching angle
%
[~,th1d,~,~] = control_params_three_link;
[r,~,~,~,~,~] = model_params_three_link;
value(1) = th1d-x(1); % when stance leg attains angle of th1d
60
value(2) = r*cos(x(1))-0.5*r; % hips get too close to ground--kill
simulation
isterminal = [1,1]; % stop when this event occurs
direction = [-1,-1]; % decreasing direction detection
%% ------------------------------------------------------------------------
--
%% a demo function
function demo
global t_2 torque y force
torque = [];
t_2 = [];
y = [];
force = [];
Xout=[];
tstart = 0;
tfinal = 6;
%% The optimization parameters
%
a = [0.512 0.073 0.035 -0.819 -2.27 3.26 3.11 1.89];
omega_1 = 1.55;
x0 = sigma_three_link(omega_1,a);
x0 = transition_three_link(x0).';
x0 = x0(1:6);
options = odeset('Events','on','Refine',4,'RelTol',10^-5,'AbsTol',10^-6);
tout = tstart;
xout = x0.';
teout = []; xeout = []; ieout = [];
disp('(impact ratio is the ratio of tangential to normal');
disp('forces of the tip of the swing leg at impact)');
for i = 1:1 % run five steps
% Solve until the first terminal event.
[t,x,te,xe,ie] = ode45('walker_main',[tstart tfinal],x0,options,a);
% Accumulate output. tout and xout are passed out as output arguments
nt = length(t);
tout = [tout; t(2:nt)];
Xout = [Xout;x];
%save('x.mat','Xout');
xout = [xout;x(2:nt,:)];
teout = [teout; te]; % Events at tstart are never reported.
xeout = [xeout; xe];
ieout = [ieout; ie];
% Set the new initial conditions (after impact).
x0=transition_three_link(x(nt,:));
% display some useful information to the user
disp(['step: ',num2str(i),', impact ratio: ',num2str(x0(7)/x0(8))])
% Only positions and velocities needed as initial conditions
61
x0=x0(1:6);
tstart = t(nt);
if tstart>=tfinal
break
end
end
disp('by Eric R. Westervelt, Jessy W. Grizzle,');
disp('Christine Chevallereau, Jun-Ho Choi, and Benjamin Morris');
%% Draw some useful graphs
%
fig_hl=figure(2);
set(fig_hl,'Position', [200 100 400 450]);
set(fig_hl,'PaperPosition',[1.25 1.5 6 8])
subplot(2,1,1)
plot(tout,xout(:,1),'-',tout,xout(:,2),'--',tout,xout(:,3),'-.')
legend('\theta_1','\theta_2','\theta_3',-1)
grid
title('Joint Positions')
subplot(2,1,2)
plot(tout,xout(:,4),'-',tout,xout(:,5),'--',tout,xout(:,6),'-.')
legend('\theta_1 (dot)','\theta_2 (dot)','\theta_3 (dot)',-1);
xlabel('time (sec)')
grid
title('Joint Velocities')
fig_hl=figure(3);
set(fig_hl,'Position', [220 120 400 450])
set(fig_hl,'PaperPosition',[1.25 1.5 6 8])
subplot(2,1,1)
plot(t_2,force(:,1),'-b',t_2,force(:,2),'--r')
legend('F_{tan} (N)','F_{norm} (N)',-1)
grid
title('Forces on End of Stance Leg')
subplot(2,1,2)
plot(t_2,force(:,1)./force(:,2))
ylabel('F_{tan}/F_{norm}');
xlabel('time (sec)')
grid
%plot the input
fig_hl=figure(4);
set(fig_hl,'Position', [240 140 400 450]);
set(fig_hl,'PaperPosition',[1.25 1.5 6 8])
subplot(2,1,1)
plot(t_2,torque(:,1))
ylabel('\tau_1 (Nm)')
grid
title('Control Signals')
subplot(2,1,2)
plot(t_2,torque(:,2))
ylabel('\tau_2 (Nm)');
xlabel('time (sec)')
grid
%plot the outputs
fig_hl=figure(5);
set(fig_hl,'Position', [260 160 400 450]);
set(fig_hl,'PaperPosition',[1.25 1.5 6 8])
62
subplot(2,1,1)
plot(t_2,y(:,1))
ylabel('y_1')
title('Outputs')
grid
subplot(2,1,2)
plot(t_2,y(:,2))
ylabel('y_2');
xlabel('time (sec)')
grid
% % save u,y to file
save('u_new.mat','torque','t_2');
%save('y.mat','y','t_2');
% Run the animation
anim(tout,xout,1/30,1);
%% ------------------------------------------------------------------------
--
%% the animation function
function anim(t,x,ts,speed)
[n,~]=size(x);
[~,vH]=hip_vel(x); % convert angles to horizontal position of hips
pH_horiz = zeros(n,1);
% Estimate hip horizontal position by estimating integral of hip velocity
%(sebesseg*ido=tavolsag)
for j=2:n
pH_horiz(j)=pH_horiz(j-1)+(t(j)-t(j-1))*vH(j-1,1);
end
[~,pH_horiz]=even_sample(t,pH_horiz,1/ts);
[te,xe]=even_sample(t,x,1/ts);
[n,~]=size(xe);
q=xe(1,1:3);
[pFoot1,pFoot2,pH,pT]=limb_position(q,pH_horiz(1));
fig_hl=figure(1);
set(fig_hl,'Position', [280 180 400 350]);
set(fig_hl,'PaperPosition',[0 0 6 5]);
clf
anim_axis=[-2.2 2.2 -2.2 2.2];
axis off
axis(anim_axis)
grid
% Use actual relations between masses in animation
[~,m,~,Mt,~,~]=model_params_three_link;
scl=0.04; % factor to scale masses
mr_legs=m^(1/3)*scl; % radius of mass for legs
mr_torso=Mt^(1/3)*scl; % radius of mass for torso
leg1_color='g';
leg2_color='r';
torso_color='b';
ground_color='k'; % a.k.a. black
% Approximate circular shape of mass
63
param=linspace(0,2*pi+2*pi/50,50);
xmass_legs=mr_legs*cos(param);
ymass_legs=mr_legs*sin(param);
xmass_torso=mr_torso*cos(param);
ymass_torso=mr_torso*sin(param);
% Draw ground
buffer=5;
ground=line([-buffer pH_horiz(n)+buffer],[0 0]);
set(ground,'Color',ground_color,'LineWidth',2);
for k=-buffer:floor(pH_horiz(n)+buffer)
ref_tick(k+buffer+1)=line([k k],[-0.1 0]);
set(ref_tick(k+buffer+1),'Color',ground_color);
ref_label(k+buffer+1)=text(-0.03+k,-0.2,num2str(k));
end
% Draw leg one
leg1=line([pFoot1(1) pH(1)],[pFoot1(2) pH(2)]);
mass1=patch(xmass_legs+(pH(1)-pFoot1(1))/2,...
ymass_legs+(pH(2)-pFoot1(2))/2,leg1_color);
set(mass1,'EdgeColor',leg1_color)
set(leg1,'LineWidth',2,'Color',leg1_color);
% Draw leg two
leg2=line([pFoot2(1) pH(1)],[pFoot2(2) pH(2)]);
mass2=patch(xmass_legs+pH(1)-(pH(1)-pFoot2(1))/2,...
ymass_legs+pH(2)-(pH(2)-pFoot2(2))/2,leg2_color);
set(mass2,'EdgeColor',leg2_color)
set(leg2,'LineWidth',2,'Color',leg2_color);
% Draw torso
torso=line([pH(1) pT(1)],[pH(2)*2 pT(2)*2]);
torso_mass=patch(xmass_torso+pT(1),ymass_torso+pT(2),torso_color);
set(torso_mass,'EdgeColor',torso_color)
set(torso,'LineWidth',2,'Color',torso_color);
for k=2:n
q=xe(k,1:3);
[pFoot1,pFoot2,pH,pT]=limb_position(q,pH_horiz(k));
set(leg1,'XData',[pFoot1(1) pH(1)],'YData',[pFoot1(2) pH(2)]);
set(mass1,'XData',xmass_legs+(pH(1)-pFoot1(1))/2+pH_horiz(k),...
'YData',ymass_legs+(pH(2)-pFoot1(2))/2);
set(leg2,'XData',[pFoot2(1) pH(1)],'YData',[pFoot2(2) pH(2)]);
set(mass2,'XData',xmass_legs+pH(1)-(pH(1)-pFoot2(1))/2,...
'YData',ymass_legs+pH(2)-(pH(2)-pFoot2(2))/2);
set(torso,'XData',[pH(1) pT(1)+(pT(1)-pH(1))],...
'YData',[pH(2) pT(2)+(pT(2)-pH(2))]);
set(torso_mass,'XData',xmass_torso+pT(1),'YData',ymass_torso+pT(2));
title(['T_{est} = ',num2str(te(k),'%.1f')])
new_axis=anim_axis+[pH(1) pH(1) 0 0];
axis(new_axis);
64
for j=1:length(ref_label)
if (j-buffer-1.05<new_axis(1)) || (j-buffer-1>new_axis(2))
set(ref_label(j),'Visible','off')
set(ref_tick(j),'Visible','off')
else
set(ref_label(j),'Visible','on');
set(ref_tick(j),'Visible','on')
end
end
drawnow;
pause(ts*speed);
end
%% ------------------------------------------------------------------------
--
%% a function to calculate hip velocity
function [vV,vH] = hip_vel(x)
vV=zeros(length(x),1);
vH=cos(x(:,1)).*x(:,4); % estimate of horizontal velocity of hips
%% ------------------------------------------------------------------------
--
%% a function to calculate the limb position
function [pFoot1,pFoot2,pH,pT] = limb_position(q,pH_horiz)
% Use position of hips as location of stance leg foot.
[r,~,~,~,L,~]=model_params_three_link;
pFoot1=[pH_horiz; 0];
pH=[pFoot1(1)+r*sin(q(1)); pFoot1(2)+r*cos(q(1))];
pFoot2=[pH(1)-r*sin(q(2)); pH(2)-r*cos(q(2))];
pT=[pH(1)+L*sin(q(3)); pH(2)+L*cos(q(3))];
%% ------------------------------------------------------------------------
--
%% CONVERTS A RANDOMLY SAMPLED SIGNAL SET INTO AN EVENLY SAMPLED SIGNAL SET
%% (by interpolation)
%%
%% written by Haldun Komsuoglu, 7/23/1999
function [Et, Ex] = even_sample(t, x, Fs)
% Obtain the process related parameters
N = size(x, 2); % number of signals to be interpolated
M = size(t, 1); % Number of samples provided
t0 = t(1,1); % Initial time
tf = t(M,1); % Final time
EM = (tf-t0)*Fs; % Number of samples in the evenly sampled case with
% the specified sampling frequency
Et = linspace(t0, tf, EM)';
% Using linear interpolation (used to be cubic spline interpolation)
% and re-sample each signal to obtain the evenly sampled forms
for s = 1:N,
65
Ex(:,s) = interp1(t(:,1), x(:,s), Et(:,1));
end
function [th3d,th1d,alpha,epsilon]=control_params_three_link
%control_params_three_link.m
%
% Control parameters for three-link legged biped.
%
% Eric Westervelt
% 20 February 2007
th3d=pi/6; % desired angle of torso
th1d=pi/8; % impact occurs with walking surface
alpha=0.9; % see page 14 of Grizzle paper
epsilon=0.1; % see page 16 of Grizzle paper
function [v]=control_three_link(H,LfH)
% CONTROL_THREE_LINK Calculate the control.
% [V] = CONTROL_THREE_LINK(X,H,LFH) is the control for the
% feedback linearized biped walking model.
%
% Eric Westervelt
% 03-May-2010 15:28:26
[th3d,th1d,alpha,epsilon]=control_params_three_link;
% LfH scaling
LfH=epsilon*LfH;
% phi fcns
phi1=H(1)+1/(2-alpha)*sign(LfH(1))*abs(LfH(1))^(2-alpha);
phi2=H(2)+1/(2-alpha)*sign(LfH(2))*abs(LfH(2))^(2-alpha);
% psi fcns
psi(1,1)=-sign(LfH(1))*abs(LfH(1))^alpha...
-sign(phi1)*abs(phi1)^(alpha/(2-alpha));
psi(2,1)=-sign(LfH(2))*abs(LfH(2))^alpha...
-sign(phi2)*abs(phi2)^(alpha/(2-alpha));
% calculate control
v=1/epsilon^2*psi;
function [D,C,G,B,K,dV,dVl,Al,Bl,H,LfH,dLfH]=dynamics_three_link(x,a)
% DYNAMICS_THREE_LINK Model of three-link biped walker model.
% [D,C,G,B,K,dV,dVl,Al,Bl,H,LfH,DLFH] = DYNAMICS_THREE_LINK(X,
% A) is the three-link
% biped walking model. (x is of dimension 6)
% Eric Westervelt
% 03-May-2010 15:28:24
[r,m,Mh,Mt,L,g]=model_params_three_link;
[th3d,th1d,alpha,epsilon]=control_params_three_link;
th1=x(1); th2=x(2); th3=x(3);
dth1=x(4); dth2=x(5); dth3=x(6);
66
% D matrix
D=zeros(3);
D(1,1)=Mh*r^2 + Mt*r^2 + (5*m*r^2)/4;
D(1,2)=-(m*r^2*cos(th1 - th2))/2;
D(1,3)=L*Mt*r*cos(th3 - th1);
D(2,1)=-(m*r^2*cos(th1 - th2))/2;
D(2,2)=(m*r^2)/4;
D(3,1)=L*Mt*r*cos(th3 - th1);
D(3,3)=L^2*Mt;
% C matrix
C=zeros(3);
C(1,2)=-(dth2*m*r^2*sin(th1 - th2))/2;
C(1,3)=-L*Mt*dth3*r*sin(th3 - th1);
C(2,1)=(dth1*m*r^2*sin(th1 - th2))/2;
C(3,1)=L*Mt*dth1*r*sin(th3 - th1);
% G matrix
G=zeros(3,1);
G(1)=- Mh*g*r*sin(th1) - Mt*g*r*sin(th1) - (3*g*m*r*sin(th1))/2;
G(2)=(g*m*r*sin(th2))/2;
G(3)=-L*Mt*g*sin(th3);
% B matrix
B=zeros(3,2);
B(1,1)=-1;
B(2,2)=-1;
B(3,1)=1;
B(3,2)=1;
% K matrix
K=zeros(2,4);
K(1,1)=156;
K(1,3)=25;
K(2,2)=110;
K(2,4)=21;
% dV matrix
dV=zeros(1,6);
dV(1,1)=(184*th1)/77 - 10*dth2 - 10*dth1 + (184*th2)/77;
dV(1,2)=(184*th1)/77 - 10*dth2 - 10*dth1 + (184*th2)/77;
dV(1,3)=(4515147318722739*th3)/2251799813685248 - 10*dth3 -
(4515147318722739*th3d)/4503599627370496 -
(4515147318722739*conj(th3d))/4503599627370496;
dV(1,4)=(370*dth1)/7 + (370*dth2)/7 - 10*th1 - 10*th2;
dV(1,5)=(370*dth1)/7 + (370*dth2)/7 - 10*th1 - 10*th2;
dV(1,6)=(4419157134357289*dth3)/70368744177664 - 10*th3 + 5*th3d +
5*conj(th3d);
% dVl matrix
dVl=zeros(1,4);
dVl(1,1)=(4515147318722739*th3)/2251799813685248 - 10*dth3 -
(4515147318722739*conj(th3d))/2251799813685248;
dVl(1,2)=(184*th1)/77 - 10*dth2 - 10*dth1 + (184*th2)/77;
dVl(1,3)=(4419157134357289*dth3)/70368744177664 - 10*th3 + 10*conj(th3d);
dVl(1,4)=(370*dth1)/7 + (370*dth2)/7 - 10*th1 - 10*th2;
% Al matrix
Al=zeros(4,4);
Al(1,3)=1;
Al(2,4)=1;
67
% Bl matrix
Bl=zeros(4,2);
Bl(3,1)=1;
Bl(4,2)=1;
%optimisation parameters
a01=a(1); a11=a(2); a21=a(3); a31=a(4);
a02=a(5); a12=a(6); a22=a(7); a32=a(8);
% Ha matrix
H=zeros(2,1);
H(1,1)=- a31*th1^3 - a21*th1^2 - a11*th1 - a01 + th3;
H(2,1)=th1 + th2 - (th1 + th1d)*(th1 - th1d)*(a32*th1^3 + a22*th1^2 +
a12*th1 + a02);
% LfHa matrix
LfH=zeros(2,1);
LfH(1,1)=dth3 - dth1*(3*a31*th1^2 + 2*a21*th1 + a11);
LfH(2,1)=dth2 - dth1*((th1 - th1d)*(a32*th1^3 + a22*th1^2 + a12*th1 + a02)
+ (th1 + th1d)*(a32*th1^3 + a22*th1^2 + a12*th1 + a02) + (th1 + th1d)*(th1
- th1d)*(3*a32*th1^2 + 2*a22*th1 + a12) - 1);
% dLfHa matrix
dLfH=zeros(2,6);
dLfH(1,1)=-dth1*(2*a21 + 6*a31*th1);
dLfH(1,4)=- 3*a31*th1^2 - 2*a21*th1 - a11;
dLfH(1,6)=1;
dLfH(2,1)=-dth1*(2*a02 + 2*(th1 + th1d)*(3*a32*th1^2 + 2*a22*th1 + a12) +
2*a12*th1 + 2*(th1 - th1d)*(3*a32*th1^2 + 2*a22*th1 + a12) + 2*a22*th1^2 +
2*a32*th1^3 + (th1 + th1d)*(2*a22 + 6*a32*th1)*(th1 - th1d));
dLfH(2,4)=1 - (th1 + th1d)*(a32*th1^3 + a22*th1^2 + a12*th1 + a02) - (th1 +
th1d)*(th1 - th1d)*(3*a32*th1^2 + 2*a22*th1 + a12) - (th1 -
th1d)*(a32*th1^3 + a22*th1^2 + a12*th1 + a02);
dLfH(2,5)=1;
function [r,m,Mh,Mt,L,g]=model_params_three_link
%model_params_three_link.m
%
% Model parameters for three-link legged biped.
%
% Eric Westervelt
% 20 February 2007
r=1; % length of a leg 1.15
m=5; % mass of a leg
Mh=15; % mass of hips
Mt=10; % mass of torso
L=0.5; % distance between hips and torso
g=9.8; % acceleration due to gravity
function [x]=sigma_three_link(omega_1_minus,a)
% SIGMA_THREE_LINK Maps velocity of stance leg just before
% impact to state of the system just before impact.
% [X] = SIGMA_THREE_LINK(OMEGA_1_MINUS,A)
% Eric Westervelt
% 03-May-2010 15:28:26
[th3d,th1d,alpha,epsilon]=control_params_three_link;
68
a01=a(1); a11=a(2); a21=a(3); a31=a(4);
a02=a(5); a12=a(6); a22=a(7); a32=a(8);
th1=th1d;
dth1=omega_1_minus;
th3 = a31*th1^3 + a21*th1^2 + a11*th1 + a01;
dth2 = 5*a32*dth1*th1^4 + 4*a22*dth1*th1^3 - 3*a32*dth1*th1^2*th1d^2 +
3*a12*dth1*th1^2 - 2*a22*dth1*th1*th1d^2 + 2*a02*dth1*th1 - a12*dth1*th1d^2
- dth1;
dth3 = dth1*(3*a31*th1^2 + 2*a21*th1 + a11);
x = [th1,-th1,th3,dth1,dth2,dth3];
function [f_tan,f_norm]=stance_force_three_link(x,dx,u)
% STANCE_FORCE_THREE_LINK Calculate the forces on the stance
% leg during impact.
% [F_TAN,F_NORM] = STANCE_FORCE_THREE_LINK(X,DX,U) are the forces on the
% stance leg at impact.
% Eric Westervelt
% 03-May-2010 15:28:26
[r,m,Mh,Mt,L,g]=model_params_three_link;
[th3d,th1d,alpha,epsilon]=control_params_three_link;
th1=x(1); th2=x(2); th3=x(3);
dth1=x(4); dth2=x(5); dth3=x(6);
% De11 matrix
De11=zeros(3,3);
De11(1,1)=(r^2*(4*Mh + 4*Mt + 5*m))/4;
De11(1,2)=-(m*r^2*(cos(th1)*cos(th2) + sin(th1)*sin(th2)))/2;
De11(1,3)=L*Mt*r*(cos(th1)*cos(th3) + sin(th1)*sin(th3));
De11(2,1)=-(m*r^2*(cos(th1)*cos(th2) + sin(th1)*sin(th2)))/2;
De11(2,2)=(m*r^2)/4;
De11(3,1)=L*Mt*r*(cos(th1)*cos(th3) + sin(th1)*sin(th3));
De11(3,3)=L^2*Mt;
% De12 matrix
De12=zeros(3,2);
De12(1,1)=(r*cos(th1)*(2*Mh + 2*Mt + 3*m))/2;
De12(1,2)=-(r*sin(th1)*(2*Mh + 2*Mt + 3*m))/2;
De12(2,1)=-(m*r*cos(th2))/2;
De12(2,2)=(m*r*sin(th2))/2;
De12(3,1)=L*Mt*cos(th3);
De12(3,2)=-L*Mt*sin(th3);
% De22 matrix
De22=zeros(2,2);
De22(1,1)=Mh + Mt + 2*m;
De22(2,2)=Mh + Mt + 2*m;
% Ce11 matrix
Ce11=zeros(3,3);
Ce11(1,2)=(dth2*m*r^2*(cos(th1)*sin(th2) - cos(th2)*sin(th1)))/2;
Ce11(1,3)=-L*Mt*dth3*r*(cos(th1)*sin(th3) - cos(th3)*sin(th1));
Ce11(2,1)=-(dth1*m*r^2*(cos(th1)*sin(th2) - cos(th2)*sin(th1)))/2;
Ce11(3,1)=L*Mt*dth1*r*(cos(th1)*sin(th3) - cos(th3)*sin(th1));
69
% Ce21 matrix
Ce21=zeros(2,3);
Ce21(1,1)=-(dth1*r*sin(th1)*(2*Mh + 2*Mt + 3*m))/2;
Ce21(1,2)=(dth2*m*r*sin(th2))/2;
Ce21(1,3)=-L*Mt*dth3*sin(th3);
Ce21(2,1)=-(dth1*r*cos(th1)*(2*Mh + 2*Mt + 3*m))/2;
Ce21(2,2)=(dth2*m*r*cos(th2))/2;
Ce21(2,3)=-L*Mt*dth3*cos(th3);
% Ge1 matrix
Ge1=zeros(3,1);
Ge1(1,1)=- Mh*g*r*sin(th1) - Mt*g*r*sin(th1) - (3*g*m*r*sin(th1))/2;
Ge1(2,1)=(g*m*r*sin(th2))/2;
Ge1(3,1)=-L*Mt*g*sin(th3);
% Ge2 matrix
Ge2=zeros(2,1);
Ge2(2,1)=Mh*g + Mt*g + 2*g*m;
% B matrix
B=zeros(3,2);
B(1,1)=-1;
B(2,2)=-1;
B(3,1)=1;
B(3,2)=1;
% See my notes, 2/16/200 for equations...
DD=inv((De12*inv(De22)).'*De12*inv(De22))*(De12*inv(De22)).';
F=DD*(-(De11-De12*inv(De22)*De12.')...
*dx(4:6)+(De12*inv(De22)*Ce21-Ce11)...
*dx(1:3)+De12*inv(De22)*Ge2-Ge1+B*u);
f_tan=F(1);
f_norm=F(2);
function [x_new,z2_new]=transition_three_link(x)
% TRANSITION_THREE_LINK Calculate the state of the system after impact.
% (Last two entries are the forces at the toe.
% [X_NEW,Z2_NEW] = TRANSITION_THREE_LINK(X) is the transition function
for
% biped walking model. (x is of dimension 8)
% Eric Westervelt
% 03-May-2010 15:28:25
[r,m,Mh,Mt,L,~]=model_params_three_link;
th1=x(1); th2=x(2); th3=x(3);
% De matrix
De=zeros(5,5);
De(1,1)=(r^2*(4*Mh + 4*Mt + 5*m))/4;
De(1,2)=-(m*r^2*(cos(th1)*cos(th2) + sin(th1)*sin(th2)))/2;
De(1,3)=L*Mt*r*(cos(th1)*cos(th3) + sin(th1)*sin(th3));
De(1,4)=(r*cos(th1)*(2*Mh + 2*Mt + 3*m))/2;
De(1,5)=-(r*sin(th1)*(2*Mh + 2*Mt + 3*m))/2;
De(2,1)=-(m*r^2*(cos(th1)*cos(th2) + sin(th1)*sin(th2)))/2;
De(2,2)=(m*r^2)/4;
70
De(2,4)=-(m*r*cos(th2))/2;
De(2,5)=(m*r*sin(th2))/2;
De(3,1)=L*Mt*r*(cos(th1)*cos(th3) + sin(th1)*sin(th3));
De(3,3)=L^2*Mt;
De(3,4)=L*Mt*cos(th3);
De(3,5)=-L*Mt*sin(th3);
De(4,1)=(r*cos(th1)*(2*Mh + 2*Mt + 3*m))/2;
De(4,2)=-(m*r*cos(th2))/2;
De(4,3)=L*Mt*cos(th3);
De(4,4)=Mh + Mt + 2*m;
De(5,1)=-(r*sin(th1)*(2*Mh + 2*Mt + 3*m))/2;
De(5,2)=(m*r*sin(th2))/2;
De(5,3)=-L*Mt*sin(th3);
De(5,5)=Mh + Mt + 2*m;
% E matrix
E=zeros(2,5);
E(1,1)=r*cos(th1);
E(1,2)=-r*cos(th2);
E(1,4)=1;
E(2,1)=-r*sin(th1);
E(2,2)=r*sin(th2);
E(2,5)=1;
% See Grizzle's paper, page 28 for equation...Eq.(2.32))
tmp_vec=([De -E';E zeros(2)])\[De*[x(4:6)';zeros(2,1)];zeros(2,1)];
x_new(1)=x(2);
x_new(2)=x(1);
x_new(3)=x(3);
x_new(4)=tmp_vec(2);
x_new(5)=tmp_vec(1);
x_new(6)=tmp_vec(3);
x_new(7)=tmp_vec(6);
x_new(8)=tmp_vec(7);
z2_new=tmp_vec(5);
71
Appendix B: Script to obtain variables from Simulink
% A MATLAB script to get the inputs and outputs from the Simulink
%
% Robert Marc
% 25 May 2010
%inputs
temp=simout_u1.signals.values(:);
U1=[];
for i=1:length(temp)
U1=[U1 temp(i)];
end
U1=U1';
temp=simout_u2.signals.values(:);
U2=[];
for i=1:length(temp)
U2=[U2 temp(i)];
end
U2=U2';
%outputs
temp=simout_y1.signals.values(:);
Y1=[];
for i=1:length(temp)
Y1=[Y1 temp(i)];
end
Y1=Y1';
temp=simout_y2.signals.values(:);
Y2=[];
for i=1:length(temp)
Y2=[Y2 temp(i)];
end
Y2=Y2';