Mechatronic Modelling of Industrial AGVs: A Complex System Architecture

Automatic guided vehicles (AGVs) are unmanned transport vehicles widely used in the industry to substitute manned industrial trucks and conveyors..ey are now considered to play a key role in the development of the Industry 4.0 due to their temporal and spatial flexibility. However, in order to deal with the AGV as a potential mobile robot with high capacities and certain level of intelligence, it is necessary to develop control-oriented models of these complex and nonlinear systems. In this paper, the modelling of this vehicle as a whole is addressed. It can be considered composed of several interrelated subsystems: control, safety, driving, guiding and localization, power storage, and charging systems..e kinematics equations of a tricycle vehicle are obtained, and a controller is proposed. An extended hybrid automata formalism is used to define the behaviour of the safety and the control systems, as well as their interaction. In addition, the electrical equivalent circuit of the batteries, charger, and the motors is studied. .e architecture of the holistic model is presented. Simulation results of the AGV in a workspace scenario validate the model and prove the efficiency of this approach.


Introduction
Automatic guided vehicles (AGVs) are unmanned transport vehicles widely used in the industry to substitute manned industrial trucks and conveyors [1]. ey have been proved an efficient element in factory workspaces, helping to reduce logistic errors and operative costs.
Many researchers in manufacturing systems recognize the following Industry 4.0 (I4.0) design principles: interoperability, virtualization, decentralization, real-time capability, service orientation, and modularity. All these principles are connected in some way with the operative of the AGVs. For example, AGVs can easily readjust their program ensuring real-time reaction to unexpected changes in the logistic flows of the production plan. ey can also operate in a decentralized way, without any central server commanding orders.
On the other hand, several I4.0 key enabling technologies have been identified in the literature to make these principles possible: autonomous robots, additive manufacturing, simulation, system integration, cloud computing, Internet of things, cybersecurity, augmented reality, and big data. AGVs are included into the category of autonomous robots as one of these technologies. In addition, this AGV can be easily interconnected and integrated with other machines and devices in the plant by its input/output subsystem. Moreover, these AGVs generate a large amount of data which are transported by IOT protocols such as MQTT, stored and processed by cloud computing systems, and can be exploited by big data technologies to obtain KPIs and optimize the production.
For all these reasons, they are now considered to play a key role in the development of the Industry 4.0. Even more, the new concept of collaborative mobile robots seeks the convergence of AGVs and collaborative robots [2].
However, this synergy demands to deal with the AGV as a potential mobile robot with high capacities and certain level of intelligence. us, the necessity of control-oriented models of these complex and strong nonlinear systems is clear. Even more, to take these robots to a further step, understanding their behavior and establishing safety requirements are a must. is will allow them to advance from assembly tasks to a genuine human-robot collaboration.
An AGV is a multivariable complex mechatronic system composed of several subsystems and with a strongly coupled dynamics. Each of the main elements of an AGV influences its dynamics. e power storage affects the control performance and the motion of the AGV. In turn, the control influences the power consumption and thus the power storage. An AGV usually works in a space shared with other robots, so these other vehicles or even people are perceived as obstacles by the safety subsystem that modifies the working conditions accordingly.
Even more, AGVs are normally used to automate logistics and production flows. ese processes involve managing a fleet of robots traveling on the same scenario. Indeed, it is considered a multilayer problem [3], where several issues have to be addressed: the design of the layouts, the warehouse and the production plant, the storage strategies, the traffic scheduling, algorithms to share the charging stations, path planning, navigation, routes assignation, and so on. To take all of these simultaneous processes into account, a global model is necessary. is model will also allow to improve the efficiency of these vehicles and the production optimization.
In this paper, we address the modelling and simulation of an AGV as a whole. First, an architecture that relates all the subsystems that are part of the AGV is proposed. en, each of them has been described and mathematically modelled: the control, safety, driving, guiding and localization, power storage, and charging systems. Besides, the kinematics and dynamics equations of the vehicle are developed. ey have been implemented for a real industrial complex AGV, a hybrid tricycle-differential one. is holistic approach gives realistic results in the simulations of the vehicle, which allows us to validate the models. e main contributions of this work can be summarized as follows: (i) e development of a general and high level of the abstraction model of an AGV. It has been divided into subsystems whose models can be used to implement different types of AGVs. (ii) e identification of all the interactions between the subsystems and its integration. (iii) e development of the mathematical model of the dynamics of a hybrid differential-tricycle AGV (this hybrid differential-tricycle AGV has not been previously studied in the literature). (iv) e mathematical description of the safety subsystem and the control subsystem based on the hybrid automata formalism. is approach is completely original.
(v) e implementation of this general model into a specific model of a real industrial AGV, the Unibot AGV of the company ASTI Mobile Robotics [4].
(vi) e integration of the kinematics, dynamics, and electrical equations in the simulation of this type of AGV.
e rest of the paper is organized as follows. Section 2 presents a brief state of the art on the AGV modelling. In Section 3, the architecture of the AGV is developed. e description and equations of the different subsystems which compose it are presented in Section 4. Simulation results on a working scenario are discussed in Section 5. e document ends with the conclusions and future works.

