Sei sulla pagina 1di 6

Hardware In The Loop Simulation Applied To

Semi-Autonomous Underwater Vehicles



Hilgad Montelo, Celso Massatoshi Furukawa
University of So Paulo
hmontelo@gmail.com, celso.furukawa@poli.usp.br

Abstract-Unmanned Underwater Vehicles (UUVs) have many
commercial, military, and scientific applications because of their
potential capabilities and significant cost-performance
improvements over traditional means of obtaining valuable
underwater information The development of a reliable sampling
and testing platform for these vehicles requires a thorough
system design and many costly at-sea trials during which
systems specifications can be validated. Modeling and simulation
provide a cost-effective measure to carry out preliminary
component, system (hardware and software), and mission testing
and verification, thereby reducing the number of potential
failures in at-sea trials. An accurate simulation environment can
help engineers to find hidden errors in the UUV embedded
software and gain insights into the UUV operation and
dynamics. This work describes the implementation of a UUV's
control algorithm using MATLAB/SIMULINK, its automatic
conversion to an executable code (in C++) and the verification of
its performance directly into the embedded computer using
simulations. It is detailed the necessary procedure to allow the
conversion of the models from MATLAB to C++ code,
integration of the control software with the real time operating
system used on the embedded computer (VxWorks) and the
developed strategy of Hardware In the Loop Simulation
(HILS). The Main contribution of this work is to present a
rational framework to support the final implementation of the
control software on the embedded computer, starting from the
model developed on an environment friendly to the control
engineers, like SIMULINK.
I. INTRODUCTION
Traditional tests, many times refereed as static tests, are the
evaluation of functionalities of a particular component where,
to it, are provided measurable inputs and outputs. The
growing of the demand for new products faster and a
consequent reduction of the development cycles associated to
the projects, has caused a increase on necessity to execute
dynamic tests, where the behavior of each component is
evaluated at same moment of its interaction with the rest of
the system and environment. Dynamic tests, in [7], minimize
risks related to the security and costs, covering more tests
conditions when compared to static tests. The application of
the test approach involving components of hardware,
software and dynamic or behavioral conditions is called
HILS.
The HILS, described by [3], is a tool that comes to aid the
work of the controls engineer. Unnumbered systems could
be developed faster only using an initial conceptual model
developed adapting or adjusting the necessary controls
variables (for instance: maximum supported pressure,
maximum speed, minimal temperature, maximum depth, bus
clock, minimal systems memory, etc), where a set of them
could be encapsulated into a configurations profile, validated
in a simulated or basic prototype, and, finally, verified in a
final target. Into this environment, the controls engineer
could to spend more time analyzing and detailing features to
solve the control problems related to the project, avoiding the
necessity to take much time writing or debugging lines of
firmwares code or even the necessity to handle with
complexities like time restrictions, establishment of priorities,
techniques to schedule tasks or load balance over the each
microprocessor or microcontroller used into the system.
The HILS could be applied to all systems, for research and
development; in the most assorted areas, like military,
medicine, automotive, air space, like indicated by [1], [5], [9],
[13], [20]... wherever could to exist an interaction between a
product in development and its environment of operation
(part of the real world) that is not so simple to represent it
complete and formally like some applications described by
[10], [15], [18], [21], [22]; then exists an opportunity to use
HILS.
The objective of this work is to present a rationale
approach to assist engineers during a project to develop a
semi-autonomous unmanned underwater vehicle Vehicles
that could realize part of its operations with or without the
remote human interference. A project where the final product
contains a lot of complex subsystems like: navigation, power
management, control of actuators, control of sensors, etc
all integrated and operating in an unpredictable and
sometimes hazardous environment: the undersea.

