robust control of autonomous underwater vehicles - … stage/rapport... · robust control of...

56
Robust control of autonomous underwater vehicles ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME , Emilie ROCHE School tutor : John-Jairo Martinez-Molina INRIARhˆone-Alpes Gipsa-Lab June 14 2010 c Copyright Ifremer 1

Upload: hoangduong

Post on 15-Sep-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

Robust control of

autonomous underwater vehicles

Sebastien VarrierCo-tutors : Daniel SIMON , Olivier SENAME , Emilie ROCHE

School tutor : John-Jairo Martinez-Molina

INRIA Rhone-Alpes Gipsa-LabJune 14 2010

c© Copyright Ifremer

1

Page 2: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

Acknowledgments

I would like to thank Daniel Simon and Olivier Sename who wereresponsible for my internship, for their trust all along the project,their contribution to make this 5 month work be as pleasant as possi-ble, and for all the participation and investment they implied duringthis period.

I also would like to thank both Gipsa-Lab and Inria Rhone-Alpes,the laboratories which hosted me during those 5 month, and all thepersons of the NeCS team in which I was affiliated.

Finally, I would like to thank the trainees and PhDs I met, whocontributed to a pleasant atmosphere in the labs.

2

Page 3: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

CONTENTS

Contents

Introduction 3

1 Modeling of the underwater vehicle 7

1.1 Frames and state variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.1.1 Inertial frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.1.2 Vehicle frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.1.3 State variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.2 Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.3 Vehicle simulation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.3.1 1st Newton principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.3.2 Simulink model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.4 Submarine properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.4.1 Hydrodynamical stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.4.2 Natural upward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2 Longitudinal speed control 12

2.1 Non linear compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.2 H∞ controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.2.1 Background on H∞ synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.2.2 Robust controller synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.2.3 Performances - Controller parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.3 Simulation - Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.4 Robustness : N −∆ form - µ-synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3 Altitude control 21

3.1 Pitch controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.1.1 Pitch model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3.1.2 H∞ controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.1.3 Model reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.1.4 Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.2 Altitude controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.1 Relation z - θ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.2 Altitude controller synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4 Conclusion 28

A Longitudinal speed equation 29

B Altitude z control simulations 30

C Functions code 31

C.1 Frames changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

C.2 Centrifugal and Coriolis forces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

C.3 Hydrodynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

C.4 Weight and Archimedes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

C.5 Actuator : fins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

C.6 Actuator : propeller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

D Modeling of an AUV 54

3

Page 4: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

CONTENTS

Introduction

My internship was performed within the NeCS team (Networked Controlled System Team) whichbelongs to both following institutes :

Inria Rhone-Alpes (Institut National de Recherche en Informatique et en Automatique)

Gipsa-Lab (Grenoble Image Parole Signal Automatique).

Inria is a French insitute working on applied and fundamental researches on science and tech-nologies of information and communication. Inria has different sites in France. I was affiliated withInria Rhone Alpes (Inovallee Meylan-Montbonnot). Inria Rhone Alpes lists over 660 persons : 200researchers and professors, 210 engineers, technical and administrative staff, over 240 Ph.D stu-dents and post-doc including 45 % from foreign countries. Inria R.A. is diversified on 30 researchteams including NeCS. It has over 250 contracts including 87 research ones with industrialists.

Gipsa-Lab is a CNRS (Centre National de la Recherche Scientifique) joint research unit, workingin partnership with Grenoble-INP (Grenoble - National polytechnic institute) and both JosephFourier and Stendhal universities. Gipsa lists 13 teams in 3 departments : “Control systems”,“Image and Signal processing” and “Speech and Cognition”. There are 300 persons working atGipsa-Lab : 100 are permanent researchers, 120 PhD positions, 20 post-doc students and guests,40 engineers and technical support.

This final year project is included within the framework of the European project FeedNetBack,which essentially deals with distributed and collaborative control.

One part of the project is the collaborative control of several autonomous underwater vehicles(AUVs). Typical missions should be some underwater mapping, or searching some fresh watersource by salinity gradient measurement (figure 1).

Figure 1: AUVs searching a fresh water source by gradient measurement

For this project, the control problem is decomposed as follows (figure 2):

A task consists in giving a reference position to the submarine, with the vehicle position, thegradient measures and the others vehicle positions as inputs. Finally, it returns the desiredposition where the vehicle has to go.

4

Page 5: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

CONTENTS

+-

Gradient measurements

Position of theothers AUVs

Referenceposition

Actualposition

Reference controller

AUV controller

Figure 2: Model of the collaborative control

Another task is to control the underwater vehicle dynamics, from the desired positions andits actual position.

Apart from the control issues, many other people are working on the project, for instance onthe underwater communications, or on the building of robots (Ifremer) etc.

My work is included in the dynamic control team. The aim of my 5 months internship was tofind some robust controllers to stabilize and to reach the objectives for the AUV dynamic. Controllaws have to be applied to the robot AsterX built by Ifremer (Institut Francais de Recherche pourl’Exploitation de la MER).

The submarine is 4.5 meters long, and it reaches a weight of 793 kg. It is actuated via apropeller on its tail, and 5 fins : 2 are on the front, and 3 are on the tail, spaced of 120° betweeneach one (figure 3).

c© Copyright Ifremer

Figure 3: Photo of the AsterX

Since the vehicle evolves in the sea (water), it is submitted to many efforts, hardly measurableand not well known. So, it has been decided to design some robust controller, in order to take intoaccount the unavoidable modeling errors.

This report presents firstly basics on the submarine modeling and presents the non linear model,including a brief part on some uncommon intrinsic properties of the submersible.

5

Page 6: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

CONTENTS

Second section account for the longitudinal control, recalling on the H∞ synthesis. The robustcontroller drives an inner loop composed by the non linear model, linearized via a non linearcompensation.

Last section deal with the altitude control. An original control scheme has been developed,including two cascade robust controllers. A pitch controller is firstly applied, then an accuratecontrol of the altitude is implemented.

6

Page 7: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

1 Modeling of the underwater vehicle

For the modeling step, I had to handle and understand the model provided by Ifremer. This studyrelies mainly on the PhD dissertation by Aristide Simon-Santos [5].

In this section, the considered AUV model will be presented. Firstly, the different used frames,and the state variables will be defined. Then, by applying the 1st Newton law, the speed of theunderwater vehicle will be outlined, in the specified frame. Then, a simulator in Matlab/Simulinkis implemented. Finally, some not common properties will be discussed.

1.1 Frames and state variables

1.1.1 Inertial frame

In order to characterize the position of the vehicle, it is necessary to use an inertial frame. Aninertial frame is one in which an immobile object is not subject to any forces. Actually, there existsan infinity of those frames because every frame in rectilinear translation above an inertial frame isan inertial frame.

A frame positioned at the level of the earth is not an inertial frame, because of the rotation ofthe earth around the sun and its own rotation. However, the submarine is a relatively slow vehicle,so the accelerations due to the earth’s rotations can be neglected.

Therefore a frame R0 centered on the level on the sea is considered, in which one directionrepresenting the altitude is pointing to the center of the earth, and the other 2 to arbitraryperpendicular directions tangent to the sea level.

This frame is dedicated to characterize the absolute position and attitude of the submarine.

1.1.2 Vehicle frame

Another frame R fixed on the vehicle, centered on the center of hull (different from the center ofgravity) of the AUV is also used. One direction is pointing the front, another the left and the lastis pointing down the vehicle.

This frame is mostly dedicated to express the speeds of the vehicle.

1.1.3 State variables

The AUV is characterized in both frames R and R0 :

R is the frame where the linear and rotating speeds are expressed

ν =

(ν1

ν2

)=

(~V~Ω

)=(u v w p q r

)/R

R0 is the frame defining the absolute position :

η =

(η1

η2

)=

(~X~Θ

)=(x y z η2

)/R0

where η2 is chosen according to the desired parametrization, as both following ones :

7

Page 8: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

1 MODELING OF THE UNDERWATER VEHICLE

– yaw, pitch and roll angles. The advantage of this representation lies in the fact thatthey are easily understandable. However, the main disadvantage is the fact that thisrepresentation has a singularity for a pitch θ = π

2 .

– quaternions. A quaternion is a 4 dimensional complex number q = q0 +q1i+q2j+q3k =q0 + ~q. The advantage is the non singularity of the representation.

The idea for fully characterize the system would be using the quaternions representation todisable the singularity, and then apply a change of variables to use the more comprehensible yaw,pitch and roll angles.

This characterization is very powerful, excepted that a quaternion is a non oriented object.However, even if the singularity is canceled, there are some unexpected results when θ > π

2 .

Moreover, it will further be seen that θ can never reach θ = π2 (part 1.4.1). Therefore, the

yaw, pitch and roll angles denoted ψ, θ and φ are considered to characterize the system. Finally,

η2 =(φ θ ψ

)Tis as illustrated on figure 4.

φY0

Z0 Z0

X0

θ

X0

Y0

ψ

Figure 4: Yaw, pitch and roll angles

Then, there exists some geometrical relations linking the speeds in the inertial frame R withthe frame R0. It can be expressed as :(

η1

η2

)/R0

=

(Jc1(η2) O3×3

O3×3 Jc2(η2)

)(ν1

ν2

)/R

(1)