Related Works
e first paper published on the design and operation of AGV systems was the work by Maxwell and Muckstadt, in 1982 [5], where a methodological framework for specifying the operational characteristics of an automatic guided vehicle system was presented. Since then, the research on this topic has not stopped growing. Nevertheless, the works found in the literature mainly tackle the system focusing on individual aspects of the AGV: kinematics, control, charging, and so on, that are not independent. Indeed, the majority focus on its kinematics and control, or the localization algorithms, or the power storage, or the charging system, but they lack a holistic approach of the guided vehicle as a whole system.
ere have been several attempts to model the AGV, for example, Veiga et al. compared vehicle models of a tuggertrolleys system with three linked towed. One model is a complete multibody model of the system. e second is a simplified version composed of vertical and handling models for motion in a plane, assuming no planar forces on the trolleys' front wheels and linking the vehicles with multibody joints and body, representing the coupling arms, developed in Modelica language. Results show good agreement between the models but the second one was much faster and provided more stable results [6].
A kinematical and dynamical analysis of a mobile robot belonging to the configuration classical tricycle is shown in [7]. For the kinematical analysis, authors consider a robot capable of locomotion on a surface by the action of wheels mounted on the robot. e dynamics of the nonholonomic mobile robot is obtained based on the Euler-Lagrange methodology. e paper is focused on the analysis of global asymptotic stability of a new position controller for this wheeled mobile robot.
In [8], authors state that the complexity of AGV dynamics and the difficulty of obtaining the actual vehicle dynamic parameters have led them to use two nonmodelbased control approaches. e robot is equipped with a front-centered steerable wheel and fixed parallel rear wheels. ey present a comparison of control techniques for robust docking maneuvers of an AGV, specifically, fuzzy control and vector pursuit that do not require a mathematical model of the vehicle dynamics.
Recently, Montazerijouybari et al. proposed a mathematical model based on the kinematics of 2-DOF AGVs with differential driving wheels and caster wheels in order to 2 Complexity predict the behaviour of the robot when the vehicle is carrying heavy loads not well distributed on it. A trajectory tracking control of an AGV based on sliding mode control with an improved reaching law is proposed in [9]. e AGV in this paper has two driving wheels and two universal wheels. ey consider a fully functional AGV composed of the motion mechanism, the sensing system, and the control system. Authors do not consider the rest of the systems of the vehicle. e work designs a double closedloop control method to control the vehicle to track the given trajectory. With the same control-oriented aim, in [10], the analysis of the kinematics and dynamics of a four-wheel omnidirectional automated guided vehicle is presented.
ere are other AGV-related topics that are dealt with in this paper, such as localization and navigation. In many cases, the routes implemented by these vehicles are subject to constant changes and are adapted to the currently assigned task. us, the sensors that allow the AGV to follow the path are an important element of the guided vehicle. Although usually the vehicle sensors are not modelled, the most common ones have been studied. Just a couple of examples are as follows. An intelligent path recognition system for vision-guided AGVs, able to tackle noise in the images captured by using a CCD camera, is presented in [11]. e paper addresses some of the most challenging problems for a vision-based AGV running in a complex workspace and improves the accuracy and reliability of vision recognition of guide paths for AGVs by means of artificial intelligence methods. Authors in [12] proposed an interesting method to measure the wheel radius. is radius is not constant, and in the case of automated guided vehicles using odometry, this is a key information to calculate the position of the vehicle. Stetter et al. designed virtual sensors that estimate forces and torques acting on an AGV [13]. However, this AGVs consists of four sprung arms that each dispose of one drive motor. For this system, they obtain a simple description of the AGV dynamics and then develop a set of virtual sensors that enables estimation of the forces and torques. Indeed, authors say that they try to avoid the use of complex tire models. e study is meant for several diagnostic purposes such as fault detection or fault prevention.
Another AGV component, the charging system, has been also the object of study by some authors. For instance, a battery management simulation is developed for evaluating battery-related costs under various AGV operation modes and for designing battery management strategies [14]. Hou et al. developed a novel energy modelling method which allows to calculate and predict the AGV energy consumption [15]. However, in this work,we do not consider energy efficiency either the design of the battery, but the simulation of the electrical performance of the AGV's battery. e charging method is out of the scope of this paper.
Finally, there are several works about the control of a fleet of AGVs. A detailed state of art on the design and control of several AGVs is presented in [16]. In this paper, author discusses the literature concerning the usage of AGVs in manufacturing and other new areas of these vehicle application, namely, distribution, transshipment, and transportation systems. As a conclusion, the author states that the most important differences between the usage of AGVs in manufacturing areas and in other environments can be noticed in the number of AGVs used. Besides, the author claims the necessity of analytical and simulation models which simultaneously address multiple design and control problems. Different vehicle platooning control strategies are presented in [17,18].
As shown above, most of the studies found in the literature are mainly focused on individual aspects of the AGV design problem: kinematics, control, guiding, energy, and so on. However, these components are not independent; indeed, these subsystems are highly coupled. erefore, a holistic and complete vision of these automatic vehicles is missing, where the interactions among their various elements are evident in the models used so that the simulation is realistic.

Description of the Industrial AGV Architecture
ere are different ways to split up an AGV into its different parts. We have considered the following interconnected subsystems that describe the whole behaviour of the vehicle: driving system, guiding and localization system, safety system, motors, power storage and charging, and control system. ese elements interact with the working environment. Figure 1 shows the AGV architecture with all the mentioned systems and their relationships.
e control system can be considered the brain of the AGV. Depending on the localization, on the external inputs and the current state, it adjusts the charging system, generates target signals for the driving system, commands the outputs, and adjusts the safety system. e driving system collects the dynamic and kinematic of the AGV motion; it changes the position and orientation of the AGV and modifies the working environment. It also gives information about the current to the control system in order to close the control loop.
e driving system is the component that demands more energy from the power system. e safety system detects obstacles in the safety zone and warns the control system; it can even trigger an emergency stop. e charging system is responsible for recovering the energy of the power storage system. is subsystem is usually placed out of the vehicle when there is not enough space in the AGV. e power storage is in charge of providing energy to the electronic components and the motors. e guiding and localization system (GLS) manages AGV position and attitude measures, which are used by the control system. Depending on the technologies used to implement the GLS, this information will have greater precision.
ere are technologies, such as simultaneous localization and mapping (SLAM), which provide information about the absolute coordinates (x, y, angle) of the AGV with high accuracy. Others only provide the deviation respect to a predefined trajectory, either marked on the floor or buried, such as magnetic antennas, optical sensors, and so on, and must be complemented with a localization system such as RFID tag sensors (low accuracy) or UWB devices (medium accuracy) to know the absolute position.

