Algorithms for Railway Embedded Control Devices for Safety Manoeuvres

– This study is dedicated to solve manoeuvres making task while working on the station with no marshalling hump. It is part of the project aimed at the development of intelligent safety and optimal control systems of autonomous electric vehicles and transport in general. The main manoeuvres safety depends on the lack of items and other objects on the rails as well as on the position of turnouts. In most cases rails, occupied with other wagons, as well as the wrong position of turnouts are marked with prohibiting red or blue signals of the traffic light. The authors propose an algorithm for the traffic light recognition by using a convolutional neural network (CNN) and traffic light indicator recognition. However, the situation when the locomotive needs to drive on the rails occupied with other wagons, for example, during the manoeuvres on the railway station can also appear. For this purpose, the authors have developed a CNN algorithm for the wagon recognition on the rails.


I. INTRODUCTION
Modern electric transport becomes more popular due to the development of the electric industry and its innocence to the environment. The risk of crashes and road accidents is increasing proportionally to the increasing number of transport vehicles in the system. To minimize the number of road accidents and to increase energy efficiency, many scientists perform studies about energy saving process [1], [2] and optimization in transportation processes [3]. Although railway transport, among other types of transport, has a lot of benefits, several issues should be noted [1]. Issues are frequently related to operational safety and crash probability; effects are heavy losses not only in business, but also, unfortunately, injuries and deaths [4]. The existing systems of railway transport security are constantly upgraded and new systems are developed to solve this problem [5], [6], but, unfortunately, it does not mean that all the problems have been solved in this area.
Manoeuvres on the railway station are one of the most dangerous events on the railway. Usually a marshalling hump is used for wagon sorting. If there is no marshalling hump on the station, locomotive crew makes manoeuvres. Human factor plays an important role in this situation that strongly depends on the human behaviour and carefulness [7]. At some stations there is no safe platform on the freight wagon for the assistant person, so he has to stand on the small board of the running train and has to hold on the handrail. The role of an assistant person is to control the indications of the traffic lights and distance till other wagons on the rails. During the wintertime, this situation becomes more dangerous in case of winter robe and icing on the wagon. Many accidents with severe consequences or even death of an assistant person happen due to specifics of the work.
Both tasks, that an assistant person does can be performed by the artificial intelligence powered software.
The most popular methods of traffic light signal recognition are traffic light election using colour density and colour features, recognition based on Spot Light Detection and adaptive traffic lights templates, traffic light detection with colour and edge information etc. For example, in scientific paper [8] the authors recommend to address the aforementioned challenges in traffic light detection by identifying the traffic light region of interest in the image, using automatically generated saliency maps. The traffic light detection system is implemented and proposed for advanced driver assistance systems and autonomous vehicle using an on-board colour camera and GPS sensor obtained information. The proposed algorithm consists of two steps: an off-line saliency map generation step and a real-time traffic light detection step. Unlike this method, in this search the authors propose not only the traffic light detection algorithm, but also an algorithm for its indication recognition. In the proposed algorithm of [9], the candidate regions of the traffic light using Support Vector Machine are verified and finally the traffic light is recognized by dividing the region of the traffic light. In this research, the red signal of traffic light recognition is based on the red colour detection. This may help gain a better result to solve tasks with different forms and types of traffic lights, but still problems with other red colour objects may appear.
In order to enable cooperative manoeuvres between trains like merging, splitting and driving in virtually coupled platoons, authors [10] proposed a Bayesian navigation algorithm based on GNSS pseudorange measurements and a geometric map of the track network that jointly estimated absolute and relative positions for multiple trains. By using pseudorange measurements and modelling common errors for different receivers, the proposed algorithm achieves the improved relative positioning accuracy compared to algorithms based on the Electrical, Control and Communication Engineering ________________________________________________________________________________________2020, vol. 16, no. 2 96 preprocessed position and velocity measurements. The proposed algorithm is based on a geometric map of the track network. The track map can be represented by a set of geometric track segments and a set of track connections defining the network topology. We, on the contrary, propose a system that uses selflearning algorithms, so no maps are needed.

II. PROBLEM FORMULATION
Despite different modern inventions and technologies, there is a problem of manoeuvre safety on the railway station. Technologies, such as unmanned aerial vehicles, may help make the process of wagon sorting without an assistant to minimize the number of railway accidents and to improve railway safety as well as to optimize work process and organization staff.
The idea of the traffic light signal transmission to the locomotive driver's cabin as well as object recognition is not new anymore. Many railways use a train control system meaning Continuous Automatic Train Signalling (ALSN) or a similar system, whose main aim is to transmit the indications of the traffic lights to the locomotives driver's cab. By contrast, the authors of the present research propose to make traffic light and other wagon detection using CNN and its signal recognition in real time, as well as to use this information for the locomotive braking system control, instead of informing the driver [11], [12]. This procedure may help minimize a human factor and decrease the necessary time for the reaction.