1.2 Actuators

The vehicle is actuated via 6 actuators, as illustrated on figure 5 :

1 propeller on the tail

5 fins split up into the vehicle body : 2 are on the front (β1 and β′1), 3 are on the tail (β2,β′2 and δ)

Figure 5 illustrates the disposition of each one, and their terminology.

Remarks

The propeller control is a normalized control, meaning it varies between 0 and 1. The propellercanot turn in the other sense (the vehicle canot go backward).

All the fins are limited in variation |βi, δ| ≤ 0.5 rad. This limitation is done in order tomaintain a region of validity for the efforts created.

8

Page 9: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

1.3 Vehicle simulation model

c© Copyright Ifremer

~w

~u

~v

β1

β′1

β2

β′2δ

Figure 5: Illustration of the actuators

1.3 Vehicle simulation model

1.3.1 1st Newton principle

By applying the first Newton principle on the center of gravity of the submarine, its speeds in theframe R can be expressed :

Mν/R = G(ν)ν +D(ν)ν + Γg + Γu + Γp (2)

where :

G(ν)ν represents the centrifugal and Coriolis forces

D(ν)ν stands for the hydrodynamics

Γg represents the weight and the Archimedes

Γu sums the efforts due to the actuators (fins and propeller)

Γp is the torsor of the marine perturbation (not considered in simulations).

The explicit values of these terms will not be detailed in this report. However, the interestedreader can refer to the PhD by Simon-Santos [5] where the submarine modeling is well explained.Some details are also proposed in appendix D (in French) about the modeling of the AsterX .

1.3.2 Simulink model

According to equations (1) and (2), a Simulink model has been established. S-functions have beencoded in C, representing each term of equation (2) except the marine disturbances. There is onecontrol input acting on Γu, and one output vector representing both η and ν vectors (figure 6).

The used code is present on appendix C.

9

Page 10: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

1 MODELING OF THE UNDERWATER VEHICLE

M−1

Jc(η2)

G(ν)ν

D(ν)ν

Γg

Γu

+

+++ 1

p

ν ν

Mappingη, ν

1p

η η

Controlinput

Figure 6: Simulink simulation model

1.4 Submarine properties

By construction, the submarine owns some remarkable properties due to the weight and theArchimedes forces.

1.4.1 Hydrodynamical stability

Weight force ~P and compensatory Archimedes ~Fa are not applied exactly on the same point,but perpendicular to the body of the vehicle. Consequently, when the submarine is tilted, theupward Archimedes and the downward weight create a moment ~Cr around the longitudinal axisthat counteracts to the inclination (figure 7).

~Fa

~P

F

G

~u θ

~Cr

Figure 7: Hydrodynamical stability

This property was decided by Ifremer. Indeed if there are some problems on the control, oreven if the submarine is not anymore controllable, this force permits the submarine to remainhorizontal.

On the other hand, in order to tilt the submarine, it is always necessary to act more on thefins to compensate this phenomenon. In simulation, the hydrodynamical stability effect preventsthe AUV to upend, neither around axis X nor Y . In this case, a pitch θ = π

2 canot be achieved.

10

Page 11: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

1.5 Conclusion

1.4.2 Natural upward

It also has been chosen to make the weight ~P 6 kg less than the theoretical Archimedes (figure 8).In this case, if the submarine is not actuated, it will naturally be pulled up. This result is a safetycondition. In effect, if an error occurs on the vehicle, it will not stay submerged, it will surfacealone.

~Fa

~P

F

G~u

~P

Figure 8: Hydrodynamical stability

Moreover, a second safety component has been introduced. If there is an important problem,batteries can be ejected from the body, releasing 200 kg more, so the submarine would rise to thesurface far faster.

1.5 Conclusion

In this part, the modeling of the AUV has been briefly presented. In open loop simulations, it canbe shown that the submarine is a very slow vehicle. It reaches for the max propeller thrust 2.7m/s.However, the nominal cruise speed is 1m/s.

Now that the vehicle is fully characterized, longitudinal and vertical control laws will be intro-duced.

11

Page 12: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2 LONGITUDINAL SPEED CONTROL

2 Longitudinal speed control

From the expression of the non-linear model (equation (2)), the equation of the longitudinal speedu can be extracted :

Gu : u = M−1(1, :) [G(ν)ν +D(ν)ν + Γg + Γu + Γp]

where Γp standing for the marine perturbation has not been taking into account. Therefore, thenumerical application is obtained :

u = −0.1148u2 + 0.9603Qn − 0.0519u√Qn + 3.209 · 10−5 u3

√Qn

In this equation, it is remarkable that the essential of the dynamic comes from the term−0.1148u2, and the essential of the control is given by the term 0.9603Qn, where Qn is the pro-peller control. Furthermore, the other non linear terms can be neglected and the robustness of thecontroller has to take into account the neglect of those terms.

Remark Even if it is not easy to conclude on the neglect of the coupling term, it can be assumedseeing appendix A. The graph shows the magnitude of the bode diagram of the non linear system,comparing the model with the coupling term (blue) and without (red) (figure 29). The relative errorbetween both models (figure 30) can also be seen. Both models are similar.

So, the control oriented model for the longitudinal speed can be considered as:

u = Au2 + BQn (3)

with A = −0.1148 and B = 0.9603.

Remark Equation (3) is not a linear equation. Nevertheless, it can be written as u = (Au) · u+BQn where (Au) is the pole of the system. It can be easily noticed that the dynamic of the systemis faster as the speed increases. Moreover, the performances are also state-dependent. Indeed, alow speed implies a long settling time, while a high speed improves the settling time.

In this context, the following control structure is adopted:

Non linearcompensation

Qn uW

H∞controller

+- u

uref

Pseudo - linear system

εGu non linear

Figure 9: Model of longitudinal speed control

A robust H∞ controller is used upstream of a “pseudo-linear” model. Actually, this “pseudo-linear” system is a non linear model, where a non linear compensation have been applied in orderto obtain a linear model. The term “pseudo-linear” model means that the non linear compensationis used for some nominal parameters, and in practice, these terms are subject to some variationsor they may be not well known. So, the compensation would not always be exact, but it shouldbe accounted for by the H∞ controller.

12

Page 13: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2.1 Non linear compensation

Next parts will explain how this non linear compensation is chosen, and then some recallson the H∞ synthesis will be outlined. Then, the robustness of the non linear compensation willbe discussed and it will be seen in more details which are the maximum unknowns that can beencountered with this approach.

2.1 Non linear compensation

Equation (3) is not linear, due to the term in u2. The aim of the non linear compensation is tocancel this non linearity by acting on the control Qn.

Considering the equation u = Au2 + BQn, a non linear compensation can be of the form :

Qn = B−1(−Au2 +Au+BW

)where W is the new control input. As equation (3) is a scalar equation, it can be formulated as :

Qn =−Au2 +Au+BW

BThus, injecting into equation (3) lies :

u = Au2 + B−Au2 +Au+BW

Bu = Au2 −Au2 +Au+BW

u = Au+BW

where A is the new desired pole, and B = −A in order to have a normalized system.

The pseudo linearized model is :

u = Au+BW (4)

2.2 H∞ controller

2.2.1 Background on H∞ synthesis

Consider a plant G actuated via a controller K, and subjected to some input disturbance di, outputdisturbance dy and an output noise η, as illustrated on figure 10. The control u and the output y

ControllerK(s)

PlantG(s)

η

yur ε

di dy

+−

++

++

++

Figure 10: General approach

can be expressed as :

y(s) = 11+G(s)K(s) (G(s)K(s)r + dy −G(s)K(s)η +G(s)di)

u(s) = 11+G(s)K(s) (K(s)r −K(s)dy −K(s)η −K(s)G(s)di)

13

Page 14: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2 LONGITUDINAL SPEED CONTROL

Then the sensitivity function S is defined such that S(s) = 11+G(s)K(s) . Other sensitivity

functions are also defined : the complementary sensitivity function T (s) = 1− S(s) = G(s)K(s)1+G(s)K(s) ,

KS(s) = K(s)1+G(s)K(s) and SG(s) = G(s)

1+G(s)K(s) . Previous expressions can finally be expressed as :

y(s) = T (s)r + S(s)dy − T (s)η + SG(s)di

u(s) = KS(s)r −KS(s)dy −KS(s)η − T (s)di

The aim of the H∞ synthesis is to make the system reach some performances, stability androbustness with regard to these sensitivity functions. Based on a frequency approach, the bodediagram of these functions can be shaped in order to fulfill the requirements.

From the previous expression, the complementary sensitivity function T (s) represents thetransfert T (s) = y

r . Moreover, the complementary sensitivity function T (s) can be stated asT (s) = 1− S(s). So it can be written :

S(s) = 1− T (s)

S(s) = 1− y

r

S(s) =r − yr

S(s) =ε

r

In order to ensure a good speed tracking, the sensitivity S(s) has to be very small in lowfrequencies : lim

ω→0S(ω) = 0.

Remark S(s) is also representing the transfert between the output disturbance dy and the outputy. Thus, if a large attenuation in low frequencies is ensured, a good output disturbance rejection isalso achieved.

On the other hand, it is important to limit the action of the actuator, and to verify the propertiesof the control u. In this case, the sensitivity function KS(s) is the most appropriate, because it isthe transfert function between : KS(s) = u

r = udy