Complexity 3
On the other hand, the input/output system allows to introduce information to the AGV from other external sources: machines, operators, and so on, and extract information. Finally, the workspace represents the external environment and everything that can produce any changes to the AGV behaviour.
In this paper, we are going to model a hybrid differentialtricycle AGV. is vehicle has been selected because nowadays is one of the most used AGVs in the industry. An example of this type of AGVs is the Unibot AGV of the company ASTI Mobile Robotics [4], represented in Figure 2.
e Unibot is mainly used to convey loads by pulling carts. is vehicle is robust, simple, flexible, and reliable and well-established in the market vehicles.
ough with reduced dimensions, it has great load capacity. It is fully connected in real time.
is industrial tow AGV can be used in whatever industry where medium loads need to be towed. However, it achieves its full potential in enterprises where recurrent flows of pieces and/or products exist. ey can be applied in any SMEs and large companies (for further information on enterprise categories see [19]) although it is commonly found in the automotive industry as it is one of the most automatized sectors. Moreover, it is easy to include them in already functioning enterprises as these automatic guided vehicles do not require to modify the infrastructure in order to implement the layout. Indeed, the layout can be usually easily removed and moved to adapt it to changes in the production plant. However, also in companies that are going to start the production, it is possible to design the plant taking into account the layouts of the AGVs to optimize the intralogistics.
In addition, it has many other functionalities such as magnetic guidance/navigation system (surface/buried), online charging system, safety laser for internal environment, safety PLC, and emergency stop button, among others.
is is a complex system because it has two wheels as a differential robot and a tricycle configuration in the front part. Most of the models found in the literature work as differential robots.

Driving System.
ere are many types of AGVs regarding the kinematics, but four different models can be typically identified: tricycle, differential, quad, and omnidirectional. Figure 3 shows some standard configurations of the wheels for these AGVs. Depending on the number and type of the wheels, the kinematic constraints and the control variables of the vehicle will vary. e drive wheels provide traction but cannot change its direction. e steer wheels can change the direction but cannot provide traction. e steer and drive wheels provide both things, and they are also called motor-wheels.
All of these wheels are subjected to nonholonomic constraints to prevent wheel lateral slipping. is can disrupt the control of the vehicle and must be avoided. By contrast, the omnidirectional wheels only provide traction, but they are not affected by the nonholonomic constraints. In fact, the omni-wheels are equipped with rollers to enable the lateral slipping.
e Unibot AGV [4] is a mixture of tricycle and differential.
e traction head is a differential robot; meanwhile, the body is linked with the traction unit by an axle, and it performs as a tricycle. e wheels of the body do not provide traction but support the weight of the vehicle and allow the body to follow the traction head.
As said before, the driving system includes the dynamics and the kinematics of the AGV motion. erefore, in this section, both the kinematic and dynamic models of the hybrid tricycle-differential AGV are developed. To do it, the kinematic equations of the individual traction tricycle and differential units are combined in a novel way as the hybrid tricycle-differential AGV has not been previously studied in the literature. In addition, the dynamic model of the vehicle has been developed by the authors using the Newton-Euler fundamental equations of the translational and rotational dynamics. Figure 4 represents the mechanical components of this AGV and the coordinate system (traction head, green square and AGV body, blue rectangle). e center of the wheels of the traction head in the inertial coordinate system is represented by (x h , y h ), and the position of the center of the wheels of the body is (x b , y b ), both in m. In this inertial frame, the attitude of the body is Φ b (rad) and the attitude of the head is Φ h (rad); the angle between the body and the head is c (rad). L b is the distance between (x b , y b ) and (x h , y h ) in m, and L h is the distance between the wheels of the traction unit in m. e equations of the traction head are given by the kinematic model of a differential robot [20]. at is, On the other hand, the motion of the body follows the equations of a tricycle: Guiding + localization system Driving system

Safety system
Control system Workspace Power storage Charging system AGV Input/ output system Figure 1: Subsystems AGV architecture. 4 Complexity where v h is the longitudinal velocity of the steering drive (m/ s), i.e., the traction head speed. ese equations (1) and (2) are linked by the following expressions: where c min and c max are the mechanical limits of the angle of the traction head (rad). ese mechanical limits are set to avoid damage in the wires between the body and the traction head.
Besides, in order to prevent sliding in the wheels, the following constraints must be met, equation (4) for the rear wheels and equation (5) for the front wheels: with L b is the distance between the center of the traction head and the rear axle. By the translational and rotational Newton-Euler dynamic equations, the following expressions that represent the forces and momentums are obtained: where m T (kg) is the total mass of the system, that is, the mass of the AGV, m AGV (kg), plus the mass of the load, m L (kg); the radius of the wheels in the traction unit is R h (m); I h is the rotational inertia of the traction unit (kg m 2 ); € θ r and € θ l are the angular accelerations of the right and left wheel of the traction unit (rad/s 2 ), respectively;M er and M el are the effective torques in the right and left wheel of the traction unit (Nm); f rT is the translational friction force (N); M rR is the friction torque (Nm); δ air is the density of the air (Kg/ m 3 ); S AGV is the front surface of the air (m 2 ); C aero is the aerodynamic coefficient; C roll is the rolling coefficient; g is the acceleration of the gravity; F vh and F sh are the viscous and static friction coefficients in the traction unit (Nm and Nms/rad); F vw and F sw are the viscous and static friction coefficients in the wheels (Nm and Nms/rad); M er and M el are the torques produced by the motors (Nm); and sign is the sign function. e effect of the inertia of the wheels has been neglected. It has been supposed that the AGV is working in an indoor environment, and the wind speed is zero. Moreover, in the simulations, the slippage has been considered. e slippage happens when the traction force exceeds the surface friction force. e traction forces in the front wheels are given by M er /R h and M el /R h . erefore, to avoid the slippage, the following constraints must be fulfilled:

Body
Traction head Figure 4: Unibot AGV driving system and the coordinate system.

