First published 2015 in Great Britain and the United States by ISTE Ltd and John Wiley & Sons, Inc.

Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms and licenses issued by the CLA. Enquiries concerning reproduction outside these terms should be sent to the publishers at the undermentioned address:

ISTE Ltd

27-37 St George’s Road

London SW19 4EU

UK

www.iste.co.uk

John Wiley & Sons, Inc.

111 River Street

Hoboken, NJ 07030

USA

www.wiley.com

© ISTE Ltd 2015

The rights of Luc Jaulin to be identified as the author of this work have been asserted by him in accordance with the Copyright, Designs and Patents Act 1988.

Library of Congress Control Number: 2014955868

British Library Cataloguing-in-Publication Data

A CIP record for this book is available from the British Library

ISBN 978-1-84821-798-0

Biological, economic and other mechanical systems surrounding us can often be described by a differential equation such as:

under the hypothesis that the time *t* in which the system evolves is continuous [JAU 05]. The vector u(*t*) is the *input* (or *control*) of the system. Its value may be chosen arbitrarily for all *t*. The vector y(*t*) is the *output* of the system and can be measured with a certain degree of accuracy. The vector x(*t*) is called the *state* of the system. It represents the memory of the system, in other words the information needed by the system in order to predict its own future, for a known input u(*t*). The first of the two equations is called the *evolution equation*. It is a differential equation that enables us to know where the state (*t*) is headed knowing its value at the present moment *t* and the control u(*t*) that we are currently exerting. The second equation is called the *observation equation*. It allows us to calculate the output vector y(*t*), knowing the state and control at time *t*. Note, however, that, unlike the evolution equation, this equation is not a differential equation as it does not involve the derivatives of the signals. The two equations given above form the *state representation* of the system.

It is sometimes useful to consider a discrete time *k*, with where is the set of integers. If, for instance, the universe is being considered as a computer, it is possible to consider that the time *k* is discrete and synchronized to the clock of the microprocessor. Discrete-time systems often respect a recurrence equation such as:

The first objective of this book is to understand the concept of state representation through numerous exercises. For this, we will consider, in Chapter 1, a large number of varied exercises and show how to reach a state representation. We will then show, in Chapter 2, how to simulate a given system on a computer using its state representation.

The second objective of this book is to propose methods to *control* the systems described by state equations. In other words, we will attempt to build *automatic* machines (in which humans are practically not involved, except to give orders, or *setpoints*), called *controllers* capable of *domesticating* (changing the behavior in a desired direction) the systems being considered. For this, the controller will have to compute the inputs u(*t*) to be applied to the system from the (more or less noisy) knowledge of the outputs y(*t*) and from the setpoints w(*t*) (see Figure I.1).

From the point of view of the user, the system, referred to as a *closed-loop system*, with input w(*t*) and output y(*t*), will have a suitable behavior. We will say that we have *controlled* the system. With this objective of control, we will, in a first phase, only look at linear systems, in other words when the functions f and g are assumed linear. Thus, in the continuoustime case, the state equations of the system are written as:

and in the discrete-time case, they become:

The matrices A, B, C, D are called *evolution*, *control*, *observation* and *direct matrices*. A detailed analysis of these systems will be performed in Chapter 3. We will then explain, in Chapter 4, how to stabilize these systems. Finally, we will show in Chapter 5 that around certain points, called *operating points*, nonlinear systems behave like linear systems. It will then be possible to stabilize them using the same methods as those developed for the linear case.

Finally, this book is accompanied by numerous MATLAB programs available at:

http://www.ensta-bretagne.fr/jaulin/isteauto.html

EXERCISE I.1.– Underwater robot# I.3. Solutions

*Solution to Exercise I.1 (underwater robot)*

*Solution to Exercise I.2 (sailing robot)*

# 1

# Modeling

**1.1. Linear systems**

**1.2. Mechanical systems**

**1.3. Servomotors**