= uη .

In this case, limω→∞

KS(ω) = 0 ensures a good noise rejection.

2.2.2 Robust controller synthesis

As part of the robust analysis, it is important to specify the module margin ∆M . The modulemargin is given as the minimum distance in the Nyquist diagram between the instability point(−1; 0) and the loop transfer function. Intuitively, the larger the distance is, the larger the modulemargin is, and better the robustness is.

The idea of the H∞ synthesis is to ensure that the module margin is larger than a value α(α = 0.5 for instance), ensuring the minimum distance between the Nyquist diagram and theinstability point (−1; 0) is at least α. In this case, the modeling uncertainties or some disturbancescan make the real Nyquist plot be closer to (−1; 0), but since it is robust, never cross by theinstability point.

Moreover, the module margin is linked with the sensitivity function S(s) as :

∆M =1

maxω∈R

σ(S(ω))=

1

‖S(s)‖∞

14

Page 15: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2.2 H∞ controller

where σ(·) stands for the singular value.

As a module margin ∆M = α is desired, we choose lims→+∞

S(s) =1

α. Finally, a weighting

function We for S(s) is chosen as a low pass filter. Then, assuming ‖S(s)‖∞ ≤ 1‖We‖∞ , the

previous specifications are met.

A similar expression can be expressed for the sensitivity KS(s). By choosing a weightingfunction Wu, the requirement can be met if ensuring ‖KS(s)‖∞ ≤ 1

‖Wu‖∞Finally, the controller K can be expressed as a set of equations which has to be solved : Find

K such that :

K :

minγ

(∥∥∥∥ WeS(s)WuKS(s)

∥∥∥∥∞≤ γ

)(5)

γ ≤ 1 means previous conditions are fulfilled.

2.2.3 Performances - Controller parameters

It has been seen that in our case, 2 weighting functions We and Wu are necessary to be definedin order to make the closed loop system reach the objectives. In this subsection, the explicit andnumerical choice for those functions is defined.

1We

is chosen as a high pass filter. Since a large attenuation in low frequencies is desired, a

-80dB gain for 1We

is applied for frequencies close to 0, and a gain of 2 (absolute) in highfrequencies is chosen to met the condition ∆M = 0.5. The cutoff frequency is also definedat ωc = 0.35rad/s in order to reach a settling time te = 2.3

2·ωc= 13.2s. A 2nd order filter is

used to impose a -40dB/dec slope, meaning an integrator in the system which guarantee anull static error.

1Wu

is chosen as a low pass filter. Similarly than before, a good high frequency rejection isnecessary. So a high frequency gain of -40 dB is chosen, and a 1.5 (absolute) gain in lowfrequencies too, in order not to saturate the actuator (the propeller).

In figure 11, bode diagrams of sensitivity functions are shown with the inverse weighting func-tions, meaning the maximal desired template for S(s) and KS(s) (because it is nedded to verifyX · Y ≤ 1 ⇔ X ≤ Y −1) (figure 11).

The H∞ synthesis is then trying to find a state space K and a scalar γ solving equation (5).

Finally, γ = 1.2480 is obtained, meaning the specifications are not totally respected. Displayingthe obtained sensitivity functions S(s) and KS(s), phenomena are observed.

In figure 12, it can be noticed that the sensitivity function S(s) satisfies its template, whileKS(s) does not. However, KS(s) is rather close to W−1

u , meaning that specifications are closed tobe met. Moreover, there exists a gain making the sensitivity KS(s) being below its template. Thisgain is equal to γ, because the optimisation reached ‖KS(s)Wu(s)‖∞ ≤ γ = 1.2480. Effectively,KS(s) is not respecting the template 1

Wu, but it respects γ

Wu.

Although specifications are not properly met, the obtained properties seems similar and areacceptable. In order to verify the performances, the behavior of the system including this controlleris simulated.

15

Page 16: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2 LONGITUDINAL SPEED CONTROL

(a) (b)

Figure 11: Inverse weighting functions of (a) : S(s) and (b) : KS(s)

(a) (b)

Figure 12: Sensitivity functions. (a) : S(s) and 1We

, (b) : KS(s) and 1Wu

2.3 Simulation - Verification

The model is tested on the complete non linear model, including the previously synthesized robustH∞ controller and the non linear compensation downstream. A 1m/s step is applied a t=0s. Somedisturbances are also added:

t = 30s, an output disturbance dy = +0.1m/s is applied

t = 55s, an input disturbance di = +0.05m/s is applied

Results are shown on figure 13.

16

Page 17: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2.4 Robustness : N −∆ form - µ-synthesis

(a) (b)

Figure 13: Longitudinal speed control. (a) : Output u with the reference, (b) : Control Qn withperturbations

Specifications are achieved. In effect, the settling time is close to 13s, and both input andoutput disturbance are rejected.

Remark Even if these results seem good, the sensitivity KS(s) has been evaluated before the nonlinear compensation. Thus, it represents the transfert KS = W

uref= W

dy= W

η , and not really the

expected transfert KS = Qn

uref= Qn

dy= Qn

η .

This remark is very important, because the weighting function Wu is not acting on the realinput Qn but on the virtual input W upstream the non linear compensation. In order to concludeon the real performances of the system, a pseudo-bode diagram (meaning a bode diagram for anon linear system cf : [1]) is evaluated. This diagram is obtained by exciting the system witha time varying frequency sinusoidal source and observing the output. Although it is a non linearsystem, the sinusoidal amplitude signal is A = 0.1. The real sensitivity KS can be observed onfigure 14.

It can be seen that the controller provides a very good disturbance rejection. In effect, evenlow or high frequency disturbances have few impact on the control input Qn.

2.4 Robustness : N −∆ form - µ-synthesis

This subsection deals with the robustness of the control scheme. In effect, some parameters canbe varying, or not well known. Therefore it is important to verify the validity of the control.

One way to analyse the robustness of the system is to study the structured singular value σ(Σ),also called the µ-sensibility analysis. The mathematical aspect of this analysis is explained on thebook [6]. In this part, only the application is presented.

The most important assumption that has been done previously is the fact that the non linearcompensation perfectly cancels the term Au2 from equation (3). Nevertheless, in practice, it isnot always the case. Using the µ-sensibility analysis, the allowed uncertainty for the system canbe expressed.

17

Page 18: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2 LONGITUDINAL SPEED CONTROL

Figure 14: Evaluated KS

Using the N−∆ form, the idea is to study the stability of the transfer related to the uncertaintyand to determine the maximum admissible uncertainty.

First, the closed loop system has to be written as a N −∆ form according to figure 15 :

Nuuref

u∆ y∆

Figure 15: N −∆ form

To get the N−∆ form, A can be expressed as a constant part A0 plus some uncertainty |δ| ≤ 1such that : A = A0 +A0δ. Finally, equation (3) becomes :

u = A0u2 +A0δu

2 + BQnThe non linear compensation is computed for the nominal value of A :

Qn =−A0u

2 +Au+BW

B

Thus, a state space representation of the pseudo-linear model (PL) stands as :

PL :

u = A0δu

2 +Au+BWu = u

This state space representation is non linear. However, for the robustness analysis, a linear one isnecessary. In order to linearize it, u2 = umaxu is assumed in the uncertainty description. Note that

18

Page 19: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2.4 Robustness : N −∆ form - µ-synthesis

this will introduce some conservatism is the representation. A linear state space representation isobtained :

PL :

u = (A0umaxδ +A)u+BWu = u

The synthesized controller (K) has a state space representation of the form :

K :

X = AkX +BkεW = CkX

Finally the N −∆ form of the closed loop state space representation is given as :

N :

˙(uX

)=

(A BCk−Bk Ak

)(uX

)+

(1 00 −Bk

)(u∆

uref

)(y∆

u

)=

(A0umax 0

1 0

)(uX

)with y∆ = A0umaxu, and u∆ = y∆δ = A0umaxδu.

The robust stability analysis relies on the transfer between the output y∆ and the input u∆,denoted N11 whose state space representation is :

N11 :

˙(uX

)=

(A BCk−Bk Ak

)(uX

)+

(10

)u∆

y∆ =(A0umax 0

)(uX

) (6)

Using the matlab functions mussv and mussvextract, the N11 stability can be proved. Thefunction on figure 16 representing the maximum bound of the structured singular value for thesystem (σ(Σ)) is obtained. The maximum structured singular value is roughly equal to σmax =

Figure 16: Bound for the structured singular values of the system

0.32. According to this value, the maximum admissible uncertainty ∆ for the system is given by∆ = 1