Complexity 5
where μ is the friction coefficient. e number 4 that appears in the denominator means that the weight of the AGV is equally distributed into the four wheels.

Safety System.
In this section, we develop the mathematical model of a general safety subsystem applying a new approach to do this, the hybrid automata formalism. e safety system is in charge of preventing collisions with humans and objects. e safety norms establish that the AGV must stop in the near presence of obstacles. is normally leads to introduce a processor in the safety system to take the control and trigger an emergency stop command when the control system is not operative. Figure 5 shows the interactions between the driving, the safety, and the control systems. e safety system monitors the velocities of the wheels (v l , v r ) by encoders. If the current longitudinal velocity is higher than the predefined current safety velocity, v safe , during a configurable period of time, then the safety system fires an emergency stop procedure.
is is represented in Figure 5 as the stop signal. Normally, this is carried out by acting directly on the brake of the vehicle or on the motors. e control system is also informed about this anomaly situation by the stop signal.
On the other hand, the control system notifies the safety system about what type of safety zones must be activated at each moment. ese safety zones are polygonal areas where there cannot be obstacles. Each zone has a code∈ N and a maximum velocity, v safe ∈ R (m/s), which is calculated considering the deceleration rate of the AGV to ensure that it is able to stop before a collision. e control system knows the location of the AGV and, for instance, if the AGV is towing a trolley, the safety zones must be big enough to cover it. Moreover, if the AGV is going to turn left, the safety zones must be defined on this side of the AGV. If the safety system detects an obstacle inside the safety perimeter, it automatically sends the code of the zone to the control system, with the signal code, and updates the safety velocity. e AGV safety system is equipped with different types of sensors: mechanical, ultrasounds, infrared, or LIDAR, to detect the obstacles. In the Unibot AGV, the safety system has a PLC and a LIDAR sensor installed in the front of the vehicle. e safety zones can be mathematically defined as a set Z i ⊆R 4 of pairs of points relative to the center of the LIDAR (x LID , y LID ). In addition, each safety zone can be classified as warning zone or error zone. erefore, by the union of all zones, it is possible to conform the set e LIDAR returns a set of distance measures, P DIST , that are defined in polar coordinates as follows: where res is the angular resolution, and θ min and θ max are minimum and maximum angles detected by the LIDAR. is set may be transformed to Cartesian coordinates by the following function: (1) e subset of allowed zones, Zones EN ⊆Zones, is obtained according to the type of zone, type zone , selected by the control system. e safety PLC checks if any of the points in P XY belongs to the set of allowed zones by the function: f zone : P XY ⟶ Zones EN (9).
where the function Polygon(z): Z i ⟶ (R, R) M gives the list of points within the perimeter of the safety zone. If there is not any obstacle in an allowed safety zone, the zone given by (10) is (∅, 0, v smax ), being v smax (m/s) the AGV maximum velocity. is v smax is usually defined in the datasheet of the vehicle, and it normally goes from 0.8 m/s to 2 m/s. If more than one zone is obtained by (10), the safety velocity, v safe , is set as the minimum safe velocity. is can be expressed as follows: e model of the safety controller can be described by the hybrid automata formalism. A hybrid automata is a formal model that combines discrete control graphs, usually called finite state automata, with continuously evolving variables. An extension to the hybrid automata H defined in [21] is a tuple H � (Q, X, U, Y, Init, D, Dom, E, G, R), where (i) Q is a set of discrete variables, and Q is countable.
Also it is also known as the set of discrete states of the automata. (ii) X is a set of continuous variables, that is, the set of continuous state variables of the automata. (iii) U is a set of input variables. 6 Complexity Let Q � q 1 , q 2 , q 3 , q 4 be the set of discrete variables; code is the set of output variables, and Init � q 1 , t � 0, stop � 0 ∈ Q × X × U is the initial. When the variable stop � 1, the emergency stop is triggered. As expected, the safety controller receives as inputs the velocity of the wheels, the type of allowed zones, and the points measured by the LIDAR; its output is the stop signal, the current safe velocity, and the code of the active safety zone. e differential equations are given by and Do m(q 4 ) � t ∈ R < t 4 . In addition, the discrete transitions are given by e guard conditions are the following: where v safe is calculated as a function of type zone and P DIST by equations (9)-(11) and t 2 and t 4 are parameters of the safety controller which can be adjusted by the user. e reset relations can be expressed as follows: e outputs: v safe and code, are calculated in the same way for all discrete states, by equations (10) and (11); thus, they have not been included in (15)- (17). To summarize, if an obstacle is detected in a warning zone, the maximum allowed speed is reduced. If the obstacle is in an error zone, the maximum speed is automatically set to zero. In both cases, the control system receives a warning, and it must follow the commands of Code v safe (v l , v r ) Figure 5: Interactions between driving system, safety system, and the control system. the safety system. If the safety system detects that the AGV velocity is higher than the allowed speed for a period of time, the safety chain is broken and the vehicle is stopped.

Guiding and Localization System
e guiding and localization functionalities of the AGV can be implemented by only one device, such as a navigation system based on laser reflectors or the SLAM navigation systems. Both technologies are commonly complemented with the use of an accurate odometry of the vehicle [22]. To combine this information that come from different sensors, a Kalman filter or another similar mathematical tool can be used. However, there are situations, such as slippage produced by an inadequate load distribution or a slippery surface, where the estimation of the speed using only the encoders of the wheels is not possible. In these cases, an inertial measurement unit (IMU) embedded in the vehicle can help to estimate the AGV velocity. However, this solution increases the cost of the AGV, and thus many mobile robots are not equipped with the IMU neither implement a Kalman filter.
is is the case of the AGV studied here. As it will be explained below, in this AGV, guiding and localization are decoupled. Guiding (understood as deviation from the expected trajectory without localization) is provided by the magnetic sensor, and the localization is provided by a RFID reader.
e guiding system allows us to know the deviation between the AGV and the path defined in the working environment.
ere are different types of guiding sensors: optical ones (to follow a painted line), magnetic ones (to follow a magnetic tape), inductive ones (to follow a buried wire), and so on. In the AGV used in the study, the guiding is based on a magnetic sensor.
e localization system detects points of reference placed in the working environment, with a known specific location on the plane. ese reference points may be sensed by an optical device (QR codes), a magnetic device (magnetic spots), an electromagnetic device (RFID tags), and so on. is way the AGV can know its own location through references. e accuracy of the localization system is half the distance between two points. In the standard Unibot robot, the localization is RFID-based. e traction unit of the AGV equipped with the guiding sensor and the magnetic tape on the floor is shown in Figure 6. e guiding sensor gives the error signal err gui , that is, the deviation respect to the planned trajectory. If the sensing point is at the right of the magnetic tape, the error is considered positive; otherwise, it is negative.