II. METODOLOGY
Development Environment: It consist, specifically, of the
assembly and utilization of a hardware with similar features
(preferentially) to those presented by the unmanned
underwater vehicle in development in the laboratory of
mechatronic engineer at Polytechnic School of So Paulo
(Escola Politcnica de So Paulo - EPUSP), allowing to make
a good utilization of the resources and solutions already in
research like described in [2], [8], [11], [12].
Real Time Operating Environment: VxWorks is a real
time operating system manufactured by Windriver Systems
and initial description could be found in [19]. Like others real
time operating systems, it includes a kernel that supports
multiple tasks and preemptive scheduling. Very popular in
embedded applications and widely used in a variety of
hardware architectures like: MIPS, PowerPC, SH-4, ARM,
StrongARM, xScale, and x86.
Real Time Framework: The Constellation consists of an
object oriented real time framework that provides capabilities
to interfacing and code generation from a model developed in
MATLAB/Simulink. The Constellation framework is
specified in [6]. The model could be converted in ANSI C++
programming language using all advantages of the objected
oriented programming and yet a high performance. The real
time capabilities are found in a middleware interface,
between the generated code and the real time environment.
The MATLABs real time workshop provides the necessary
elements to perform that relationship.
UUVs Dynamic: One of the first steps to realize an
appropriate simulation consists of the modeling of the
dynamic equations of the Hornet UUV, specified in [4] and
used in this work as a concept prove, due the fact that UUVs
model presents a simpler system of equations appropriate to
develop the necessary software interfaces to be used also by
others UUVs. The Fig. 1 presents the six degrees and the
respective derivatives used by a rigid body and its system of
coordinates in the Hornet UUVs model. Where: is the
linear movement relationship to the longitudinal axis; is the
linear movement relationship to the transversal axis; is the
linear movement relationship to the vertical axis; is the
angular or rotational movement over the X axis; is the
angular or rotational movement over the Y axis and is the
angular or rotational movement over the Z axis.
The inputs of the system are defined by the following set of
forces: : force applied by lateral thruster, : force applied
by frontal thruster, : force applied by vertical thruster,
: external disturbs or interferences like water
current for instance, : linear hydrodynamic drag force
as defined in (1), and studied by [16].


(1)
Where:
C
d
: Drag coefficient;
: Waters density;
A
p
: Projected drags area;
V
0
: Drags surface velocity;

The dynamic equations used to describe the vehicles
movement are developed in accordance with [14]. Taking the
sum of all forces in direction of the respective axis (X, Y, Z),
and solving its equations for acceleration, presented,
respectively, by (2), (3), and (4).


(2)


(3)


(4)

Where:
F
d(x,y,z)
: Defined in (1);
F
xext
= F
yext
= F
zext
= 0: Considering that there is not any
disturbance or current;
m: Vehicles mass.
W
auv
: Vehicles weight in water
(considering that the buoyancy
force is 0).

And taking the sum of the moments over the Z axis, it is
obtained the acceleration around that axis presented by (5):


(5)

Where:
D: Distance between the thrusters 1
(lateral thruster) and 2 (frontal
thruster)
M
zext
= 0: Sum of moments over Z axis
(Considering that there is not any
disturbance over Z axis).
I
z
: Inertia moment over Z axis.

For the simulation purposes those movement equations
contains eight state variables (x
1
, x
2
, x
3, ,
x
8
) and three
systems inputs independently controlled (F
x
, M
z
, F
z
)
presented by (6):







(6)
Where:
u: It is function of the three plants inputs: T
1
, T
2
, and
T
3
.


Fig. 1. Rigid body and its coordinate system.

The transformation matrix presented in (7) is responsible to
convert the rigid bodys output states found in plants model
into a coordinate value associated to a geographic reference
in the horizontal plan.


(7)

To obtain the coordinates in the vertical plan, it is sufficient
to calculate the superposition matrix of X
BG
.
The Fig. 2 shows the block diagram used to represent the
depth controller. The vehicle receives a command with the
desired depth (Z
desired
), it verifies the current depth (Z
actual
) and
apply an output to the thruster 3 (T
3
). Analyzing (4), it is
possible to see that the relationship between the depth and the
actuator responsible to adjust it (in this case, the thruster 3
T
3
) is simple and linear; therefore a PID (Proportional-
Derivative-Integral) controller is sufficient [23].

Where:
Z
desired
: Command of depth used by the mission
planner;
Z
actual
: Current depth gathered by the navigation
system;
: Depth error;
T
3
: Vertical thruster output;
K
p
: Proportional gain;
K
i
: Integral gain;
K
d
: Derivative gain.

