\chapter{Introduction} \label{chap:introduction}

\section{The ATLAS Project} \label{sec:the_atlas_project}

The Atlas project has been developed at the Laboratory of Automation and Robotics at the Department of Mechanical Engineering of the University of Aveiro \cite{ATLAS}. The project started in 2002/2003, and its primary mission is to develop, study and implement advanced sensing and active systems for further implementation in the automotive industry, or other similar platforms. After repeatedly achieving excellent results while participating in the Autonomous Driving Competition, taking place at the Portuguese Robotics Open, the Atlas team decided it was time to move on to a more ambitious and challenging environment: the real world scenario. In order to do so, a new platform was acquired and a brand new branch of the project was created: the AtlasCar.

The AtlasCar is a real-scale prototype vehicle used for research on Advanced Driver's Assistance Systems (ADAS), and consists of a modified and adapted 1998 Ford Escort Station Wagon, shown in Figure \ref{figure:atlascar_1}. The vehicle is equipped with several sensor systems that allow it to perceive the surrounding environment, as well as  some of the driver's actions. The main sensors currently available in the car are the following:

\begin{itemize}
\item Stereo Head;
\item Foveated Vision;
\item 2D Laser Scanners;
\item Custom 3D Laser Scanner;
\item MEMS IMU;
\item GPS Receiver;
\item Pedal pressure Sensors.
\end{itemize}

\begin{figure}[h!]
\centering
\epsfig{file=Images/atlascar1.eps,width=100mm}
\caption{AtlasCar prototype vehicle.}
\label{figure:atlascar_1}
\end{figure}

The vehicle has also suffered a major set of interventions on a hardware level. One of the most important changes was the addition of a second DC generator, independent from the original AtlasCar alternator, but also propelled by the engine shaft. In order to power up the vehicle's new and more demanding electric circuitry, including all the computers, monitors, cameras, sensors and actuators, this DC generator is connected to an AC inverter that raises the voltage to 220/230 V. This inverter is connected to an Uninterruptible Power Supply (UPS) to ensure a stable and safe power supply to all the mentioned equipments. The UPS is the interface from where all equipments' power is derived. The car also includes two DC power rectifiers: a 12 V and a 24 V, used to feed the large variety of electronic and electromechanical equipment. The power management of each sensor or actuator is made by software using an industrial Mitsubishi Programmable Logic Controller (PLC). Another PLC, a Siemens SIMATIC S7-1200 depicted in Figure \ref{figure:plc_siemens}, is the responsible for the majority of the actuation systems, the low-level management of the security systems and the monitoring of several driving parameters.

\section{The AtlasCar Actuators} \label{sec:the_atlascar_actuators}

As the AtlasCar project consists of an automatic driving prototype, there is the need to control as many driving parameters as possible. In order to achieve this main objective, AtlasCar uses some electronically controlled actuators on most of the main car systems. The systems currently being actuated are listed below:

\begin{itemize}
\item The Throttle;
\item The Brake pedal;
\item The Clutch pedal;
\item The Handbrake;
\item The Ignition;
\item The Steering;
\item The Lights.
\end{itemize}

A brief description of these actuator systems is presented from Subsection \ref{subsec:the_clutch_and_brake_pedals} to Subsection \ref{subsec:the_lights}.

\subsection{The Clutch and Brake Pedals} \label{subsec:the_clutch_and_brake_pedals}

The AtlasCar clutch and brake pedals are actuated in a very similar way. These pedals are mechanically connected, through a steel wire attached to the pedals, to the respective actuator boxes, currently located below the driver's seat to allow easy access. These actuator boxes are actually adapted lock brake actuators from a \textit{Renault Vel Satis}, whose circuitry was remade in order to allow the local control of the speed and sense of rotation of its DC motor \cite{tese Tiago Rocha}. The actuators simulate the pedal movements normally caused by a driver's foot pressing them, without interfering with the normal driving of the car. The control signal used to actuate the clutch and the brake is controlled using a digital communication protocol with the Siemens Programmable Logic Controller. The force that the driver exerts in each pedal can also be monitored, using variable resistance sensors, and the values are communicated directly to the PC.