**1.4. Exercises**

The underwater robot *Saucisse* of the Superior National School of Advanced Techniques (SNSAT) Bretagne [JAU 09], whose photo is given in Figure I.2, is a control system. It includes a computer, three propellers, a camera, a compass and a sonar. What does the input vector u, the output vector y, the state vector x and the setpoint w correspond to in this context? Where does the computer come in the control loop?

EXERCISE I.2.– Sailing robot

The sailing robot *Vaimos* (French Research Institute for Exploitation of the Sea (FRIES) and SNSAT Bretagne) in Figure I.3 is also a control system [JAU 12a, JAU 12b]. It is capable of following paths by itself, such as the one drawn in Figure I.3. It has a rudder and a sail adjustable using a sheet. It also has an anemometer on top of the mast, a compass and a Global Positioning System (GPS). Describe what the input vector u, the output vector y, the state vector x and the setpoint w may correspond to.

The input vector corresponds to the electric voltage given to the three propellers and the output vector y(*t*) includes the compass, the sonar data and the images taken by the cameras. The state vector x corresponds to the position, orientation and speeds of the robot. The setpoint w is requested by the supervisor. For instance, if we want to perform a course control, the setpoint w will be the desired speed and course for the robot. The controller is a pogram executed by the computer.

The input vector corresponds to the length of the sail sheet and to the angle of the rudder *δ _{g}* . The output vector includes the GPS data m, the ultrasound anemometer (weather vane on top of the mast)

We will call *modeling* the step that consists of finding a more or less accurate state representation of the system we are looking at. In general, constant parameters appear in the state equations (such as the mass or the inertial moment of a body, the coefficient of viscous friction, the capacitance of a capacitor, etc.). In these cases, an identification step may prove to be necessary. In this book, we will assume that all the parameters are known, otherwise we invite the reader to consult Eric Walter’s book [WAL 14] for a broad range of identification methods. Of course, no systematic methodology exists that can be used to model a system. The goal of this chapter and of the following exercises is to present, using several varied examples, how to obtain a state representation.

In the continuous-time case, linear systems can be described by the following state equations:

Linear systems are rather rare in nature. However, they are relatively easy to manipulate using linear algebra techniques and often approximate in an acceptable manner the nonlinear systems around their operating point.

The fundamental principle of dynamics allows us to easily find the state equations of mechanical systems (such as robots). The resulting calculations are relatively complicated for complex systems and the use of computer algebra systems may prove to be useful. In order to obtain the state equations of a mechanical system composed of several subsystems *S*_{1}, *S*_{2}, . . . , *S*_{m}, assumed to be rigid, we follow three steps:

1) *Obtaining the differential equations*. For each subsystem *S*_{k}, with mass *m* and inertial matrix J, the following relations must be applied:

where the f_{i} are the forces acting on the subsystem *S*_{k}, *M*_{f}* _{i}* represents the torque created by the force f

2) *Removing the components of the internal forces*. In differential equations there are the so-called *bonding* forces, which are internal to the whole mechanical system, even though they are external to each subsystem composing it. They represent the action of a subsystem *S*_{k} on another subsystem *S*_{ℓ}. Following the action–reaction principle, the existence of such a force, denoted by f^{k,ℓ} , implies the existence of another force f^{ℓ}^{,}^{k}, representing the action of *S*_{ℓ} on *S*_{k}, such that Through a formal manipulation of the differential equations and by taking into account the equations due to the action-reaction principle, it is possible to remove the internal forces. The resulting number of differential equations has to be reduced to the number *n* of degrees of freedom *q*_{1}, . . . , *q*_{n} of the system.

3) *Obtaining the state equations*. We then have to isolate the second derivative from the set of *n* differential equations in such a manner to obtain a vectorial relation such as:

where u is the vector of external forces that are not derived from a potential (in other words, those which we apply to the system). The state equations are then written as:

A mechanical system whose dynamics can be described by the relation will be referred to as *holonomic*. For a holonomic system, q and are thus independent. If there is a so-called *non*-*holonomic* constraint that links the two of them (of the form the system will be referred to as *non*-*holonomic*. Such systems may be found for instance in mobile robots with wheels [LAU 01]. Readers interested in more details on the modeling of mechanical systems may consult [KHA 07].

A mechanical system is controlled by forces or torques and obeys a dynamic model that depends on many poorly known coefficients. This same mechanical system represented by a kinematic model is controlled by positions, velocities or accelerations. The kinematic model depends on well-known geometric coefficients and is a lot easier to put into equations. In practice, we move from a dynamic model to its kinematic equivalent by adding servomotors. In summary, a servomotor is a direct current motor with an electrical control circuit and a sensor (of the position, velocity or acceleration). The control circuit computes the voltage *u* to give to the motor in order for the value measured by the sensor corresponds to the setpoint *w*. In practice, the signal *w* is generally given in the form of a square wave called *pulse-width modulation* (PWM) ). There are three types of servomotors:

– the *position servo*. The sensor measures the position (or the angle) *x* of the motor and the control rule is expressed as *u* = *k* (*x* − *w*). If *k* is large, we may conclude that *x* *w*;

– the *velocity servo*. The sensor measures the velocity (or the angular velocity) of the motor and the control rule is expressed as If *k* is large, we have

– the *acceleration servo*. The sensor measures the acceleration (tangential or angular) of the motor and the control rule is expressed as If *k* is large, we have *w*.

EXERCISE 1.1.– Integrator

The integrator is a linear system described by the differential equation = *u*. Find a state representation for this system. Give this representation in a matrix form.

EXERCISE 1.2.– Second order system

Let us consider the system with input *u* and output *y* described by the second order differential equation:

Taking x =(*y*, ), find a state equation for this system. Give it in matrix form.

EXERCISE 1.3.– Mass-spring system

Let us consider a system with input *u* and output *q*_{1} as shown in Figure 1.1 (*u* is the force applied to the second carriage, *q*_{i} is the deviation of the *i*^{th} carriage with respect to its point of equilibrium, *k*_{i} is the stiffness of the *i*^{th} spring and *α* is the coefficient of viscous friction).

Let us take the state vector:

1) Find the state equations of the system.

2) Is this system linear?

EXERCISE 1.4.– Simple pendulum

Let us consider the pendulum in Figure 1.2. The input of this system is the momentum *u* exerted on the pendulum around its axis. The output is *y*(*t*), the algebraic distance between the mass *m* and the vertical axis:

1) Determine the state equations of this system.

2) Express the mechanical energy *E*_{m} as a function of the state of the system. Show that the latter remains constant when the momentum *u* is nil.

EXERCISE 1.5.– Dynamic modeling of an inverted rod pendulum

Let us consider the so-called *inverted rod pendulum* system, which is composed of a pendulum of length *ℓ* placed in an unstable equilibrium on a carriage, as represented in Figure 1.3. The value *u* is the force exerted on the carriage of mass *M*, *x* indicates the position of the carriage, *θ* is the angle between the pendulum and the vertical axis and is the force exerted by the carriage on the pendulum. At the extremity *B* of the pendulum, a point mass *m* is fixated. We may ignore the mass of the rod. Finally, *A* is the point of articulation between the rod and the carriage and is the rotation vector associated with the rod.

1) Write the fundamental principle of dynamics as applied on the carriage and the pendulum.

2) Show that the velocity vector at point *B* is expressed by the relation Calculate the acceleration of point *B*.

3) In order to model the inverted pendulum, we will take the state vector Justify this choice.

4) Find the state equations for the inverted rod pendulum.

EXERCISE 1.6.– Kinematic modeling of an inverted rod pendulum