For the establishment of the control of the velocity, a PID
controller also is provided using, in some cases; the velocity
gathered directly from the thruster (T
1
) instead the desired
velocity produced by mission planner to avoid problems
associated with the accuracy. The PID controller used to
control the velocity work together with the direction
controller, where, depending of the information about the
current direction, it is possible to increase or decrease the
vehicles velocity.
To control the vehicles direction, it was used a slide-mode
control, presented by Fig. 3 and also used by [24], that allows
errors in its sliding layer with about +/- 3 degrees and sliding
function defined by (8).

The direction controller uses the following parameters:
: Command of direction used by the mission
planner;
K
s
: Positive and negative limits used over the
thruster output;
h
1
: Error gain;
h
2
: Error rate gain;
T
1
and T
2
: Horizontal thrusters output.

The sliding function that allows to the slide-mode direction
controller decreases its error and error rate down to zero is
presented by (8).


(8)

Where:
h: It is a bi-dimensional array with the controllers
gains;
e: It is a bi-dimensional array that contains the
controllers error and error rate

Hardware In the Loop Simulation Environment: The
Fig. 4 shows a general overview of the HILS architecture
used to assist the development and construction of a semi-
autonomous underwater vehicle. It contains the main
components:
Embedded Hardware: It represents a clone of part of
the hardware used to produce the UUV. The inputs
consists of the forces generated by the environment
(like current, pressure, buoyancy, etc) and the forces
generated by the thrusters;
World Model: It consists the model used to represent
the physical world or, more precisely, a very close
representation of where the UUV will operate;
Control Parameters: They are the main and auxiliary
variables used to operate adequately the control
algorithms used by the UUV (For example: initial
velocity, initial acceleration, Initial position, error
adjusts for directions, maximum pressure allowed,
etc);
Sensors and Actuators: They represent the components
that allow the inputs and outputs of the system,
respectively. They could be real components
(hardware like compass, inclinometers, temperature
sensors, pressure sensors) or virtual (represented by
input/output files, for instance).
Data Logger: This component is responsible to register
all operations that are using this infra-structure, either
through a partial or total simulation. Only using the log
files and registers produced by this component is
possible to evaluate if a control algorithm is adequate
for the UUV and its environment of operation.


Fig. 2. Block Diagram of the PID depth controller. AUV (Autonomous
Underwater Vehicle) and UUV are used in this work with the same meaning.


Fig. 3. Block Diagram of the slide-mode direction controller.

The following steps are necessary to generate a useful code
compatible with the proposal hardware in the loop
architecture, based in an initial UUV's conceptual model.
To prepare the UUV's control model in Simulink
environment: It consists in the utilization of the
Simulink tool box and its control blocks (like S-
Functions, PID block, Plant block, etc). OBS: Before
the next step, it is important to eliminate any algebraic
loop in the model (loops where there is a direct
feedback between a output and input in the same
control block);
To convert the prepared UUV's control model in a
suitable software component compatible with the real
time framework adopted. There is a special tool
developed to achieve that objective where is possible
to specify event handlers, allows priority specification
and concurrent code;
To prepare the target environment and to configure its
real time operating system to establish all necessary
connections;
To configure the real time framework to operate either
with the operating system in target machine or with a
simulation environment (environment with the same
interfaces but not considering time restrictions);
To establish connection between the target machine
and the Matlab/Simulink environment using the
middleware provided by Constellation tools;
Trough the Data Logger component and tools like the
Matlab's shell, WindView or Stethoscope, see [17]; is
possible to evaluate and even update values of
monitored variables or statuses in run time to achieve
the timers and specified control conditions;
All generated firmware's code is in ANSI C++ not
allowing the utilization of templates (generic
programming) or even dynamic memory allocation
(temporally to avoid problems with garbage
collection, for instance).

III. RESULTS
The dynamic model and its respective control algorithm
published in [4]; was successfully reproduced in
Matlab/Simulink environment, also eliminating the
unnecessary algebraic loops with to lose the behavior
presented by the model.
The hardware in the loop environment and the UUV's
controller was embedded in a hardware developed in PC104
standard, using x86 architecture, the same configuration
presented by the UUV in development. Virtual sensors and
virtual actuators (like compass, inclinometers, depth's
sensors, thrusters, etc) also had its embedded and real time
representation stored directly into the target's file system.
For all graphs generated, the following procedure was
executed:
Samples representing the sensors were recorded in
format of files;
The converted and generated controller code read the
signal values and has calculated the respective
actuation signals used by the UUV's thrusters;
Thos actuation signals were recorded in file format and
used as input for the dynamic simulator, generating
information about velocity control, direction control,
and depth control.
To compare the results obtained with the implemented
HILS (identified by the label: "reproduzido") against
the adopted bibliographic material (identified by the
label: "original").