The clutch actuator is particularly important for the future of this this work, as it presents itself as a fundamental element on the gear shifting process. The clutch allows the engine to be mechanically detached from the gearbox, which needs to be stopped in order to perform a smooth gear shifting process. 

\subsection{The Handbrake} \label{subsec:the_handbrake}

The system used to drive the handbrake uses a chain and sprocket wheel attached to the handbrake itself. Another adapted \textit{Renault Vel Satis} lock brake actuator box was used to drive this system. An electric linear actuator, depicted in Figure \ref{figure:handbrake_mechanism}, pulls the handbrake blocking button when necessary. All the handbrake actions are controlled locally using a programmable integrated circuit. The control signal used in order to actuate this system is also controlled using a digital communication protocol with the Siemens PLC.

\begin{figure}[h!]
\centering
\epsfig{file=Images/handbrake.eps,width=120mm}
\caption{AtlasCar Handbrake mechanism.}
\label{figure:handbrake_mechanism}
\end{figure}

\subsection{The Throttle} \label{subsec:the_throttle}

The AtlasCar original vehicle, a 1998 Ford Escort Station Wagon, was not equipped with an electrically controlled throttle valve, and consisted on a common throttle, actuated directly by a steel wire from the pedal to the throttle valve. This system was replaced by the electronic throttle depicted in Figure \ref{figure:throttle}, which uses digital potentiometers and an H-bridge, controlled by an \textit{Arduino}, in order to set a desired position to the valve. This system communicates directly with the control PC, via TCP/IP.

\begin{figure}[h!]
\centering
\epsfig{file=Images/throttle.eps,width=70mm}
\caption{AtlasCar electronic throttle valve.}
\label{figure:throttle}
\end{figure}

\subsection{The Ignition} \label{subsec:the_ignition}

The AtlasCar current automatic ignition uses a two relay system, as depicted in Figure \ref{figure:ignition_electric_diagram}, because there are two main circuits on the original lock cylinder:

\begin{itemize}
\item A pair of Power Cables;
\item A pair of cables for the Starter Motor;
\end{itemize}

\begin{figure}[h!]
\centering
\epsfig{file=Images/ignition.eps,width=100mm}
\caption{AtlasCar electrical ignition diagram.}
\label{figure:ignition_electric_diagram}
\end{figure}

In order to activate this system, a normally closed relay is used in series with the Power cables, and a normally open relay controls the state of the starter motor. This system allows the automatic control of the ignition, but the manual system remains fully operational. The key still needs to be inserted on the cylinder and rotated to the second position (\textit{Power On}) for the system to start, because of the steering wheel blocking system.

\subsection{The Steering} \label{subsec:the_steering}

The steering actuator is an adapted electric power steering system, depicted in Figure \ref{figure:steering}. The original power steering system was hydraulic, and it is currently only aiding the new electric system. The electrical actuator is locally controlled by a Programmable Integrated Circuit, the position of the steering wheel is monitored using a multi-turn potentiometer and the communication with the PLC is made using analogue signals.

\begin{figure}[h!]
\centering
\epsfig{file=Images/steering.eps,width=90mm}
\caption{AtlasCar electrically controlled steering column.}
\label{figure:steering}
\end{figure}

\subsection{The Lights} \label{subsec:the_lights}

The AtlasCar lights are currently being both controlled and monitored. The lights control is achieved using the PLC digital outputs, which command a relay box, currently placed below the passenger's seat. The lights currently being actuated are listed below:

\begin{itemize}
\item Dipped Beam Headlamps;
\item Main Beam Headlamps;
\item Right Directional Indicator;
\item Left Directional Indicator;
\item Roof-mounted Yellow Beacon;
\end{itemize}

The lights' actuation system is connected in parallel with the vehicle's original light circuitry, so all the lights can still be normally used by a human driver. This fact is particularly useful if the automatic systems are turned off, or in the case that the car is only used to monitor the driver's behaviour, without interfering with it.

\section{Objectives} \label{sec:objectives}