In a kinematic model, the inputs are no longer forces or moments, but kinematic variables, in other words positions, velocities or accelerations. It is the role of servomotors to translate these kinematic variables into forces or moments.

Let us take the state equations of the inverted rod pendulum established in the previous exercise:

1) Instead of taking the force *u* on the carriage as input, let us rather take the acceleration What does the state model become?

2) Show how, by using a proportional control such as with large *K*, it is possible to move from a dynamic model to a kinematic model. In what way does this control recall the servomotor principle or the operational amplifier principle?

EXERCISE 1.7.– Segway

The segway represented on the left side of Figure 1.4 is a vehicle with two wheels and a single axle. It is stable since it is controlled. In the modeling step, we will of course assume that the engine is not controlled.

Its open loop behavior is very close to that of the planar unicycle represented in Figure 1.4 on the right hand side. In this figure, *u* represents the exerted momentum between the body and the wheel.

The link between these two elements is a pivoting pin. We will denote by *B* the center of gravity of the body and by *A* that of the wheel. *C* is a fix point on the disk. Let us denote by *α* the angle between the vector and the horizontal axis and by *θ* the angle between the body of the unicycle and the vertical axis. This system has two degrees of freedom *α* and *θ*. The state of out system is given by the vector

The parameters of our system are:

– for the disk: its mass *M*, its radius *a*, its moment of inertia *J*_{M} ;

– for the pendulum: its mass *m*, its moment of inertia *J*_{p}, the distance *ℓ* between its center of gravity and the center of the disk.

Find the equations of the systems.

EXERCISE 1.8.– Hamilton’s method

Hamilton’s method allows us to obtain the state equations of a conservative mechanical system (in other words, whose energy is conserved) only from the expression of a single function: its energy. For this, we define the *Hamiltonian* as the mechanical energy of the system, in other words the sum of the potential energy and the kinetic energy. The Hamiltonian can be expressed as a function *H* (q, p) of the degrees of freedom q and of the associated amount of movement (or kinetic moments in the case of a rotation) p. The Hamilton equations are written as:

1) Let us consider the simple pendulum shown in Figure 1.6. This pendulum has a length of *ℓ* and is composed of a single point mass *m*. Calculate the Hamiltonian of the system. Deduce the state equations from this.

2) Show that if a system is described by Hamilton equations, then the Hamiltonian is constant.

EXERCISE 1.9.– Omnidirectional robot

Let us consider the robot with three omni wheels, as shown in Figure 1.5. An omni wheel is a wheel equipped with a multitude of small rollers over its entire periphery that allow it to slide sideways (in other words perpendicularly to its nominal movement direction). Let us denote by v_{i} the velocity vector of the contact point of the *i*^{th} wheel. If i_{i} is the normed direction vector indicating the nominal movement direction of the wheel, then the component of v_{i} according to i_{i} corresponds to the rotation *ω*_{i} of the wheel whereas its complementary component (perpendicular to i_{i} ) is linked to the rotation of the peripheral rollers. If *r* is the radius of the wheel, then we have the relation *rω*_{i} = 〈v_{i}, i_{i}〉 = v_{i}. i_{i}. cos *α*_{i}, where If cos *α*_{i} = ±1, the wheel is in its nominal state, i.e. it behaves like a classical wheel. If cos *α*_{i} =0, the wheel no longer turns and it is in a state of skid.

1) Give the state equations of the system. We will use the state vector x =(*x*, *y*, *θ*) and the input vector *ω* =(*ω*_{1}, *ω*_{2}, *ω*_{3}).

2) Propose a loop that allows us to obtain a model tank described by the following state equations:

EXERCISE 1.10.– Modeling a tank*x**y**θ*^{T}*v* and _{2}*x**y**θ**v*, _{2}^{T}

The robot tank in Figure 1.7 is composed of two parallel motorized crawlers (or wheels) whose accelerations (which form the inputs *u*_{1} and *u*_{2}*x**y**θ*