0.32 = 3.13. Thus, the maximum admissible pole for A has to be in the set −0.1148(1± 3.13.Finally, A has to verify :

A ∈ [−0.4742; 0.2446] (7)

19

Page 20: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

2 LONGITUDINAL SPEED CONTROL

Remarks

The value of the pole A is mostly due to the hydrodynamical term, which is stem from thebody of the submarine. Thereby, this term is strictly negative because this part of the AUVprovides friction in the sea.

The obtained value is an upper bound of the real value.

Moreover, it does not take into account any saturation of the system.

Nonetheless, it can be shown that the obtained bound is a maximum bound for the pole. So,any more negative pole is suitable. In practice, the real value is roughly known at 40%.

To verify the performances of the system, the complete closed loop system is simulated fordifferent values of the pole A (figure 17).

(a) (b)

Figure 17: Longitudinal speed control. (a) : Speed u for different poles, (b) : Correspondingcontrol Qn

The obtained speeds remain stable, whatever the pole is (for a variation of 100% for A), evenwith the saturation.

2.5 Conclusion

The presented structure seems efficient. The advantage of the non linear compensation relies inthe way that performances are constant whatever the speed is. The robust controller absorbsthe errors of compensation, and it permits to reach the desired speed, with a good settling time,without static error.

20

Page 21: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3 Altitude control

The classic way to design an altitude controller should be by considering a model, representingthe transfer between the desired output (altitude z) and the reference zref . This method has beenused. Even if the results were acceptable, the performances were not. The best results occurredwhile acting more on the front fins regardless to the back ones.

The bad performances can be easily interpreted. Indeed, the controller input is the differencebetween the desired altitude and the real altitude ε = zref − z. So, a low error implies a fewinclination of the fins whereas a large error implies large fins variations. In order to use thiskind of controller, the minimum and maximum altitude variation has to be defined involving thenominal angles of variation.

However, this kind of control canot be acceptable. Indeed, there are different types of missionsthat the submarine has to reach, with different kinds of altitude, or variation of altitude. So,the controller should be tuned before each mission, depending on the difference ε. That is notacceptable.

Nonetheless, another kind of control has been developed. It points out that the fins are firstlyacting on the incidence θ, which changes the altitude. Moreover, the transfer between the incidenceand the actuators (fins) is more homogeneous because both are angles in radians.

In that sense, the altitude control is achieved first trough the control of the pitch angle θ, whichis firstly controlled. Then, there exists some relations linking the altitude to the angle. The controllaw is based on 2 cascade controllers according to the figure 18.

Σ NLCorr θ

θref

Corr ZZref

z

+−

ε

Figure 18: Model of the altitude control

In a first subsection, the construction of the pitch controller will be presented, hence the altitudeone will be.

3.1 Pitch controller

The idea is still to construct a robust controller, due to the lack of information on the exact model.The H∞ approach is chosen.

3.1.1 Pitch model

According to the modeling, a non-linear model of the θ angle can be expressed. However, thismodel is too complicated to design such a controller. Thereby, a linearized model given in thefollowing equations is used :

θ = q

q = 0.0047u+ 0.1876w − 0.2180θ − 0.9403q

+0.1326β1 + 0.1326β′1 − 0.0456β2 − 0.0456β′2 + 0.0167γ

21

Page 22: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3 ALTITUDE CONTROL

The model is multi-variable, and there are 5 actuators acting on the system, including thepropeller. In order to simplify the system, the term due to the propeller were canceled, because itis used to move the submarine forward, at a constant speed. Finally, the considered model is :

β1

β′1

β2

β′2

u

w

θ

q

Figure 19: Pitch model

θ = q

q = 0.0047u+ 0.1876w − 0.2180θ − 0.9403q

+0.1326β1 + 0.1326β′1 − 0.0456β2 − 0.0456β′2

3.1.2 H∞ controller

The system is controlled only using as reference θ. So, the following multi-variable scheme for thesynthesis of the robust controller is used :

β1

β′1

β2

β′2

u

w

θ

q

Pitchcontroller+

θref ε

Figure 20: Model of the altitude control

From this structure, a robust controller can be synthesized, using one weighting function onthe error ε, and one weighting function on each actuator.

The controller is obtained with γ=2.268. Sensitivities S(s) and KS(s) relatively to the outputθ and the first input β1 are obtained on figure 21.

The maximum singular value is obtained for a frequency ωn = 0.05 Hz, and reaches over 2.13dB.It means that the module margin is equal to ∆M = 1

‖S‖∞ = 1102.13/20 ' 0.78. The system is quite

robust.

In this subsection, a robust controller for the pitch angle is developed. It is a high ordercontroller composed of the order of the system (4) plus the order of the weighting functions (1 +4). Finally, it is a 9th order controller.

This kind of controller seems interesting. However, it has a too large order, and it will not beused anymore.

3.1.3 Model reduction

The idea is so to reduce the size of the controller. There are different approaches :

Reduce the system size

22

Page 23: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3.1 Pitch controller

(a) (b)

Figure 21: Sensitivity functions. (a) : S(s) and 1We

, (b) : KS(s) and 1Wu

Reduce the number of actuators

Controller reduction (a posteriori)

Apparently, neither one proposed solution seems adequate, because the reduction of the modelimplies some loss of information, and a reduction of the actuators can lead to uncontrollability.

However, a remark has to be made. When controlling the altitude, or the pitch of the submarine,it is moving on a vertical frame. Moreover, in order to stay in the frame, both front fins have tobe tilted with the same angle, and both rear ones too.

Thanks to this observation, the number of controls can be reduced, controlling only 1 front and1 rear fin, but multiplying the input matrix by 2 in order to take into account the modification.In this case, the size of the controller should be reduced from 9 to 7.

Even if a system reduction implies a loss of dynamical information, some state variables canbe unconsidered. For instance, non considering the speed is not important with respect to thedynamic of the system. In practice, it has been shown that only considering the state variables θand q is enough. This permits to reduce the system size from 7 to 5.

Remark Even if the longitudinal speed u has few effect on the dynamic of the pitch angle, it hasa large effect on the maximal admissible value. Due to the hydrodynamical stability, the submarineis no longer able to reach any pitch. However, as speed increases, the submarine can reach a higherslope. This remark has to be taken into account for further simulations.

3.1.4 Verification

In order to take into account the previous remark, a saturation on the control input is added. Itcan be shown that the maximum admissible pitch is proportional to the square of the longitudinalspeed θmax ' 0.8u2. Thereby a variable saturation on the input control is used.

Another remark can be done on the rate of variation. Effectively, the pitch variation is limited.It can be expressed as θmax ' 0.7u2.

23

Page 24: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3 ALTITUDE CONTROL

The system is simulated, submitted to a 0.6 radian step reference, with a perturbation att=400s. Both models with and without a saturation on the rate of variation are compared.

(a) (b)

Figure 22: Response to a 0.6 rad step. (a) : Output θ with and without saturation, (b) : Controlangles βi with saturation

As a result, the system with the saturation is more efficient. The system is a few oscillating,and it does not ensure a null steady state. However, the selected weighting functions (1st order)does not include an integrator in the system. This will not always guarantee a 0 static error. But,this problem will be handled via the outer loop (figure 18) controlling the altitude z.

3.2 Altitude controller

3.2.1 Relation z - θ

Z

l

θ

~u

Figure 23: Relation between z and θ

There exists some geometrical relations linking the altitude z with the pitch θ. In effect,according to figure 23, it can written :

z = l sin θ

i.e.z = l sin θ + lθ cos θ

24

Page 25: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3.2 Altitude controller

Moreover, the longitudinal speed u is equal to u = l. We get :

z = u sin θ + lθ cos θ (8)

A 1st order limited development of equation (8) for θ = 0 implies :

z ' uθ

Gθ =z

θ=

1

p

Therefore, the inner loop composed by the non linear model and the pitch controller Gθ canbe approximated by an integrator. In this case, the obtained controller should be of small order.

3.2.2 Altitude controller synthesis

The aim is then to design a robust controller via the same method than before (see figure 24).

ControllerK(s)

PlantG(s)

η

yur ε

dy

+−

++

++

We Wu

e1 e2

Figure 24: General approach

A 2nd order weighting function We on the error should be used because it would ensure a goodtracking (integrator ⇒ no static error). The following weighting functions are used (figure 25).

(a) (b)

Figure 25: Sensitivity functions. (a) : S(s) and 1We

, (b) : KS(s) ans 1Wu

As the pitch angle is limited, the derivative of the altitude is limited too (equation 8).

25

Page 26: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3 ALTITUDE CONTROL

The limitation of the pitch is due to the hydrodynamical stability of the submarine. So, inorder to tilt the vehicle, the fins need to compensate the torque due to the hydrodynamical effect.As speed increases, forces provided by the fins increases and it generates a higher torque (1.4.1).

The maximum admissible angle is θmax = 0.8u2. Since z = u sin θ, it lies :

|θ| ≤ θmax ⇒ |z| ≤ zmax = u sin 0.8u2 (9)

Nevertheless, without taking into account the rate of variation of the altitude, the differencebetween the real altitude and the desired one could be very high after a step, and it could introducea “wind-up” phenomenon, leading sometimes to instability (figure 27).

Finally, it is important to limit the rate of variation of the control input, with variables boundscorresponding to the values from equation (9).

The control scheme described on figure 26 is used.

+-

u

zr 1p

zr

u · sin(0.8 · u2)

+−

H ' 1p

θ zaltitudecontroller

Figure 26: Scheme of control

This rate limiter works like this. Consider the vehicle and the input in steady state, meaningzr − zr = 0. When a step arrives on the input zr = R, the difference zr − zr = R is saturated (±1)and multiplied by the maximum admissible rate of variation, present on the top function. Then itis integrated. The resulting slope is then determined by the value of the saturation.

This powerful control input allows not to limit the system, and it allows the integrator not toreach important values (wind-up effect). Hence, the simulated system including this control inputshows an improved response (figure 28).

(a) (b)

Figure 27: Response to a 100 m step without rate limitation. (a) : Altitude z, (b) : Control θ

26

Page 27: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

3.3 Conclusion

(a) (b)

Figure 28: Response to a 100 m step with rate limitation. (a) : Altitude z, (b) : Control θ

The overshoot on the altitude has been reduced, the settling time also has decreased due tothe saturation. It can be noticed that during the slope time, the integrator make the responsealtitude closer to the desired altitude, decreasing the error. Moreover, the angle θ in this case isnot saturated.

3.3 Conclusion

In this section, I presented an original kind of altitude control, composed by 2 cascade controllers.The presented results seem very encouraging, and are more adapted to the submarine’s controlthan a classical single multi-variable controller. Simulations have been done for different speedswhereas the presented results were done for the nominal 1m/s speed. During the simulations, thesystem remained stable, due to the robustness of the controllers. However, as speed decreases, theperformances also decrease due to the efforts generated by the actuators which are proportional tothe square of the speed (appendix B).

I tried to imagine like in the speed control a kind of non linear control making the robustcontroller linear against the speed, but unsuccessfully. However, the proposed control laws seemto work satisfactorily.

The presented structure include a rate limiter. This structure has proved itself by its stabilizingaction. However, the rate limit has to be known a priori. In order to compensate for this loophole,an anti wind-up system on the control can be added.

27

Page 28: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

4 CONCLUSION

4 Conclusion

During this 5 month internship, I developed several control laws for a full control of the AUV. Inthis report, both the longitudinal speed and the altitude control are presented. I also synthesizeda robust control for the cape tracking, using the same methodology.

I was also working on the discretization of the controller, and on the problem of time varyingsample time. This is a very important issue. Actually, this kind of control is very interesting forthe altitude control. Indeed a sonar sends a signal and receives an echo. By measuring the elapsedtime, the altitude is recovered. In this case, the next control will be applied after having receivedthe signal. That is the main motivation for this kind of control.

Moreover, in the case of limited autonomy, a varying sample time is very interesting because itpermits to save the embedded power, and it enlarges the mission time.

Some work already exists on this subject. For example, David Robert worked on the subject[2] and [3]. Emilie Roche is doing her PhD on the robust control of underwater vehicle, especiallybesides to the sampling period [4].

For my own, time varying sample time controllers was implemented using as basic solution :at each step, recompute the discretized controller for the actual sampling time.

Nevertheless, my work on the modeling has allowed to give some first restrictions on the AUVdynamics. Moreover, a simulator of the whole behavior of a scenario is being developed. Themodel I have provided is then used in this simulator.

Personally, this work was very interesting for me. I discovered in details the work in a lab, andespecially the work for the NeCS team. I especially appreciated the autonomous work, with onlya weekly or bi-weekly meeting with my tutors.

28

Page 29: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

A Longitudinal speed equation

Figure 29: Comparaison of both models with and without the coupling term

Figure 30: Relative error between the simplified and the complete model

29

Page 30: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

B ALTITUDE Z CONTROL SIMULATIONS

B Altitude z control simulations

(a) (b)

Figure 31: Response to a 100 m step for u = 0.5m/s. (a) : Altitude z, (b) : Control θ

(a) (b)

Figure 32: Response to a 100 m step for u = 1m/s. (a) : Altitude z, (b) : Control θ

(a) (b)

Figure 33: Response to a 100 m step for u = 1.5m/s. (a) : Altitude z, (b) : Control θ

30

Page 31: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C Functions code

C.1 Frames changes

#define S FUNCTION NAME chgt repere /* Defines and Includes */#define S FUNCTION LEVEL 2

#include ”simstruc.h”#include ”math.h”

/*———– passage du repere local au repere absolu ———–*/

static void mdlInitializeSizes(SimStruct *S)/*———— verifie le nombre de parametres egal zero ———–*/ssSetNumSFcnParams(S, 0);

if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return; /* Parameter mismatch will be reported by Simulink */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return;

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 12;int nb sortie = 6;/* definition de la taille du vecteur d’entree */dims = nb entree;di.width = nb entree;di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> vecteur 6*1 */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);