The AtlasCar vehicle is not originally equipped with an automatic transmission system, which makes the implementation and testing of new autonomous driving algorithms very difficult, or even impossible. One of this work's main objectives is to project, build and test extensively a new gearbox management system based on the control of two DC motors. It is also an objective of this project to prove that this controller is solid and robust enough to control the existent AtlasCar gear selector mechanism.

The other main objective of this work is to develop a reliable firmware solution to control the gear selector mechanism, which can automatically perform the trajectories required to obey any gear change order given by the software controlling the gearbox on the AtlasCar PC.

The communication process with the device will also be explored and tested, to ensure the proper operation required for such a vital element of the AtlasCar vehicle: the gearbox.

It is also in the scope of this work the development of a simple, yet highly configurable Hardware-in-the-Loop simulator, in order to perform laboratory tests on the gear selector mechanism controller.

\section{Dissertation Structure} \label{sec:dissertation_structure}

This dissertation consists of seven chapters.

This first Chapter is a brief introduction to the Atlas project. It presents some of the project's history, and its current developments stage. In this Chapter, the most common automatic transmission systems used nowadays are also presented, as well as some of their advantages or limitations. The first Chapter also defines the primary objectives and goals of this work.

In the second Chapter, the current AtlasCar gear selector mechanism is explained in detail, and the electronic controller solution built to control it is also described. The firmware programming, the methods used to perform it and the details about the communication messages received and sent between the control computer and the firmware are also explained in the second Chapter. Other accessory software, namely the calibration software and the ROS Node that was built to facilitate the introduction of the mechanism in the AtlasCar, are also shown in this Chapter, along with the necessary instructions or programming details about their operation.

The third Chapter of this dissertation explains in detail the simple Hardware-in-the-Loop partial gearbox simulator, written in Matlab in order to simulate and test the behaviour of the gear selector mechanism, its communication protocol and the robustness of its programming, in the laboratory.

The fourth Chapter explains some of the laboratory tests that were performed on the gear selector mechanism, both using the manual mode and the automatic mode. This second test is performed using the Hardware-in-the-Loop simulator described in the fourth Chapter.

The fifth Chapter presents the conclusions about this work. This Chapter also proposes some future work that still needs to be executed in order to perform successful gear changes on the Atlascar vehicle using this mechanism.

At the end of this work, both the bibliographic material used to develop it is described, and the annexes necessary to the complementation and further comprehension of certain aspects and parts of this work are presented.

\section{Automatic Gearboxes} \label{sec:automatic_gearboxes}

In order do develop a gear changing mechanism for the AtlasCar vehicle, and to achieve a better understanding of the problem at hand, the most common solutions commercially available were studied and explored.

An automatic gearbox, or automatic transmission is, by definition, "an arrangement of gears, brakes, clutches, a fluid drive and governing devices that automatically changes the speed ratio between the engine and the wheels of an automobile" \cite{Enciclopedia Britannica}. This system was initially created to simplify the driving process, freeing the driver from the process of shifting gears or clutching. There are three main types of automatic transmission used nowadays:

\begin{itemize}
\item The traditional Fully Automatic Transmission;
\item Continuously Variable Transmissions (CVT);
\item The Semi-automatic transmission.
\end{itemize}

The most common automatic transmission system is the hydraulically operated fully automatic transmission. One of the most significant differences between the manual transmission and the hydraulic automatic transmission system is that the last uses a torque converter instead of a common mechanical clutch.

\begin{figure}[h!]
\centering
\epsfig{file=Images/automatic_transmission.eps,width=90mm}
\caption[Automatic Transmission]{Automatic transmission system. The torque converter can be seen in the left, and the planetary gears can be observed in the middle \cite{Oscar Gearbox}.}
\label{figure:automatic_transmission}
\end{figure}

The torque converter is a type of hydrodynamic fluid coupling used to transfer the rotating power from the engine to the gearbox itself, allowing the two systems to be mechanically separated when convenient, like the common clutch system. This system differs from the classic clutch, as the one present in the AtlasCar vehicle, because the clutch can completely mechanically connect two different shafts, contrarily to what happens with the torque converter, where a thin film of fluid is always present between the gearbox's and engine's disks \cite{Automotive Handbook}. The clutch is not an hydraulic system, and uses springs in order to engage or disengage the engine shaft from the gearbox shaft. The use of clutches, instead of hydraulic torque converters, on the manual transmission systems is the main reason why this type of transmission presents more efficiency, as there is no energy loss to the operating fluid \cite{FUEL EFFICIENCY AND THE PHYSICS OF AUTOMOBILES}.