Control System.
e main contribution of this section is the formal description of a general control subsystem of the AGV, as well as the identification of the interactions with the other subsystems. Figure 7 shows the interaction between the subsystems driving and safety, the guiding and location systems, as well as the internal structure of the control system (orange dashed rectangle). e control system has three internal blocks: the control unit, the velocity control, and a block called MIN that calculates the minimum of its inputs.
e control unit has as inputs the localization variable from the GLS and the stop signal from the safety system. Its outputs are the reference of the cruise velocity, v ref , and the type of safety zone, type zone , associated to the section of the route where the AGV is currently located. e inputs of the MIN block are v ref and v safe (from the safety system). It selects the minimum of them and calculates the effective velocity that the AGV should have, v foll .
Finally, the velocity control module is in charge of generating the control signals for the motors (u l , u r ) in order to track the reference longitudinal velocity v foll and to minimize the error signal, err gui . To do it, it receives the velocity of the wheels (v l , v r ) from the driving system and the error signal err gui from the GLS. Even more, it is notified if the stop signal is triggered, and it also receives the references for the wheel speeds (man, u ml , u mr ) directly from the user if the manual controller is on. It interacts with the workspace through a set of input/output signals (IO signals ). e velocity control is carried out by the function f vcon , which receives as inputs v foll (m/s) from the MIN block, err gui (m) from the GLS, (v l , v r ) (m/s) from the driving system, (u ml , u mr ) (m/s) from an external control device, and the digital signals (stop, man) ∈ 0, 1 { } 2 . e stop signal, as it was explained, comes from the safety system. e man signal is generated in an external control device. It is 1 when the manual external controller device is on and 0 otherwise. e output of the f vcon function is the pair of control signals for the motors (u l , u r ) ∈ u ∈ R| − t1n ≤ quh ≤ 1 2 . us, this function f vcon (v foll , err gui , v l , v r , u ml , u mr , stop, man): 2 can be defined as follows: 8 Complexity As it may be observed in (19), when stop signal is active, the motor targets are set to 0. However, when the manual mode is active, the external velocity control signals (u ml , u mr ) are changed to (u l , u r ). On the other hand, if the automatic mode is on (last statement in (20)), the control output is generated by a couple of PID controllers, in particular a PI controller per wheel. e targets for the left and right wheels are v lref and v rref , respectively. ese targets are calculated by equation (19) using as inputs the longitudinal velocity reference, v foll , and the angular velocity reference, _ Φ href . e angular reference is computed by a PID to compensate the guiding error, err gui .
As explained before, the control unit is in charge of assigning the type of safety zone, type zone , and a cruise velocity reference, v ref . A lookup table is generated by the user with localization as input and this information.
Likewise with the safety controller, the control unit can be modelled as a hybrid automata. It has three macrostates: automatic, manual, and safety stop. erefore, the set of discrete states is Q CS � auto, manual, safestop ; the set of continuous variables is X CS , that is, defined by the user according to the actions to be carried out by the AGV. U CS � Localization, man, inp prog is the set of input variables and Complexity e set of guard conditions are given by  X, U, Y, Init, D, Dom, E, G, R), as defined before. In this work, we are going to focus on H auto because it has more interactions with the rest of subsystems. When in the automatic macrostate, the set of discrete states is Q CSauto � wcon i , march i i ∈ N < N loc , where N loc is the number of known localizations. In other words, the number of microstates is 2 · N loc . e parameter N loc is configured by the user for each application. e discrete variables wcon i mean "waiting for conditions," and the variables march i mean "the AGV is in motion." erefore, for each localization defined in the lookup table, the AGV will be either waiting for conditions or in motion once the conditions are fulfilled.
e set of continuous variables in this macrostate, X CSauto , and its corresponding vector field of differential equations, D CSauto , are defined by the user according to the actions to be carried out by the AGV. e user can associate to each localization i in the lookup table a set of inputs inp iprog , a set of outputs out i prog , a set of conditions Cond i , a cruise velocity reference v iprog , and a type of safety zone tsf iprog .
us, the set of inputs in this macrostate is U CSauto � Localization { } ∪ inp prog , and the set of outputs is e set of discrete transitions in the automatic mode is as follows: where R prog is a user-defined relationship.
is relationship defines the sequence of localization values of an action and so it is necessary to specify a pair of microstates (march i , cond i ). As shown in (23), the jump between two microstates can only be done if its sequence appears in R prog .
From the relationship R prog , the set of guards is automatically generated as follows: where Cond i i ∈ N < N loc is a set of conditions. It is possible to observe in (23) and (24) how the AGV in the microstate wcon i waits for the meeting of condition Cond i . When they are fulfilled, it switches to the microstate march i .
And vice versa, when it is at march i state and it reaches a localization defined in R prog , it changes to wcon j .
Finally the set of reset relations is given by 10 Complexity As expressed in (26), when the AGV reaches the microstate march i , it sets v ref to the value v iprog stored in the lookup table associated to localization i .