31

Page 32: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)int T i;InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);real T *y = ssGetOutputPortRealSignal(S,0);

real T PSI, THETA, PHI, u, v, w, p, q, r;real T m11, m12, m13, m21, m22, m23, m31, m32, m33, m44, m45, m46, m54, m55, m56, m64,

m65, m66;/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v *//* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//*——————————————————————*/u = *uPtrs[1];v = *uPtrs[3];w = *uPtrs[5];PHI = *uPtrs[6];p = *uPtrs[7];THETA = *uPtrs[8];q = *uPtrs[9];PSI = *uPtrs[10];r = *uPtrs[11];

/*——————————————————————*//*————– pas de parametres pour cette fonction ————-*//*——————————————————————*//* pour les vitesse lineaires u, v, w */m11 = cos(THETA) * cos(PSI);m12 = sin(THETA) * sin(PHI) * cos(PSI) - sin(PSI) * cos(PHI);m13 = cos(PSI) * sin(THETA) * cos(PHI) + sin(PSI) * sin(PHI);m21 = cos(THETA) * sin(PSI);m22 = sin(THETA) * sin(PHI) * sin(PSI) + cos(PSI) * cos(PHI);m23 = sin(PSI) * sin(THETA) * cos(PHI) - cos(PSI) * sin(PHI);m31 = -sin(THETA);m32 = cos(THETA) * sin(PHI);m33 = cos(THETA) * cos(PHI);/* pour les vitesse angulaires p, q, r */m44 = 1;m45 = sin(PHI)*tan(THETA);

32

Page 33: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.1 Frames changes

m46 = cos(PHI)*tan(THETA);m54 = 0;m55 = cos(PHI);m56 = -sin(PHI);m64 = 0;m65 = sin(PHI)/cos(THETA);m66 = cos(PHI)/cos(THETA);

/* calcul de la sortie */y[0] = m11 * u + m12 * v + m13 * w; /*x*/y[1] = m21 * u + m22 * v + m23 * w; /*y*/y[2] = m31 * u + m32 * v + m33 * w; /*z*/y[3] = m44 * p + m45 * q + m46 * r; /*phi*/y[4] = m54 * p + m55 * q + m56 * r; /*theta*/y[5] = m64 * p + m65 * q + m66 * r; /*psi*/

static void mdlTerminate(SimStruct *S)

/* Simulink/real-Time Workshop Interface */

#ifdef MATLAB MEX FILE /* Is this file being compiled as a MEX-file? */#include ”simulink.c” /* MEX-file interface mechanism */#else#include ”cg sfun.h” /* Code generation registration function */

#endif

33

Page 34: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

C.2 Centrifugal and Coriolis forces

#define S FUNCTION NAME dynamique /* Defines and Includes */#define S FUNCTION LEVEL 2

#include ”simstruc.h”#include ”math.h”

/*———————– vecteur G d(nu)*nu ————————*/

enum PARAM = 0, NUM PARAMS;

#define PARAM ARG ssGetSFcnParam(S, PARAM)

static void mdlInitializeSizes(SimStruct *S)/*—————– verifie le nombre de parametres —————-*/ssSetNumSFcnParams(S, NUM PARAMS);

#if defined(MATLAB MEX FILE) /* simulink et non real-time */if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return;

if (ssGetErrorStatus(S) != NULL) return;#endif

int iParam = 0;int nParam = ssGetNumSFcnParams(S); /*nb de parametre attendu*/

for ( iParam = 0; iParam < nParam; iParam++ )ssSetSFcnParamTunable( S, iParam, SS PRM TUNABLE ); /* on rend les parametres

modifiable */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return;

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/int T pWidth = mxGetNumberOfElements(PARAM ARG); /*nb parm*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 12;int nb sortie = 6;/* definition de la taille du vecteur d’entree */dims = nb entree;di.width = nb entree;

34

Page 35: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.2 Centrifugal and Coriolis forces

di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> vecteur 6*1 */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)int T i;InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);const real T *param = mxGetPr(PARAM ARG);real T *y = ssGetOutputPortRealSignal(S,0);

real T u, v, w, p, q, r;real T M, Xg, Yg, Zg, Ix, Iy, Iz;

/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v *//* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//*——————————————————————*/u = *uPtrs[1];v = *uPtrs[3];w = *uPtrs[5];p = *uPtrs[7];q = *uPtrs[9];r = *uPtrs[11];

/*——————————————————————*//*– attention il faut rentrer les parametres dans cet ordre la!!!–*/

35

Page 36: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

/*——————————————————————*//* PArAMETrES GLOBAUX : M, Xg, Yg, Zg, Ix, Iy, Iz, Ixy, Ixz, Iyz */M = param[0];Xg = param[1];Yg = param[2];Zg = param[3];Ix = param[4];Iy = param[5];Iz = param[6];