III. TASK FORMULATION
The goal of the research is to develop the intelligent system and the algorithm which is able to run the locomotive braking system according to the results of the analysis of the situation made by an on-board unmanned aerial vehicle and to use intelligent devices of unmanned vehicles for decision making based on convolutional neural networks (CNN) [13] and fuzzy logic (FL) [14] in order to reduce the influence of the human factor.
The following objectives have been set: • to develop the structure of the on-board active electric transport control system and to develop the system mathematical model with CNN submodel; • to develop the algorithm of object recognition by using region of interest (ROI), to define the area where the object might appear, and CNN, to recognize the object; • to develop the algorithm of red signal of traffic light recognition; • to implement and test the models and algorithms for microcontroller devices; • to analyse the results.

IV. SYSTEM STRUCTURE
The structure of the proposed system is shown in Fig. 1.
The following designations are used in this structure: UAVunmanned aerial vehicle; CFNN -convolutional fuzzy-neural network; OR -object recognition module; CNNconvolutional neural network; RA -risk assessment module; FL -fuzzy logic; DM -decision making module; DTRcontrol components to obtain the position, to calculate the motion parameters, to communicate with other devices and to control the electric drive; ESC -electronic speed controller; M -electric motor; RF -radio frequency; CAM -video camera; GPS -global positioning system. The common data and voltage flow scheme between system blocks and elements is provided in Fig. 2. The denotations used in the figure: Camera -video camera for video recording; GPS -Global Positioning System for obtaining the location data; microcontroller -microcontroller for obtaining the data based on the developed algorithm; micro SD -database, which contains information about traffic light position on the route; LCD -display for informing the driver about the recognized traffic light signal; relay -relay for actuating an electromechanical valve; valve -electromechanical valve for actuating the locomotive braking system; brakes -locomotive braking system; transformer -converts the 24 V on-board voltage to 5 V voltage; locomotive -locomotive 24 V power supply network.
The elements of the developed system interact as follows: an electromechanical valve is powered by the locomotive onboard voltage. With transformer 24 V on-board voltage is converted to 5 V voltage and all the necessary system elements are powered by this voltage: microcontroller, MicroSD database, LCD, CPS data receiver and video camera. The traffic signal and the recognition process are significantly influenced by information about the locomotive location on the route, i.e., it is important in time to identify approaching the possible traffic light. Therefore, the system is equipped with a GPS signal receiver and a database with the predefined traffic light location. The image taken by the video camera is forwarded to the microcontroller, where the resulting image is processed and the traffic signal and wagons are recognized according the algorithm. Information about the recognized signal and distance till the recognized wagon are sent to the driver's LCD to make a correct decision to operate the locomotive. If the driver does not react in due time, the microcontroller automatically generates a signal to the relay to activate the electromechanical valve, which in turn activates the locomotive braking system. The electrical circuitry of the proposed system elements is shown in Fig. 3. RX TX outputs of the video camera are connected to the appropriate TXD and RXD outputs. The GPS receiver's SIO output is connected to the controller output RXD2, the database with controller outputs SPI MOSI and SPI MISO connected to the outputs MOSI and MISO, CS and SCK respectively with the controller SPI CS and SCK. The relay receives the control signal from the controller output PD7 and transmits it to the electric valve directly acting on the locomotive emergency braking mechanism. The whole system is powered by locomotive DC 24 V and is transformed into DC voltage of 5 V. The electric valve is powered by locomotive DC 24 V without conversion.

V. ALGORITHM OF RAILWAY TRAFFIC LIGHT SIGNAL RECOGNITION
To distinguish traffic light and other wagons from other objects, a CNN based algorithm was used. This algorithm was also described by the authors of this paper [15]: • Generate initial random weights and biases for other layers; • Generate initial random weights and biases for FC network; • Set an index of the selected image for training tr = 1; • Set an initial number training set and output matching ok = 0; • Set a logical value of made weight corrections cor = false.
where a, b -pixel 2D spatial (x, y) coordinates in the region Fci × Fci.

STEP 3. Pooling and feature maps
Using each j-th neuron of POOLi layer down-sample each feature map k = 1…Ki in region Fpi × Fpi: Checking the necessity for weight correction IF ok2 = 0 THEN Go to Step 12 ELSE Go to Step 13

STEP 12. Correcting all weights and biases of FC
Continue with the next image from the training set The algorithm for traffic light red signal recognition was also developed: STEP 0. Camera connection STEP 1. Setting the parameters of the picture: • height = 1024 pixels; • width = 1280 pixels; • sensitivity = 10.

STEP 2.
Creating picture "original" STEP 3. Picture "original" output STEP 4. Region of interest (ROI) detection in "original" picture by detection of the traffic light using the convolutional neural network. ROI area marking on the picture. STEP 5. ROI picture output STEP 6. Copy ROI into RGB color picture STEP 7. Dividing RGB picture into three different channels: • red (saving as r_plane variable); • green (saving as g_plane variable); • blue (saving as b_plane variable).