Electrical System: Charging, Power Storage, and Motors.
e novelty of this section is the integration of the electrical models of the battery, the charger, the motors, and the drives. e most frequently power storage technologies used in AGVs are the lead-based and lithium batteries. More recently, supercaps, electric capacitors with an unusually high power density, are being used for very high charging currents demand. However, still lead batteries are the most widely used because they are much cheaper than the other options.
ere are several mathematical models of these batteries, each one considering different aspects. e electrical model is adapted from [23,24] to include the charger and the motors, as shown in Figure 8. e electrical model of the motors (Figure 8) is adapted from [25][26][27]: Regarding motor i, V mot i (V) and I mot i (A) are the voltage and the current; R m is the motor winding resistor (Ω); L m is the motor inductance (H); K m is the electromotive constant (kgm 2 s −2 A −1 ); w mot i is the rotor angular velocity (rad/s); J is the moment of inertia of the rotor (kgm 2 ); K r is the coefficient of rotation resistance; M X i is the load moment (kg m 2 /s 2 ); η is the performance coefficient; I M i is the input current (A); and abs is the absolute value function; the control signals of the motors u L and u R are calculated by equation (33), and they are the inputs of the motor drivers. e main equations of the equivalent electrical circuit of the AGV and the charger are as follows: where I bat (A) and V bat (V) are the current and the voltage in the terminals of the battery; I stop (A) is the current consumed by the AGV when it is stopped; I c (A) is the current given by the charging station; R c (Ω) is the equivalent resistance of the charger;I p (A) is the parasitic current in the battery when is charging; Em bat (V) is the voltage in the open circuit of the battery; R 1 (Ω), R 2 (Ω), and C 1 (F) are internal parameters of the battery; and C n (Ah) is the capacity of the battery. e control signal u c is active, u c � 1, when the AGV is in a charging station. For more details of these variables and parameters, see [23].

Workspace.
e workspace, although is not embedded in the AGV as the rest of the subsystems, plays an important role in the performance of the automatic vehicle. It represents the environment where the AGV moves. It collects information about the ground, the obstacles, and other possible AGVs and provides information to the safety system, the guiding and localization system, the driving system, and the control system. Figure 9 shows the interaction among these subsystems. e workspace gives the landmarks and references to the GLS to calculate the guiding error err gui and localization. It also detects obstacles that will be handled by the safety system. In addition, it interacts with the driving systems by the friction coefficients and the ramps of the ground. In turn, the driving system moves the AGV, changing its position coordinates (x, y). Finally, the workspace sends IO signals to the control system that may come from other machines [28], AGVs, and human operators, and it also receives commands from the control system. e workspace can be simulated as a lookup table, where the inputs of the table are the AGV position coordinates (x, y), and the output is a set that provides information about the obstacles, the landmarks and references, the friction coefficients, the ramps, and the IO signals in that spatial location.

Simulation Results and Discussion
Several simulations have been carried out to validate the analytical modelling approach [29] and analyze the AGV model. e model has been implemented with Matlab/ Simulink software package. In order to reduce the discretization error, a variable simulation step size has been used, with maximum step size set to 25 ms. e control sample time Tc has been also fixed to 25 ms. e AGV parameters used in the simulations are listed in Table 1. e load mass m L is set to 500 kg. e simulation scenario is represented in Figure 10. It is a magnetic tape loop (green line) with a charging station and a traffic light. e charging station supplies the energy to the vehicle, so the AGV does not need to leave the circuit to reload. is component, part of the workspace, has been included in the electrical equations of Section 4.5 due to its electrical nature.
A typical element that interacts with the AGV through the IO System is a traffic controller (shown in Figure 10 as a traffic light). When the AGV arrives at an intersection, it stops; then, it requests crossing priority to the traffic Complexity 11 controller, and when the intersection is free, the traffic controller informs the AGV and the vehicle continues moving. e trajectory proposed in Figure 10 is Bernoulli's lemniscate. is trajectory is interesting because the curvature radius is variable and even more, it has an intersection point as it happens in many real layouts. It can be described as the set of P points where the product of the distance to two focus, F1 and F2, located at a distance 2a between them, is a 2 .
(32) e intersection between the straight line projected by the guiding sensor and the lemniscate is used to calculate the guiding error. To calculate the crossing points, we substitute the well-known straight-line equation y � mx + b in (32) and obtain a fourth-degree polynomial (33), with the constants k 0 to k 4 defined in the following: e solution of this polynomial gives the x coordinate of the intersection points. As it is fourth-degree polynomial, the analytical solution is not evident so it is solved by numerical methods.
During the simulation, it has been supposed that there are not ramps in the environment, all the localizations have the same friction coefficient, and friction coefficients are considered constant due to the large system time constants.
For the sake of clarity, the inputs and outputs of the simulation blocks used during the experiments are shown in Table 2. Figure 11 shows the trajectory followed by the traction unit (Figure 11(a)) and the body of the AGV (Figure 11(b)) when reference is a lemniscate curve with a sinusoidal velocity profile, with v ref � 0.4 m/s of amplitude and 0.4 m/s of mean value. In this experiment, the a parameter of the lemniscate is set to 5, and the initial position of the AGV is (3.144, 2.5) with an angle of 0°in the traction unit and the body.

Kinematic Behaviour Simulation.
is figure represents 200 steps of the AGV motion on the XY plane, between the initial and the final position. It is possible to observe how the positions described by the traction unit follow a lemniscate-shaped trajectory. is type of representation is very useful to design the layout where the AGV is going to travel in a factory or workhouse. It allows to foresee, among other cases, whether the AGV will be blocked by an obstacle, get stuck in a narrow corridor, or if it will reach correctly a station. Workspace Guiding + localization system Driving system Safety system