/* calcul de la sortie *//*y[0] = -M*(q*w - r*v + Zg*p*r);y[1] = -M*(-p*w + r*u + Zg*q*r);y[2] = -M*(p*v - q*u - Zg*(p*p + q*q));y[3] = - q*r*(Iz-Iy) - M*(- Zg*(r*u - p*w));y[4] = - p*r*(Ix-Iz) - M*(Zg*(q*w - r*v));y[5] = - p*q*(Iy-Ix);*//* y[0] = -M*((Yg*q+ Zg*r)*p -(Xg*q-w)*q -(Xg*r+v)*r );y[1] = -M*(-p*w + r*u + Zg*q*r);y[2] = -M*(p*v - q*u - Zg*(p*p + q*q));y[3] = - q*r*(Iz-Iy) - M*(- Zg*(r*u - p*w));y[4] = - p*r*(Ix-Iz) - M*(Zg*(q*w - r*v));y[5] = - p*q*(Iy-Ix);*/y[0] = -M*(w + p*Yg - q*Xg)*q + M*(v - p*Zg + r*Xg)*r;y[1] = M*(w + p*Yg - q*Xg)*p - M*(u + q*Zg - r*Yg)*r;y[2] = -M*(v - p*Zg + r*Xg)*p + M*(u + q*Zg - r*Yg)*q;y[3] = -M*(w + p*Yg - q*Xg)*v + M*(v - p*Zg + r*Xg)*w + (Iy-Iz)*q*r;y[4] = M*(w + p*Yg - q*Xg)*u - M*(u + q*Zg - r*Yg)*w + (Iz-Ix)*p*r ;y[5] = -M*(v - p*Zg + r*Xg)*u + M*(u + q*Zg - r*Yg)*v + (Ix-Iy)*p*q ;

static void mdlTerminate(SimStruct *S)

/* Simulink/real-Time Workshop Interface */

#ifdef MATLAB MEX FILE /* Is this file being compiled as a MEX-file? */#include ”simulink.c” /* MEX-file interface mechanism */#else#include ”cg sfun.h” /* Code generation registration function */

#endif

36

Page 37: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.3 Hydrodynamics

C.3 Hydrodynamics

#define S FUNCTION NAME hydrodynamique /* Defines and Includes */#define S FUNCTION LEVEL 2

#include ”simstruc.h”#include ”math.h”

/*——- forces de coriolis et centrifuges hydrodynamiques ——-*/

static void mdlInitializeSizes(SimStruct *S)/*—————– verifie le nombre de parametres —————-*/ssSetNumSFcnParams(S, 0);

if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return; /* Parameter mismatch will be reported by Simulink */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return;

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 12;int nb sortie = 6;/* definition de la taille du vecteur d’entree */dims = nb entree;di.width = nb entree;di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> vecteur 6*1 */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

37

Page 38: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);real T *y = ssGetOutputPortRealSignal(S,0);real T u, v, w, p, q, r; /* les variables d’etat a modifier */real T Xuu, Yvv, Yrv, Zww, Zqw, Kpp, Mwq, Mqq, Nvr, Nrr;

/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v *//* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//*——————————————————————*/u = *uPtrs[1];v = *uPtrs[3];w = *uPtrs[5];p = *uPtrs[7];q = *uPtrs[9];r = *uPtrs[11];

/* affectation des parametres */Xuu = -1.077300000000000e+002;Yvv = -6.464381742000000e+003;Yrv = -1.055827938122860e+004;Zww = -6.803174493360000e+003;Zqw = 4.307406275126168e+004;Kpp = -4000;Mwq = -1.455954419088000e+004;Mqq = -1.471447001500305e+005;Nvr = -1.427131471439232e+004;Nrr = -1.470090280295782e+005;

/*calcul de la sortie */y[0] = Xuu*u*fabs(u) ;/*u*/y[1] = Yvv*v*fabs(v) + Yrv*r*fabs(v);/*v*/y[2] = Zww*w*fabs(w) + Zqw*q*fabs(w);/*w*/y[3] = Kpp*p*fabs(p);/*p*/y[4] = Mwq*w*fabs(q) + Mqq*q*fabs(q);/*q*/y[5] = Nvr*v*fabs(r) + Nrr*r*fabs(r);/*r*/

38

Page 39: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.3 Hydrodynamics

static void mdlTerminate(SimStruct *S)

/* Simulink/Real-Time Workshop Interface */

#ifdef MATLAB MEX FILE /* Is this file being compiled as a MEX-file? */#include ”simulink.c” /* MEX-file interface mechanism */#else#include ”cg sfun.h” /* Code generation registration function */

#endif

39

Page 40: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

C.4 Weight and Archimedes

#define S FUNCTION NAME Gamma G /* Nmo de la fonction sous matlab */#define S FUNCTION LEVEL 2

#include ”simstruc.h”#include ”math.h”

/*—————— poids et poussee d’Archimede ——————*/

enum PARAM = 0, NUM PARAMS;

#define PARAM ARG ssGetSFcnParam(S, PARAM)

static void mdlInitializeSizes(SimStruct *S)/*—————– verifie le nombre de parametres —————-*/ssSetNumSFcnParams(S, NUM PARAMS);

#if defined(MATLAB MEX FILE) /* simulink et non real-time */if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return;

if (ssGetErrorStatus(S) != NULL) return;#endif

int iParam = 0;int nParam = ssGetNumSFcnParams(S); /*nb de parametre attendu*/

for ( iParam = 0; iParam < nParam; iParam++ )ssSetSFcnParamTunable( S, iParam, SS PRM TUNABLE ); /* on rend les parametres

modifiable */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return;

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/int T pWidth = mxGetNumberOfElements(PARAM ARG); /*nb parm*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 12;int nb sortie = 6;/* definition de la taille du vecteur d’entree */dims = nb entree;di.width = nb entree;

40

Page 41: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.4 Weight and Archimedes

di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> vecteur 6*1 */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);const real T *p = mxGetPr(PARAM ARG);real T *y = ssGetOutputPortRealSignal(S,0);real T THETA, PHI; /* les variables d’etat a modifier */real T delta, rho, M, g, Xg, Yg, Zg, Xf, Yf, Zf; /* les parametres */real T volume;/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v *//* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//*——————————————————————*/

PHI = *uPtrs[6];THETA = *uPtrs[8];

/*——————————————————————*//*– attention il faut rentrer les parametres dans cet ordre la!!!–*//*——————————————————————*//* PARAMETRES GLOBAUX : M rho delta g (Xg,Yg,Zg) (Xf,Yf,Zf) */delta = p[0];rho = p[1];

41

Page 42: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

M = p[2];g = p[3];Xg = p[4];Yg = p[5];Zg = p[6];Xf = p[7];Yf = p[8];Zf = p[9];volume=delta;

/* calcul de la sortie */y[0] = -(M - rho * volume) * g * sin(THETA);y[1] = (M - rho * volume) * g * cos(THETA) * sin(PHI);y[2] = (M - rho * volume) * g * cos(THETA) * cos(PHI);y[3] = (Yg*M - Yf*rho*volume)*g*cos(THETA)*cos(PHI) - (Zg*M - Zf*rho*volume)*g*cos(THETA)*sin(PHI);y[4] = -(Zg*M - Zf*rho*volume)*g*sin(THETA) - (Xg*M - Xf*rho*volume)*g*cos(THETA)*cos(PHI);y[5] = (Xg*M - Xf*rho*volume)*g*cos(THETA)*sin(PHI) + (Yg*M-Yf*rho*volume)*g*sin(THETA);/*y[0] = -(M - rho * delta) * g * sin(THETA);y[1] = (M - rho * delta) * g * cos(THETA) * sin(PHI);y[2] = (M - rho * delta) * g * cos(PHI) * cos(THETA);y[3] = (-(Zg * M - Zf * rho * delta) * g)* cos(THETA)*sin(PHI);y[4] = (-(Zg * M - Zf * rho * delta) * g)*sin(THETA);y[5] = 0;*/

static void mdlTerminate(SimStruct *S)

/* Simulink/Real-Time Workshop Interface */

#ifdef MATLAB MEX FILE /* Is this file being compiled as a MEX-file? */#include ”simulink.c” /* MEX-file interface mechanism */#else#include ”cg sfun.h” /* Code generation registration function */

#endif

42

Page 43: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.5 Actuator : fins

C.5 Actuator : fins

#define S FUNCTION NAME Prop gouv total /* Defines and Includes */#define S FUNCTION LEVEL 2#define PI 3.14159265358979323846

#include ”simstruc.h”#include ”math.h”

/*——————– Gamma u arriere vertical ——————–*/

enum PARAM = 0, NUM PARAMS;

#define PARAM ARG ssGetSFcnParam(S, PARAM)

static void mdlInitializeSizes(SimStruct *S)/*—————– verifie le nombre de parametres —————-*/ssSetNumSFcnParams(S, NUM PARAMS);

#if defined(MATLAB MEX FILE) /* simulink et non real-time */if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return;

if (ssGetErrorStatus(S) != NULL) return;#endif

int iParam = 0;int nParam = ssGetNumSFcnParams(S); /*nb de parametre attendu*/

for ( iParam = 0; iParam < nParam; iParam++ )ssSetSFcnParamTunable( S, iParam, SS PRM TUNABLE ); /* on rend les parametres

modifiable */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return;

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/int T pWidth = mxGetNumberOfElements(PARAM ARG); /*nb parm*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 18; /* on rajoute les consignes*/int nb sortie = 6;/* definition de la taille du vecteur d’entree */

43

Page 44: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

dims = nb entree;di.width = nb entree;di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> vecteur 3*1 */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);const real T *param = mxGetPr(PARAM ARG);real T *y = ssGetOutputPortRealSignal(S,0);