The Fig. 5 shows a direction plot of the path traversed by
the UUV in direction to a specific point.
The starting point (0, 0), the UUV traverses the known map
until reach the specified point, coordinates (35,35) in the map
and presenting a total distance of about 49 meters. The results
are compatible with the results presented by [4].

Fig. 4. Overview of the HILS used to assist the development of UUV.


Fig. 5. Overview of the traversed path by UUV in direction of a point.
In the graph presented in Fig. 6, the UUV when traversing
in direction of its target, initially receives a first command to
descend 61 meters (it takes about 30 meters until the UUV
completes the submersion procedure) and, at 350 meters, the
UUV receives command to start the emersion procedure with
5 meters and 55 meters, respectively. The UUV remains at 1
meter of the surface. The PID depth's controller had a good
performance with K
p
= 10, K
i
= 0, and K
d
= 5.
The results of the PID velocity's controller presented in
Fig. 7 had presented some problems to reproduce the original
model and keep a stable value. There was an almost constant
switching due the high error rate. Nevertheless, the UUV has
continued its trajectory, presenting a similar behavior (but
with more attention and careful by engineers) when compared
with the same dynamic model in the original work.

It is very important that, even after a correct code
generation, to investigate if that code is capable to be
executed in an embedded and real time environment, not
exceeding the limitations and restrictions of the system. For
instance, the Fig. 8 presents a snapshot of the control cycles,
encapsulated by the task "CSSysClockData" (into the red
circles). The total time for each task is about 20 ms (see the
red bars) and, the time consumed by the task analysis is about
2ms. In other words, the task is taking only 15% of the total
time that could be expended to perform all its internal
operations. Therefore, the chosen hardware is adequate to
implement the proposal UUV's control algorithm.

IV. CONCLUSIONS
The UUV's dynamic model was successfully reproduced in
Matlab/Simulink. The simulation results are compatible with
the available literature, even after the addition of some delays
to avoid the generation of algebraic loops.
The suggested HILS approach has worked as expected,
presenting a coherent behavior during the reading of a
Matlab/Simulink model, conversion of that model in an
executable software code and providing a final validation of
utilization of resources of time and memory through the
interaction with a real time and embedded platform. That
validation could imply in a better and optimized chosen of
hardware.
Different tools could be attached to the HILS process to
provide more information about the run time environment of
the UUV's controller and, if necessary, to adjust variables and
conditions.
Parts of the complexity to handle with embedded and real
time restrictions, synchronization techniques, task's
scheduling, priorities, etc... They could be taken in a more
transparent way, aiding the control engineers to concern with
more specific problems.
Problems that involves remotely download and upload
packets of code suggest a new and a more effective handling
for the tasks related to communication process, improving
stacks, buffers, queuing policies, etc.

ACKNOWLEDGMENT
To our families and friends for encouraging the crowd
standing and successful completion of this work; To FINEP
than through one of its research funds, the CT-PETRO,
allowed some of the funding of this work; To CNPq
(National Council for Scientific and Technological
Development Conselho Nacional de Desenvolvimento
Cientfico e Tecnolgico), for having awarded the scholarship
to complete this Master in Science work, and finally to the
University of So Paulo and their collaborators - who
introduced the graduate program in Mechanical Engineer,
innovating in the environment of academic teaching.

Fig. 6. Path traversed by the UUV to test the PID depth's controller.

Fig. 7. Performance of the PID velocity's controller.
Fig. 8. Run time context switch between controller's tasks.