STEP 8.
Setting the channels intervals (from 0 to 255) for red and green colours:

VI. COMPUTER EXPERIMENTS
The following operating principle of the system was taken for the experiment: STEP 0. UAV is located on the locomotive. The UAV charger is also located there (Fig. 4). STEP 1. UAV starts moving above the train roof and finds the last train wagon by using CNN (Fig. 5).  2. UAV by using CNN distinguishes the traffic light and other objects on the rails, and recognizes the indication of the traffic light and by using distance meter finds the distance till the traffic light and other objects (Fig. 6). Fig. 6. Detecting an object on the rails and finding the distance till the object. STEP 3. UAV by using control components sends the information to the locomotive cabin (Fig. 7).    If the recognized object is a wagon, then necessary speed is calculated according to the distance till the wagon. If the object is something else, such as a human being or a car, then the train is stopped. STEP 5. UAV components control the existence of traffic lights, their indications and distance till them as well as objects on the rails and distance till them during the convergence process of wagons (Fig. 8).

STEP 6.
After the process is done, the UAV goes back to its location (Fig. 9). The system was developed for the traffic light and wagon recognition task, so for the experiment pictures of traffic lights and wagons were taken. The system also needed to distinguish them from other objects; for this purpose, pictures of human beings were taken.
Before making a computer model and checking the proposed CNN algorithm in action, the training sets and test sets had to be defined.
To define a training set of traffic lights, ROI was processed and size reduced till 48 × 48 pix (Fig. 10). ROI is based on the road turns. For the right turn, ROI was shifted to the right side from the picture centre and for the left turn, it was shifted to the left side from the centre. Road turns are recognized using the algorithm, which was described by the authors of this paper in previous research [15]. After ROI detection, the size of the chosen region was changed and filters were also used.
To define a training set of wagons, ROI was not used due to the big size of the object (Fig. 11). The developed system can recognize a different colour object on the black background, which is why it is necessary to use filters and to change the obtained picture to the appropriate form. After CNN was trained to recognize traffic lights and wagons, three training sets and three test sets with 48 × 48 pixels size samples (Fig. 12) were taken for the computer experiment to prove the efficiency of the proposed algorithm.
As a result, CNN recognized all the traffic lights and wagons correctly (Fig. 12). The pictures of other objects, such as trees and human beings, were also used in the computer experiment to find out whether the CNN could distinguish traffic lights and wagons from other objects. The untrained CNN recognized the traffic lights in 13.83 s and wagons in 21.05 s. The training process took the largest amount of time. After training was done, the recognition process took only some seconds. The positive result of the experiment proved the efficiency of the algorithm proposed earlier [15].
After the authors obtained the positive result of the traffic light recognition experiment, the experiment based on the red signal of the traffic light recognition in real time was made. For this purpose, a traffic light prototype was used (Fig. 13). The proposed system was trained to distinguish the red signal from other colour signals without any mistakes. In future the authors have a plan to test the proposed system for traffic light recognition on the real railway.  After the authors obtained the positive result of the wagon recognition experiment, it was necessary to find out the distance till the wagon and to calculate the necessary speed.
The following algorithm was proposed: STEP 1. Data obtaining: class of the object O, distance S till the object.

STEP 2.
If object O is not a wagon, then speed is reduced to zero.

STEP 3.
If object O is a wagon, then speed is calculated according the distance till the object by using fuzzy logic (Fig. 14). The algorithm for the choice of the necessary speed, according to the distance till the wagon or a group of wagons, was also proposed Table I.

VII. CONCLUSION
The results of research show that CNN is suitable for image recognition tasks. CNN is able to recognize objects from three different groups: traffic light, wagon and human being. The untrained CNN recognizes the traffic lights in 13.83 s and wagons in 21.05 s. Further recognition by the trained CNN is performed in 0.35 s by average. Time of the process might be minimized by dividing CNN training and recognition processes. The higher number of CNN feature maps results in overfitting or resource waste. More patterns for the first CNN layer are needed for better recognition -the network is very sensitive to patterns.
Experiment of traffic light red signal recognition also shows positive results; this proves the efficiency of the chosen algorithm. To recognize the traffic lights, it is worth using ROI due to the small size of the object and many distractions.
Other problems have been identified while making the research: -UAV deviates from the desired path. Possible solution -UAV returns back to the location point and starts the movement from the beginning.
-Wagons with oversized cargo. Possible solution -CNN of UAV needs to make recognition while flying above the wagons and to be ready to change the flight trajectory.
-Manoeuvres can be made on the rails with contact network or other wires. Possible solution: UAV is not flying higher than 5 meters above the ground surface (or at another height, according to the height of the wires).