real T u, v, w, q;real T beta1max, beta2max, delta1max;real T beta1,beta1p, delta1, beta2, beta2p;real T fp, ft, vr, fp v, ft v, vr i, fp i, ft i, alpha1, alpha2, alpha3, alpha4;real T Fu1, Fv1, Fw1, Fu2, Fv2, Fw2, Mp1, Mq1, Mr1, Mp2, Mq2, Mr2, Fu3, Fv3, Fw3,

Fu4, Fv4, Fw4, Mp3, Mq3, Mr3, Mp4, Mq4, Mr4, Fu5, Fv5, Fw5, Mp5, Mq5, Mr5;real T u a, v a, w a, theta, F1, F2, F3, Fx, Fy, Fz, Fx2, Fy2, Fz2, Fx3, Fy3, Fz3, Cp;real T Mx, My, Mz, Mx2, My2, Mz2, Mx3, My3, Mz3;real T aile1x, aile1y, aile1z,aile2x, aile2y, aile2z, aile3x, aile3y, aile3z, aile4x, aile4y,

aile4z, aile5x, aile5y, aile5z;real T rho, CL, Sfin, CD, CD0;

real T fn1, ft1, fn2, ft2;/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v */

44

Page 45: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.5 Actuator : fins

/* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//* + commandes: X[12]=beta1 X[13]=beta1p X[14]=delta1 *//* X[15]=beta2 X[16]=beta2p X[17]=Qc *//*——————————————————————*/u = *uPtrs[1];v = *uPtrs[3];w = *uPtrs[5];q = *uPtrs[9];beta1 = *uPtrs[12];beta1p = *uPtrs[13];delta1 = *uPtrs[14];beta2 = *uPtrs[15];beta2p = *uPtrs[16];

/*——————————————————————*//*– attention il faut rentrer les parametres dans cet ordre la!!!–*//*——————————————————————*//* PARAMETRES GLOBAUX : rho, Dh, Zg, delta1, yd3, yd1, Cx */rho = param[0];CL = param[1];Sfin = param[2];CD = param[3];CD0 = param[4];beta1max = param[5];beta2max = param[6];delta1max = param[7];

/* centre de pression Cp*/Cp = 0.56/2+0.4/2;/*——————— Coordonnee des ailerons ———————*/aile1x = 0.716;aile1y = -0.518;aile1z = 0.;

aile2x = 0.716;aile2y = 0.518;aile2z = 0.;

aile3x = -1.276;aile3y = 0.;aile3z = (-Cp);

aile4x = -1.276;aile4y = -Cp*cos(30*PI/180);aile4z = Cp*sin(30*PI/180);

aile5x = -1.276;aile5y = Cp*cos(30*PI/180);aile5z = Cp*sin(30*PI/180);

45

Page 46: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

/*——————————————————————-*//*————————- ailerons avants ————————-*//*——————————————————————-*//* aile 1 */if (beta1 > beta1max)

beta1 = beta1max;else if (beta1 < -beta1max)

beta1 = -beta1max;

/* vitesse de l’eau sur l’aileron dans le referentiel vehicule*/u a = u;v a = v;w a = w;

if(fabs(u)< 0.001)alpha1=0;elsealpha1 = atan(w a/u a);

vr = pow(u a,2)+pow(w a,2); /*vitesse de l’eau sur la barre*/fp = 0.5 * rho * CL * Sfin * (beta1+alpha1) * vr ;ft = 0.5 * rho * CD * Sfin * pow((beta1 + alpha1),2) * vr + 0.5 * rho * CD0 *

Sfin * vr;

/* calcul de la sortie: projection sur les axes du repere mobile */Fu1 = fp * sin(alpha1) - ft * cos(alpha1);Fv1 = 0. ;Fw1 = -fp*cos(alpha1) - ft*sin(alpha1);/* calcul du moment du a un plan canard */Mp1 = aile1y*Fw1-aile1z*Fv1;Mq1 = aile1z*Fu1-aile1x*Fw1;Mr1 = aile1x*Fv1-aile1y*Fu1;

/* aile 2 */if (beta1p > beta1max)

beta1p = beta1max;else if (beta1p < -beta1max)

beta1p = -beta1max;

u a = u;v a = v;w a = w;

if(fabs(u)< 0.001)alpha1=0;elsealpha1 = atan(w a/u a);

46

Page 47: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.5 Actuator : fins

vr = pow(u a,2)+pow(w a,2);fp = 0.5 * rho * CL * Sfin * (beta1p+alpha1) * vr;ft = 0.5 * rho * CD * Sfin * pow((beta1p + alpha1),2) * vr + 0.5 * rho *

CD0 * Sfin * vr;

/* calcul de la sortie: projection sur les axes du repere mobile */Fu2 = fp * sin(alpha1) - ft * cos(alpha1);Fv2 = 0.;Fw2 = -fp*cos(alpha1) - ft*sin(alpha1);

/* calcul du moment du a un plan canard */Mp2 = aile2y*Fw2-aile2z*Fv2;Mq2 = aile2z*Fu2-aile2x*Fw2;Mr2 = aile2x*Fv2-aile2y*Fu2;

/*——————————————————————-*//*———————— ailerons arrieres ————————*//*——————————————————————-*/

/*———— Calcul de la force due a l’aile verticale ————*//* calcul de l’angle d’incidence de l’auv suivant y */if (delta1 > delta1max)

delta1 = delta1max;else if (delta1 < -delta1max)

delta1 = -delta1max;

u a = u;v a = w;w a = -v;

if(fabs(u a)>0.001)alpha2 = atan(w a/u a);elsealpha2 = 0;vr = pow(u a,2)+pow(w a,2);fp = 0.5 * rho * CL * Sfin * (delta1 + alpha2) * vr ;ft = 0.5 * rho * CD * Sfin * pow((delta1 + alpha2),2) * vr + 0.5 *

rho * CD0 * Sfin * vr;

Fu3 = fp * sin(alpha2) - ft * cos(alpha2);Fv3 = -fp * cos(alpha2) - ft * sin(alpha2);Fw3 = 0;

Mp3 = aile3y*Fw3-aile3z*Fv3;Mq3 = aile3z*Fu3-aile3x*Fw3;Mr3 = aile3x*Fv3-aile3y*Fu3;

/*———- Calcul de la force due a l’aile inclinee arr. droite ———

47

Page 48: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

-*//* calcul des vitesses dans le repere lie a l’aile*/if (beta2 > beta2max)

beta2 = beta2max;else if (beta2 < -beta2max)

beta2 = -beta2max;

theta = PI/6.0;u a = u;v a = v*cos(theta) - w*sin(theta);w a = v*sin(theta) + w*cos(theta);

if(u a==0) /*ici pa tout a fait la meme condition*/alpha3 = 0;elsealpha3 = atan(w a/u a);

vr = pow(u a,2)+pow(w a,2); /*vitesse de l’eau sur la barre*/fp = 0.5 * rho * CL * Sfin * (beta2 + alpha3) * vr ;ft = 0.5 * rho * CD * Sfin * pow((beta2 + alpha3),2) * vr

+ 0.5 * rho * CD0 * Sfin * vr;

/* forces exprimees dans le repere de l’aile */F1 = fp * sin(alpha3) - ft * cos(alpha3);F2 = -fp * cos(alpha3) - ft * sin(alpha3);F3 = 0;

/* projection dans le repere vehicule */theta = PI/6.0;/* matrice de transfert :1 0 00 cos(theta) -sin(theta)0 sin(theta) cos(theta)mais la troisiemme composante est nulle*/Fu4 = F1;Fv4 = sin(theta)*F2;Fw4 = cos(theta)*F2;

Mp4 = aile4y*Fw4-aile4z*Fv4;Mq4 = aile4z*Fu4-aile4x*Fw4;Mr4 = aile4x*Fv4-aile4y*Fu4;

/*——— Calcul de la force due a l’autre aile inclinee ———*/

if (beta2p > beta2max)beta2p = beta2max;else if (beta2p < -beta2max)

beta2p = -beta2max;

48

Page 49: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.5 Actuator : fins

/* calcul des vitesses dans le repere lie a l’aile*/theta = PI/6.0;u a = u;v a = v*cos(theta) + w*sin(theta);w a = -v*sin(theta) + w*cos(theta);

if(u a==0)alpha4=0;elsealpha4 = atan(w a/u a);vr = pow(u a,2)+pow(w a,2); /*vitesse de l’eau sur

la barre*/fp = 0.5 * rho * CL * Sfin * (beta2p + alpha4) * vr ;ft = 0.5 * rho * CD * Sfin * pow((beta2p + alpha4),2)

* vr + 0.5 * rho * CD0 * Sfin * vr;

/* forces exprimees dans le repere de l’aile */F1 = fp * sin(alpha4) - ft * cos(alpha4);F2 = -fp * cos(alpha4) - ft * sin(alpha4);F3 = 0;

/* projection dans le repere vehicule */theta = PI/6.0;/* matrice de transfert :1 0 00 cos(theta) -sin(theta)0 sin(theta) cos(theta)mais la troisiemme composante est nulle*/Fu5 = F1;Fv5 = -sin(theta)*F2;Fw5 = cos(theta)*F2;