Control system
Landmarks and references Obstacles IO signals Friction, ramps…: (x, y) Figure 9: Interaction between the workspace and the AGV subsystems. e trajectories followed by the traction unit (red line) and the body (orange line) of the AGV are represented in Figure 12, with the reference (blue line). e trajectory on the plane is shown on the left, and the evolution of each coordinate is represented on the right. e coordinates (x H , y H ) represent the center of the traction unit, and (x B , y B ) are the coordinates of the middle of the rear axle. e traction unit follows reasonably well the lemniscateshaped magnetic tape; thus, the reference and the traction unit lines are overlapped in Figure 12(a). Nevertheless, the body of the AGV follows a lemniscate curve closer than the reference. is difference decreases with the width of the lemniscate, parameter a in (30). is effect is more visible in the edges of the lemniscate, and it is not shown at the intersection.
Looking closely at Figure 12(b), local maximums and minimums appear at x ≈ 7 m, x ≈ − 7 m, y ≈ 2.5 m, and y ≈ − 2.5 m, the extremes of the lemniscate, as expected. It is also interesting to note how when the AGV is in the first and third quadrant, from t � 0 to t ≈ 10 s and from t around 60 s to 100 s, x H seems to be delayed respect to x B . However, when it is in the second and fourth quadrants, the opposite happens.  Figure 13(b). On the right side of this Figure 13, the angle of the traction unit (blue line) and of the body (red line) of the AGV is shown. e angle of the body of the AGV decreases up to 225°a round t � 28 s when the straight part of the lemniscate starts, and it keeps constant until that straight part of the lemniscate end about to t � 40 s. After this point, the AGV turns counterclockwise, which increases the angle up to approximately t � 70 s when the straight part of the lemniscate starts again. On the other hand, the angle of the traction unit is related to the radius of curvature. At the top and bottom edges of the lemniscate, this radius slightly varies and the angle of the traction unit keeps practically constant at −25°from t � 10 s up to t � 25 s and at 25°from t � 50 s up to t � 65 s. is angle is positive when the AGV turns clockwise and negative otherwise. In the straight part of the lemniscate, as expected, the angle of the traction unit is 0°.
So, these results validate the model as the AGV moves as expected.