REFERENCES
[1] S. Alles, C. Swick and M. Hoffman. "A Real Time Hardware in the
Loop Simulation for Traction Assist," International Journal of Vehicle
Design, 1994. Vols. 15, pp. 597-625.
[2] P.E. Almeida., M.G. Simoes. "Projeto de um sistema robtico
inteligente para instalao de equipamentos em poos petrolferos em
guas profundas," IV SBAI Simpsio Brasileiro de Automao
Inteligente. So Paulo. 1999.
[3] W.K. Anakawa et al. "Environments for rapid implementation of
control algorithms and hardware in the loop simulation," In IEEE 28th
Annual Conference of the Industrial Electronics Society, 2002.
[4] T. Braunl et al. "The Autonomous Underwater Vehicle Initiative
Project Mako". IEEE Conference on Robotics, Automation, and
Mechatronics (IEEE-RAM), Singapore . 2004. Vols. pp: 446-451.
[5] D.P. Brutzman, Y. Kanayama and M. J. Zida. Integrated Simulation
for Rapid Development of Autonomous Underwater Vehicles. IEEE
Symposium On Autonomous Underwater Vehicle Technology, 1992.
[6] Constellation. Constellation, Real-Time Software Framework". Real-
Time Innovations, Inc, 2005.
[7] S.E. Duno, M. Smith and P. Betzer. Design of Autonomous
Underwater Vehicles for Coastal Oceanography, Underwater Robotic
Vehicles. Design and Control. TSI Press, 1994. Vols. pp. 229-326.
[8] A. Jansson and J.O. Palmberg. Load simulation, a flexible tool for
assessing the performance of hydraulic valves. In Proceedings of the
Fourth Triennial International Symposium on Fluid Control, Fluid
Measurement, and Visualisation, Toulouse, France, 1994.
[9] C. Key. Cooperative Planning in the Pilots Associate. Proc. DARPA
Knowledge-Based Planning Workshop, 1987.
[10] J. Kim and A. Srinivan. "Computationally efficient technique for real
time surgical simulation with force feedback". Proc. 10th Sym. On
Haptic Interfaces For Virtual Environment & Teleoperator Systems,
2002.
[11] F.V. Lima, C.M. Furukawa. Development of a High Resolution
Underwater Positioning System. XIV COBEM Brazilian Congress of
Mechanical Engineer. 2003.
[12] F.V. Lima. Desenvolvimento de um Sistema Acstico de
Posicionamento Submarino. Master in Science thesis presented to
Escola Politcnica da USP. So Paulo. 2003.
[13] D. Maclay. Simulation Gets Into the Loop, IEEE Review, 1997.
[14] N. Olgac, B.E. Platin and J.M. Chang. Sliding Mode Control of
Remotely Operated Vehicles for Horizontal Plane Motions, IEEE
Proceedings, 1991. Vol. 138.
[15] E.A. Prasetiawan et al. "Modeling and control design of a powertrain
simulation testbed for earthmoving vehicles," Journal of Fluid Power
Systems and Technology, 1999.
[16] J.A. Roberson and C.T. Crowe. "Engineering Fluid Mechanics," John
Wiley & Sons, New York, 1997. Vol. Sixth Edition.
[17] Scopetools. "Windriver's ScopeTools Suite," Windriver Corp., 2005.
[18] Y. Senta and E. Okamura. "HIL simulation system for hdd servo
firmware," IEEE Transactions on Magnetics, 2002. pp: 2204-2207.
[19] VxWorks. "Windriver - VxWorks Programmer's Guide," Windriver,
2005. Vol. 5.5.
[20] Y. Yuroda, K. Aramik and T. Ura. AUV Test Using Real/Virtual
Synthetic World, IEEE Symp. On Autonomous Underwater Vehicle
Technology, 1996.
[21] R. Zhang, D.E. Carter and A.G. Alleyne. "Multivariable control of an
earthmoving vehicle powertrain experimentally validated in an
emulated working cycle". In Proc ASME International Mechanical
Engineering Congress & Exposition. Washington, 2003.
[22] L. Zhen, M. Kyte and B. Johnson. "Hardware in the loop real-time
simulation interface software design," In Proc of The 7th International
IEEE Conference on Intelligent Transportation Systems, 2004. pp:
1012-1017.
[23] K. Ogata. Modern Control Engineering, " Prentice Hall. New Jersey,
1997. Vol. Third Edition.
[24] R.A. Decarlo., S.H. Hak and S.V. Draukunov. Variable Structure,
Sliding-Mode Controller Design.," In The Control Handbook, CRC
Press. Florida, 1996

Potrebbero piacerti anche