Mp5 = aile5y*Fw5-aile5z*Fv5;Mq5 = aile5z*Fu5-aile5x*Fw5;Mr5 = aile5x*Fv5-aile5y*Fu5;/* calcul de la sortie */y[0] = Fu1 + Fu2 + Fu3 + Fu4 + Fu5;y[1] = Fv1 + Fv2 + Fv3 + Fv4 + Fv5;y[2] = Fw1 + Fw2 + Fw3 + Fw4 + Fw5;y[3] = Mp1 + Mp2 + Mp3 + Mp4 + Mp5;y[4] = Mq1 + Mq2 + Mq3 + Mq4 + Mq5;y[5] = Mr1 + Mr2 + Mr3 + Mr4 + Mr5;

static void mdlTerminate(SimStruct *S)

/* Simulink/Real-Time Workshop Interface */

49

Page 50: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

#ifdef MATLAB MEX FILE /* Is this file being com-piled as a MEX-file? */

#include ”simulink.c” /* MEX-file interface mecha-nism */

#else#include ”cg sfun.h” /* Code generation registration

function */#endif

50

Page 51: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.6 Actuator : propeller

C.6 Actuator : propeller

#define S FUNCTION NAME Propulsion helice /* Nom de la fonction sous matlab */#define S FUNCTION LEVEL 2#define PI 3.14159265358979323846

#include ”simstruc.h”#include ”math.h”

/*——————— propulsion principale ———————-*//*—- n’agit que suivant l’axe Ox (sur u) donc une seule sortie —-*/enum PARAM = 0, NUM PARAMS;

#define PARAM ARG ssGetSFcnParam(S, PARAM)

static void mdlInitializeSizes(SimStruct *S)/*—————– verifie le nombre de parametres —————-*/ssSetNumSFcnParams(S, NUM PARAMS);

#if defined(MATLAB MEX FILE) /* simulink et non real-time */if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return;

if (ssGetErrorStatus(S) != NULL) return;#endif

int iParam = 0;int nParam = ssGetNumSFcnParams(S); /*nb de parametre attendu*/

for ( iParam = 0; iParam < nParam; iParam++ )ssSetSFcnParamTunable( S, iParam, SS PRM TUNABLE ); /* on rend les parametres

modifiable */

/*———– verifie le nombre d’entre et de sortie = 1 ———–*/if (!ssSetNumInputPorts( S,1)) return; /* etat et consigne */

if (!ssSetNumOutputPorts(S,1)) return;/* une seule entree et une seule sortie de dim !=1 */

/*—— Definition de la taille de l’entree et de la sortie ——*/int T pWidth = mxGetNumberOfElements(PARAM ARG); /*nb parm*/DECL AND INIT DIMSINFO(di); /* Initializes structure */int dims;int nb entree = 18;/* 0->11: etat, 12->17: action*/int nb sortie = 6;/* definition de la taille du vecteur d’entree */dims = nb entree;

51

Page 52: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C FUNCTIONS CODE

di.width = nb entree;di.numDims = 1;di.dims = &dims;ssSetInputPortDimensionInfo(S, 0, &di);

/* definition de la taille du vecteur de sortie */dims = nb sortie;di.width = nb sortie;di.numDims = 1; /* -> scalaire */di.dims = &dims;if(!ssSetOutputPortDimensionInfo(S, 0, &di)) return;

ssSetInputPortDirectFeedThrough(S, 0, 1);ssSetNumSampleTimes(S, 1);

ssSetOptions(S, SS OPTION WORKS WITH CODE REUSE — SS OPTION EXCEPTION FREE CODE);end mdlInitializeSizes */

static void mdlInitializeSampleTimes(SimStruct *S)ssSetSampleTime(S, 0, INHERITED SAMPLE TIME);ssSetOffsetTime(S, 0, 0.0);ssSetModelReferenceSampleTimeDefaultInheritance(S);

end mdlInitializeSampleTimes */

static void mdlOutputs(SimStruct *S, int T tid)InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);const real T *p = mxGetPr(PARAM ARG);real T *y = ssGetOutputPortRealSignal(S,0);real T u, q, consignehelice; /* les variables dont on a besoin */real T N, Dh, Zg, rho, Ct1, Px; /* les parametres */

real T Va, J, Kt, tangbet, beta, w;real T ux, Xuu, u0;/*——————————————————————*//* recuperation de l’entree: le vecteur d’etat X *//* X[0]=x X[1]=u X[2]=y X[3]=v *//* X[4]=z X[5]=w X[6]=phi X[7]=p *//* X[8]=theta X[9]=q X[10]=psi X[11]=r *//* + commandes: X[12]=beta1 X[13]=beta1p X[14]=delta1 *//* X[15]=beta2 X[16]=beta2p X[17]=Qc *//*——————————————————————*/u = *uPtrs[1];q = *uPtrs[9];consignehelice = *uPtrs[17];/*——————————————————————*//*– attention il faut rentrer les parametres dans cet ordre la!!!–*/

52

Page 53: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

C.6 Actuator : propeller

/*——————————————————————*//* PARAMETRES GLOBAUX : N, Dh, Zg, rho, Ct1, Px, Xuu */N = p[0];Dh = p[1];Zg = p[2];rho = p[3];Ct1 = p[4];Px = p[5];/* nouvelle vitesse de rotation de l’helice en fonction de la consigne */

/*********************************************************************//******** pour tester un consigne constante sur la propulsion ********//* u0=consignehelice;*/ /* vitesse souhaitee *//* ux = -Xuu*pow(u0,2); */ /* pousse du propulseur*//* consignehelice = ux/Px;*//*********************************************************************/

N = sqrt(consignehelice*Px) * 2.24; /*2.24?*/ /*vitesse de rotation de l’helice*/Va = u + q * Zg; /* vitesse d’avance */if (N == 0) J = 0;else J = Va / (N * Dh); /* coefficient d’avance */

Kt = 0.369516 - 0.490246 * J + 0.182464 * pow(J, 2)- 0.391137 * pow(J,3);

w = Kt * rho * N * N * 0.25 * pow(1 / PI, 2) * pow(Dh,4);

if (w < 0)w=0;/* application de la sortie */y[0] = w;y[1] = 0;y[2] = 0;y[3] = 0;y[4] = 0;y[5] = 0;

static void mdlTerminate(SimStruct *S)

/* Simulink/Real-Time Workshop Interface */

#ifdef MATLAB MEX FILE /* Is this file being compiled as a MEX-file? */#include ”simulink.c” /* MEX-file interface mechanism */#else#include ”cg sfun.h” /* Code generation registration function */

#endif

53

Page 54: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

D MODELING OF AN AUV

D Modeling of an AUV

See document “Modelisation d’un vehicule sous-marin autonome type AsterX ”.

54

Page 55: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

REFERENCES

References

[1] Charles Poussot-Vassal, Commande robuste LPV multivariable de chassis automobile, Ph.D.thesis, Ecole doctorale Electronique, Electrotechnique, Automatique, Traitement du Signal,Grenoble-INP, Departement Automatique du GIPSA-lab, 2008.

[2] David Robert, Contribution a l’interaction commande / ordonnancement, Ph.D. thesis, Ecoledoctorale Electronique, Electrotechnique, Automatique, Traitement du Signal, Grenoble-INP,Departement Automatique du GIPSA-lab, 2007.

[3] David Robert, Olivier Sename, and Daniel Simon, An H∞ LPV design for sampling varyingcontrollers experimentation with a T inverted pendulum, IEEE Transactions on Control Sys-tems Technology 18 (2010), 741–749.

[4] Emilie Roche, Olivier Sename, and Daniel Simon, LPV / H∞ control of an autonomousunderwater vehicle (auv), European Control Conference, ECC’09, Budapest, Hungary (2009).

[5] Aristide Simon Santos, Contribution a la conception des sous-marins autonomes : Architecturedes actionneurs, architecture des capteurs d’altitude, et commandes referencees capteurs, Ph.D.thesis, Ecole nationale superieure des mines de paris, 1995.

[6] Sigurd Skogestad and Ian Postlethwaite, Multivariable feedback control - analysis and design,John Wiley & Sons, 1996.

67

Page 56: Robust control of autonomous underwater vehicles - … stage/rapport... · Robust control of autonomous underwater vehicles S ebastien Varrier Co-tutors : Daniel SIMON , Olivier SENAME

Abstract

My work is included in the framework of the FeedNetBack project. The objective of the project is

the collaborative control of several autonomous underwater vehicles (AUV). The first step of this

final year project is the realization of an efficient Matlab/Simulink model of the submersible, based

on Ifremer (marine vehicle constructor) data. Thus, the aim is to control the vehicle by synthesizing

robust controllers via a H∞ approach, since some parameters are over 70 % uncertain. This report

presents a control of the longitudinal speed (including a non linear compensation) and an original

structure of control in the vertical plan.

Resume

Mon travail s’inscrit dans le cadre du projet FeedNetBack. L’objectif du projet est le controle

collaboratif d’une flottille de plusieurs vehicules sous-marin. La premiere etape de ce projet de

fin d’etude consiste a realiser un modele Matlab/Simulink performant du sous-marin, a partir

de donnees de l’Ifremer (constructeur de vehicules marins). Par la suite, il est alors possible

de controler le vehicule en realisant un correcteur robuste via une approche H∞, car certains

parametres sont incertains a 70 %. Ce rapport presente une commande de la vitesse longitudinale

(avec compensation non lineaire) ansi qu’une structure originale pour la commande dans le plan

vertical.

Key words : Robust control, H∞ synthesis, submarine robot, underwater vehicle modeling,

autonomous underwater vehicle (AUV), non linear compensation.