The Hydraulic Automatic transmissions also use planetary gearing with independent internal clutches, instead of the simpler meshing gears system used in the manual transmission systems, thus increasing its maintenance cost. The number of moving parts used in hydraulic transmission is considerably higher than their manual equivalent, because of all the auxiliary hydraulic circuitry, such as the necessary pumps and pipes. The hydraulic system is also composed of at least two different fluids: the lubricant and the operating hydraulic fluid, which also requires a more careful maintenance.

\begin{figure}[h!]
\centering
\epsfig{file=Images/mercedes_gear_selector_lever.eps,width=90mm}
\caption[Steering column automatic mode selector lever]{Steering column automatic mode selector lever from a 2010 Mercedes-Benz E350, with the four common modes: R, N D and P \cite{Steering Column}.}
\label{figure:mercedes_gear_selector_lever}
\end{figure}

The fully automatic transmission interface with the driver consists of a selection lever, normally located on the steering column like the one represented on Figure \ref{figure:mercedes_gear_selector_lever} or in the car floor, on the place occupied by the gear lever on a manual transmission car. This lever allows the driver to choose from a variety of running modes, the most common of which are presented and described in the following list:

\begin{itemize}
\item Park (P) $\rightarrow$ The Park mode mechanically locks the output shaft of the transmission and prevents it from turning in any direction. This mode is used when the vehicle is in a stationary position;
\item Reverse (R) $\rightarrow$ The Reverse mode allows the vehicle to be driven backwards, in order to perform special manoeuvres. The insertion of this mode is only allowed when the vehicle reaches a complete standstill;
\item Neutral (N) $\rightarrow$ The Neutral mode works in a very similar way to a Neutral position of a manual transmission vehicle, as it disengages all gears in the transmission system. The automatic transmission drivers must always start in this position in order for the engine to start;
\item Drive (D) $\rightarrow$ The Drive mode allows the transmission to use all the forward gear ratios available. This is the mode used for normal car driving.
\end{itemize}

An autonomous driving project named CADU, currently in progress at the \textit{Universidade Federal de Minas Gerais}, in Brazil, takes advantage of the simple lever design of the semi-automatic transmission already available on the vehicle, and actuates it externally using a linear actuator \cite{CADU_Project}. This actuator only pushes or pulls the lever in the forward or backward direction, in order to select the desired running mode.

The Continuously Variable Transmissions are another type of automatic transmission system where the gear ratio can vary steplessly between a maximum and a minimum limit, defined by the manufacturer. These systems are used to provide better fuel economy, as the engine can work at its most efficient revolutions per minute value for a wide range of vehicle speeds. This system is not relevant for the study at hand, and is not described in more detail, because its functioning principle is drastically different from the transmission used in the AtlasCar vehicle.

Due to all these notorious differences between the fully automatic hydraulic transmission or the Continuously Variable Transmission described above, and the common manual transmission present on the AtlasCar vehicle, the gear shifting system principle used in the AtlasCar presents more similarities with the third automatic transmissions category presented: the semi-automatic transmission.

Unlike the automatic hydraulic transmission, which takes care of the whole gear shifting process for the driver, the semi-automatic transmission gives much more control to the driver, or the controlling computer system. The main advantage of this system is that it automatically controls the clutching process, leaving only the decision about the gear at which the system should run to the driver, or the electronic system in charge of the gear shifting logic. Typically it uses electronic sensors and actuators in order to engage or disengage the clutch and carefully synchronize its timing. This accurate timing process results in fast, smooth and effective gear shifts, which makes it the preferred transmission type for high performance applications. 

The semi-automatic transmission interface with the user is similar to a manual one, but instead oh using the characteristic H-pattern gear distribution, the gear lever only moves forward and backwards to shift up or down, respectively.