Dynamic Behaviour Simulation.
e model of the dynamics of the AGV has been also implemented. Figure 14(a) shows the angular velocity of the traction unit (red line) and its reference (blue line). Figure 14(b) represents the reference of v ref (blue line) and the longitudinal velocity (red line). When the AGV starts moving, the angular speed reference, that is, generated by the controller, oscillates due to error of the velocity. Once the reference speed is reached, at t � 8 s, the oscillations are much smaller and the mean value is around 0. In any case, the angular velocity reference is well tracked, with a slight oscillation (smaller than 0.5 rad/s). e sinusoidal profile of v foll (Figure 14(b) is well followed by the    controller. e biggest error appears at the beginning of the simulation as the AGV is stopped, and it starts accelerating to reach the reference speed.
In order to reach these angular and longitudinal velocities, the corresponding wheel speeds are calculated. Figure 15(a) shows these references, and Figure 15(b) shows the effective wheel velocities. e blue lines represent the right wheel and the red lines the left one. As it is possible to see, the controller is able to track the wheel speed references.
e largest error appears at the beginning of the simulation as it is necessary to overcome system inertia. Once the reference value is achieved, the biggest difference between the velocities of the wheels appears at the inflection points of the angle of the traction unit. is happens approximately at t � 25 s, 45 s, 65 s, and 85 s. At these points, if the angular velocity of the traction unit is positive, the speed of the right wheel is bigger than the left one, and it is smaller in the opposite case.
In order to follow the wheel speed references (Figure 15(a)), the control has to generate the right power values. Figure 16(a) shows the control signals which are the inputs of the electrical model equation (27); in Figure 16(b), the torque of the wheels is represented. As explained before, this torque is the result of subtracting the friction forces from the torque provided by the motors. e blue lines represent the right wheel and the red lines the left one. e range of the control signals is [−1, 1]. ese control signals are inputs in equation (29), and they are dimensionless; they represent the percentage of battery voltage that is applied in the motors.
At the beginning of the simulation, both control signals are saturated to 1, as the initial state of the AGV is stopped. ese values are maintained until the wheel speed reference is reached; from this point, the control signals show a sinusoidal behaviour similar to the reference but slightly noisier. Negative peaks appear at t ≈ 30 s, 50 s, 70 s, and 90 s. ese values match with the peaks of Figure 14(a). ey correct the angular velocity of the traction unit to maintain the angle when the AGV gets close to the top and bottom edges of the lemniscate trajectory. Due to this, the curvature radius is practically constant ( Figure 13). As expected, the shape of the effective torque in the wheels is similar to the control signals but with different amplitude. At the beginning, when the control signals are saturated to 1, the value of the torque is maximum. en, the effective torque decreases although the control signals are constant due to the effect of the viscous friction forces which increase with the velocity.

Electrical Behaviour Simulation.
In this section, the same experiment is carried out but the analysis is focused on the electrical model. At the initial state, the voltage in the capacitor is V c � −4V, and Em bat is set to 24 V, that are the common values after the charging. e initial current in the motors is 0 A. Figure 17 shows the current in the motors on the left and the effective torque on the right. e blue lines represent the right motor and the red lines the left one. As expected from equation (26), the absolute value of the effective torque is practically proportional to the current. e difference comes from the friction forces. In the simulations, the current of the motor is considered always positive no matter the sign of the control signal. e sign of the torque in each motor is equal to the sign of its control signal.
In addition to the current of the motors, it is also interesting to study the current and the voltage in the battery terminals.
is helps us to scale up the layout and the production cycles, as well as to foresee the battery life. Figure 18 shows the current and voltage in the battery terminals (blue and red lines), the voltage in open circuit of the battery (yellow line), and the voltage in the equivalent capacitor (purple line). As expected, the battery current

Complexity 15
follows a sinusoidal signal. Although sometimes the current in the motors is 0 A, the current in the battery is bigger due to the consumption of the other electronic devices of the AGV. is consumption is considered constant and modelled by I stop . e negative peaks of the torque can be seen in the battery current as positive peaks at the bottom part of the signal. e battery voltage measured in terminals varies with the current; when the battery current increases, the voltage decreases due to the effect of the internal resistance, producing an observable sinusoidal curve. When the system is working, the absolute value of the voltage in the capacitor decreases.
is also produces a decreasing trend in the battery voltage. On the other hand, the Em bat slightly decreases as well but this is not noticeable due to the high capacity of the battery, i.e., the bigger the capacity, the slower the decreasing trend.
Another interesting effect is that when the battery voltage decreases, the voltage applied to the motor for the same control value also decreases. And if the motor voltage decreases, its speed also decreases. is forces to increase the control signal to get the same motor velocity. In turn, the increment of the control makes the consumed current to increase, as it is possible to see in Figure 18. is effect is less significant when the capacitor is discharged since the decreasing trend of the battery voltage is much smaller. Figure 19 shows the total accumulated current in Ah (Figure 19(a)) and the percentage (%) of the battery (Figure 19(b)). As expected, the sinusoidal current in the battery terminal produces a sinusoidal total current. It is a  usual practice to calculate the percentage of the battery using the total consumed current. In this case, the capacity of the battery is 150 Ah; thus, a total current of 0.3 Ah is equivalent to 0.2% battery, as shown in Figure 19(b). is provides an autonomy of approximately 13.8 h. is is an approximation since it has been seen, the battery voltage also affects the current.

Influence of the Mass of the Load.
e effect of the load on the AGV has also to be analyzed. To do it, different experiments varying the load mass have been carried out with two different speed profiles: a sinusoidal one, as before, and a constant speed of 0.8 m/s. All these experiments are configured as in the previous sections but the mass. In the previous experiments, the load mass m L was set to 500 kg. Figure 20 represents the variation of the average battery power with the mass (Figure 20(a)) and the variation of the average current (Figure 20(b)). e blue lines represent the values for a sinusoidal speed profile and the red lines for a constant velocity. As expected, the bigger the load mass, the larger the power and current. is effect is more marked when the speed is constant. As the AGV travels more time at a bigger speed, it needs more energy. Figure 21 shows the variation of the MSE guiding error (Figure 21(a)) and the variation of the standard deviation of the total torque in the wheels (Figure 21(b)). e color code  is the same as in Figure 20.
ese indicators have been calculated using the following equations: where T s i is the sampling time at i and T sim is the total simulation time. is period T s i is necessary since a variable simulation step has been used. is way the MSE gives the mean squared value of the guiding error in cm. e standard deviation of the total torque can give us an idea of the degradation of the electromechanical pieces, as larger total torque means bigger degradation. In Figure 21, it is possible to observe how the MSE is not affected by the mass until certain mass threshold is surpassed.
is value is around 300 kg for the sinusoidal speed profile and 150 kg for the constant speed. is may be explained as the average velocity with the sinusoidal profile is approximately half than the obtained with the constant speed. However, the effect of the mass on the standard deviation of the torque is worse. e sinusoidal speed profile produces bigger deviations, and moreover, the influence of the mass is bigger.

Influence of the AGV Velocity.
Finally, the effect of using two AGV velocity profiles, sinusoidal and constant, is  18 Complexity studied. e mean amplitude of the sinusoidal signal is half the value fixed for the constant one. e load mass is 500 kg. e rest of parameters of the experiment have been configured as in previous sections. Figure 22 represents the variation of the average battery power with the velocity (Figure 22(a)) and the variation of the average current (Figure 22(b)). e color code is the same as in the previous experiments. Again, as expected, bigger velocity produces larger power and bigger current. However, in this case, the sensitivity, defined as the derivative of the measured variable respect to the parameter that is modified by the sweep, is smaller. e sensitivity is denoted by β var par , where var is the measured variable and par is the parameter that is modified in the experiment. In particular, β Pow m L is 0.4 W/kg, β Pow v foll is 0.18 W·s/cm, β I bat m L is around 0.016 W/kg, and β I bat v foll is 0.007 W·s/cm, approximately. Figure 23 shows the variation of the MSE (Figure 23(a)) and of the standard deviation of the total torque in the wheels (Figure 23(b)). e color code is the same as in Figure 22. It is remarkable how the error is related to the cruise velocity; lower speeds produce smaller errors. is is so in general, but there exist an inferior limit related to the accuracy of the encoders that measure the velocity. e velocity is also related to the torque, as shown in Figure 23(b), where larger velocities demand bigger effective torque. is is not a general rule since the torque is directly related to the acceleration; in order to increase the  acceleration of the AGV, it is necessary to increase the effective torque of the wheels. However, a bigger velocity does not necessarily entail a bigger torque since a higher velocity can be reached with the same acceleration and torque but spending more time. However, in this case, the AGV cannot leave the magnetic circuit; thus, bigger accelerations are necessary to maintain the cruise velocity and that increases the effective torque.

Conclusions and Future Works
Automatic guided vehicles are complex systems with highly coupled internal variables. eir use has lately grown exponentially due to the Industry 4.0 paradigm, as these are industrial devices and play a key role in process flow and in the logistic sector. However, some of their safety requirements depend on the dynamics and control of these vehicles. erefore, a holistic modelling approach of the AGV is necessary in order to better understand its performance and to design efficient controllers.
In this paper, a complete model of a hybrid AGV has been developed. e vehicle is a general one, widely used, that is a mixture of tricycle and differential robots. e different subsystems of the AGV have been described and mathematically modelled, particularly, the control system, the safety system, the driving system, the guiding and location system, the charging, the power storage, and the motors. Even more, the interactions among them have been identified and represented in the proposed architecture of the AGV.

Complexity
Simulations results, varying some of the vehicle parameters, have allowed it to validate the models as the global performance of the AGV is as expected.
Among other possible future works, we may highlight the study of the influence of the deformation of the wheels and the design of neural-controllers to improve the performance provided by the current PIDs. Besides, rollover conditions depending on the load could be estimated to ensure the safety of these systems.

Data Availability
e equations and parameters used in this study are included within the article.

Conflicts of Interest
e authors declare that they have no conflicts of interest regarding the publication of this paper.