scieee AI-readable full text Open interactive document viewer

Development of the vision based navigation system for mobile robot

Fuente García, Eva de la

Abstract

Departamento de Ciencias de los Materiales e Ingeniería Metalúrgica, Expresión Gráfica en la Ingeniería, Ingeniería Cartográfica, Geodesia y Fotogrametría, Ingeniería Mecánica e Ingeniería de los Procesos de Fabricación

Full text

UNIVERSIDAD DE VALLADOLID ESCUELA DE INGENIERIAS INDUSTRIALES Grado en Ingeniería Electrónica Industrial y Automática Development of the vision based navigation system for mobile robot Autor: De La Fuente García, Eva Responsable de Intercambio en la UVa Marta Herráez Sánchez Universidad de destino Vilnius Tech Valladolid, Junio 2022 TFG REALIZADO EN PROGRAMA DE INTERCAMBIO TÍTULO: Development of the vision based navigation system for mobile robot ALUMNO: Eva de la Fuente García FECHA: 7/6/2022 CENTRO: Faculty of Mechanics UNIVERSIDAD: Vilnius Tech TUTOR: Vytautas Bučinskas Resumen en español (max 150 palabras) Se ha desarrollado un sistema navegación basado en visión para un robot móvil que actuará en tuberías subterráneas. El sistema debe detectar la presencia de obstáculos en la trayectoria planificada tales como objetos o agujeros en el suelo. Si alguno de estos es encontrado e impide la continuación del seguimiento del camino planificado por el robot, el sistema presenta las instrucciones para esquivarlo y continuar con la trayectoria. El sistema de visión está formado por una unidad principal de procesamiento Raspberry Pi 4B junto con un rayo laser rojo y la Raspberry Pi Camera module v2. La programación se ha realizado en Python con la utilización de librerías de OpenCV. Se han estudiado distintos enfoques tales como la transformada de Hough, algoritmo RANSAC y contorno de componentes conexos. Además, se ha diseñado e impreso en 3D el soporte para el sistema de proyección de laser y adquisición de imagen. Palabras clave: Sistema de navegación, Raspberry Pi, línea laser, blob análisis, Python. Abstract (max 150 words) A vision-based navigation system has been developed for a mobile robot that will operate in subway pipelines. The system must detect the presence of obstacles in the planned path such as objects or holes in the ground. If any of these are found and impede the continuation of the robot's planned path, the system presents instructions to avoid them and continue the trajectory. The vision system consists of a Raspberry Pi 4B main processing unit together with a red laser beam and the Raspberry Pi Camera module v2. Programming has been done in Python using OpenCV libraries. Different methods such as the Hough transform, RANSAC algorithm and blob analysis have been studied. In addition, the support for the laser projection and image acquisition system has been designed and 3D printed. Keywords: Navigarion system, Raspberry Pi, laser line, blob analysis, Python. VILNIUS GEDIMINAS TECHNICAL UNIVERSITY FACULTY OF MECHANICS DEPARTMENT OF MECHATRONICS, ROBOTICS AND DIGITAL MANUFACTURING Eva de la Fuente García DEVELOPMENT OF THE VISION BASED NAVIGATION SYSTEM FOR MOBILE ROBOT Final Bachelor’s Project Study programme MECHATRONICS AND ROBOTICS, Code 612H73002 Vilnius, 2022 VILNIUS GEDIMINAS TECHNICAL UNIVERSITY FACULTY OF MECHANICS DEPARTMENT OF MECHATRONICS, ROBOTICS AND DIGITAL MANUFACTURING APPROVED BY Head of Department ______________________ (Signature) ______________________ (Name, Surname) ______________________ (Date) Eva de la Fuente García DEVELOPMENT OF THE VISION BASED NAVIGATION SYSTEM FOR MOBILE ROBOT Final Bachelor’s Project Study programme MECHATRONICS AND ROBOTICS, Code 612H73002 Supervisor: __________________ _______ ______ (Title, Name, Surname) (Signature) (Date) Vilnius, 2022 Vytautas Bučinskas 2022 05 24 prof., dr., Vytautas Bučinskas 2022 05 24 VILNIUS GEDIMINAS TECHNICAL UNIVERSITY Eva de la Fuente García, 20213649 (Student name and surname, Student ID) Mechanics Faculty (Faculty) Mechatronics and robotics, MRfuc-18 (Study programme, academic group) COURSE PROJECT (WORK, INTEGRATED PROJECT) DECLARATION OF ACADEMIC INTEGRITY 16 May 2022 (Date) I confirm, that my course project (work, integrated project), which topic is Development of the vision based navigation system for mobile robot is written independently. The material presented in this project (work, integrated project) is not plagiarized. Quotations from other sources used directly or indirectly are indicated in the literature references. The course project (work, integrated project) was inspected by: Vytautas Bučinskas There is no contribution of other persons to the course project (work, integrated project). I have not paid any statutory sums of money for this work. EVA DE LA FUENTE GARCIA Signature (Name and Surname) ANNOTATION 6 CONTENT LIST OF PICTURES ...................................................................................................................... 7 LIST OF TABLES .......................................................................................................................... 8 INTRODUCTION .......................................................................................................................... 9 1. OWERVIEW OF ANALOGIC CONSTRUCTIONS ........................................................ 11 1.1. Ultrasonic sensor ............................................................................................................... 11 1.2. LiDAR (Light Detection and Ranging)............................................................................. 13 1.3. Monocular camera and line-laser ...................................................................................... 15 1.4. Stereo vision ...................................................................................................................... 17 1.5. Substantiation of the decision ........................................................................................... 19 2. CALCULATION OF PROJECT .............................................................................................. 21 2.1. Static study ........................................................................................................................ 21 2.2. Frequency study ................................................................................................................ 23 3. DESCRIPTION OF THE CONSTRUCTION AND OPERATIONAL PRINCIPLE .............. 25 3.1. Electric-block scheme ....................................................................................................... 25 3.2. Algorithm of management of device or node ................................................................... 26 3.3. Results. ........................................................................................................................ 36 4. WORK SAFETY ................................................................................................................ 41 4.1. General provisions and requirements for safe working and environmental protection .... 41 4.2. Work safety of Raspberry Pi 4B 4Gb ............................................................................... 41 4.3. Work safety of red linear - positioning laser (5mw) ......................................................... 43 5. ECONOMIC CALCULATION ................................................................................................ 44 CONCLUSIONS .......................................................................................................................... 49 LIST OF LITERATURE .............................................................................................................. 51 THE ANNEXES ........................................................................................................................... 53 ANNEX 1: Installation of Raspbian on Raspberry Pi 4B ........................................................ 54 ANNEX 2: Installation of OpenCV on Raspberry Pi 4B ......................................................... 56 ANNEX 3: Code of algorithm. ................................................................................................ 59 ANNEX 4: Photos of the assembly on the robot ..................................................................... 62 ANNEX 5: Bill of Materials. ................................................................................................... 64 ANNEX 6: Drawings. .............................................................................................................. 67 13 Fig. 4. Representation of ultrasonic signal deflected due to target object’s position, resulting in error. [https://forum.arduino.cc/t/problema-con-sensor-de-ultrasonido-hc-sr04/352252] 1.2. LiDAR (Light Detection and Ranging) LiDAR (Light Detection and Ranging) also known as 3D scanning, is a device capable of measuring the distance from an emitter to an obstacle by using a pulsed light beam. As with the ultrasonic sensor, the device will measure the time it takes for the wave to propagate from emission to reception. Fig. 5. 3D LiDAR sensors. Model MRS1000 Sick. [https://www.sick.com/ag/en/detection-and-ranging-solutions/3d-lidar- sensors/mrs1000/c/g387152] This type of sensor has the advantage of being able to analyse the entire environment covering 360º of its surroundings. On the other hand, obstacles that are lower than the height at which the laser is positioned cannot be detected. Therefore, the application for which the system is being developed must be taken into account in order to achieve a good positioning of the lidar. 14 The emitter sends out a series of infrared laser beams which reflect off objects in the environment generating a point cloud every scanning period that involves a 360-degree turnaround. Once the scan has been performed, each object is represented by a set of points. On the other hand, if there is no obstacle in the range of the scanner, no point is obtained. For each point in the cloud a lot of information can be obtained such as its position and the distance to it (Wei Chen, 2009). It should be noted that an object is not given by a single point but by a set of them. Thus, it is not recommendable to use the point cloud generated by the scanner directly to generate a map of the environment where the robot is working. To obtain a map faithful to reality it is necessary to use some methods of clustering point cloud data. The generated point cloud is processed by a computer to obtain a three-dimensional image of the environment in real time providing a map of the surrounding area. Since the lidar technology allows the creation of 3D models from the point cloud, in this map it will be possible to detect any kind of obstacle. Moreover, thanks to the fact that its wavelength is considerably smaller than that of the ultrasonic sensor, it is highly accurate in detecting small objects. Finally, a grid map of the area to be analysed is constructed. This environment turns in small grids in order to be able to analyse and locate the objects with greater accuracy. Fig. 6. LiDAR point cloud for object detection. [https://edosoft.es/follow-the-lidar/] On the other hand, this sensor is far more expensive than ultrasonic one. Moreover, it should be noted that the higher the desired accuracy, the more points to take from the environment and the greater the sampling frequency, the heavier the computational load. Another drawback with respect to the sensor described above on point 1.1, is that the light emitted by a LiDAR is harmful to the human eye due to the strong pulses. 15 1.3. Monocular camera and line-laser This method consists in the configuration of a line laser and a camera. The laser beam will be projected on the horizon and it will be captured by the camera to be processed. In this way, the laser beam will be distorted in case of the presence of an obstacle. Fig. 7. System configuration. Source: “A Method for Detection of Obstacle Using Line Laser and Camera”. Kyushu Institute of Technology The distance between the laser and the camera will be fixed so that the dimensions of the object can be obtained by triangulation. In case of an obstacle the laser line will be cut off. On the contrary, if the path is free of objects, the line will not show any discontinuity. In this way, the camera will take the image of the environment in which the laser is reflected, this will be processed and it will be possible to discern if there is an obstacle or not (Miki Suetsugu, 2019). a) Laser without object. b) Laser distortion with object. Fig. 8. Image processing for laser line acquisition. Source “A Method for Detection of Obstacle Using Line Laser and Camera”. Kyushu Institute of Technology 16 Since this method is based on the projection of a laser beam, in theory there is no limitation of the maximum measurable distance. However, some experiments have shown that beyond 600mm the laser beam is seen in a very faint form making the image incapable of being processed. In contrast, it should be highlighted that this type of configuration not only allows the detection of the presence of multiple obstacles but it is also capable of measuring the distance to each of them at the same time. Some experiments have shown that the smaller the distance between the object and the robot, the higher the accuracy of the measurement (Guoqiang Fu, 2011). a) Raw image. b) Image processed. Fig. 9. Multiple object detection. Source: Paolo Dario, “An Integrated Triangulation Laser Scanner for Obstacle Detection of Miniature Mobile Robots in Indoor Environment” The three main factors influencing system performance are described below: 1. Ambient light. 2. Incidence angle of the laser beam. 3. Characteristics of the detected obstacle. When the system is working in a dark environment, the laser beam is strongly reflected making it easier to separate the laser beam from the background. On the other hand, if the surroundings are brightly illuminated, the laser is perceived as weaker, making it more difficult to separate the laser from the background in the image. Therefore, the higher the ambient light the distance at which obstacles can be sensed decreases. The second factor is the angle of incidence of the laser. The greater the angle of incidence of the laser, the more clearly it can be seen on the surface and the more accurate the measurements. 17 On the contrary, the smaller the angle of incidence, the system tends to look for objects farther away from the robot and the laser is seen in a more diffuse way, making it more difficult to process. Last but not least, the properties of the detected obstacle also play a major role in the performance of the system. The strength with which the laser is perceived is dependent on the reflectivity of the surface on which it is projected. Therefore, not only the color of the obstacle but also the material of the obstacle is very influential. Very light colors have a reflectivity of more than 70% while dark colors have a reflectivity of less than 40%. This means that the darker the object, the more difficult it is for the system to detect it. Similarly, in materials such as polished aluminum the laser will be much more detectable than in other materials such as dark concrete (Miki Suetsugu, 2019). 1.4. Stereo vision Stereo vision is a machine vision technique that can provide 3D measurements using two or more industrial cameras. The basis of stereo vision is similar to 3D perception in human vision and is based on the triangulation of rays from multiple viewpoints. In this way, a stereo vision system faithfully replicates how the eyes work to provide accurate, real-time depth perception. This is achieved by using two sensors at a set distance to triangulate similar pixels from both 2D planes. The stereo vision model can be classified into three steps: 1. Selection of a point or small region in one of the images 2. Identification in the corresponding image of the other camera 3. Measurement of the disparity between the corresponding points. These steps should be performed for all points that are considered necessary for a good interpretation of the environment. Depending on the requirements of the application, the depth can be calculated from the disparity found. The difference that occurs when projecting the same three-dimensional point under the perspective of two or more cameras with different perspectives is called disparity. In the following figure the two points given by the coordinates (xL, yL) and (xR, yR) represent the one threedimensional point captured by each of the cameras that compose the system. The location of this point on the vertical axis is the same in both images, while its horizontal location varies according to the perspective. 18 Fig. 10. Detection of a 3D point from the location of the 2D point on the images taken by the two cameras. [https://www.researchgate.net/figure/Stereo-vision-principle-two-cameras-which-view-the- same-scene-detect-a-common-3D-point_fig1_221908788] If the horizontal location of this point in the left view is xL and in the right view is xR, the disparity d that it presents is obtained by the difference of both values, as shown in the following equation. RL xxd −= (1) However, knowing the disparity of a single point is not enough to have a good understanding of the three-dimensionality of the scene. It is necessary to generate a disparity map that can represent the whole, or a significant portion, of the observed environment. There are two main types of stereo vision: active and passive. Active vision benefits from artificial illumination or a structured light source to assist visibility. In certain situations, this illumination is essential for the proper functioning of the system. On the other hand, there is passive vision which does not require any type of artificial illumination for correct operation. Therefore, only a connection, calibration and implementation of the cameras will be required (Tekkie Tak-Kei Chiu, 2009). 3D stereo vision can be CPU intensive along with significant speed loss when working in real time due to the required algorithms such as "Semi Global Matching" (SGM). This not only performs stereo matching using 2 cameras but also performs lens distortion compensation. This achieves stereo vision that works accurately and consistently over time. 19 As discussed above, passive 3D stereo camera systems can be implemented without the need for lasers / LEDs and can generally operate effectively in most ambient lighting conditions. This type of implementation can be much more affordable than other 3D vision technologies. In contrast, if the system is operated in low light or with untextured surfaces, stereo vision tends to perform poorly. Another advantage of this sensing is that it does not impose restrictions on the range of motion on the target object, as other 3D profiling technologies do. This allows stereo vision to cope with long distances and moving objects. Once calibrated, a stereo vision system can detect depth in real time, and when combined with the appropriate software to display the 3D image, it is possible to obtain color depth mapping for increased visibility as shown in the figure below. Fig. 11. Depth map generated from stereo vision. [https://www.researchgate.net/figure/Depth-map-generated-from- stereovision_fig2_239618382] 1.5. Substantiation of the decision After a study of all the possible solutions for the objective of this thesis, it has been decided to choose the proposal explained in point 1.3. Monocular camera and line-laser. This solution has many advantages over the others presented for the required application. First of all, it has a wide operating angle as opposed to an ultrasonic sensor. In addition, with this method it is possible to detect multiple objects at the same time up to a depth of 600mm without any problems. Secondly, this method has no major restrictions with ambient light. As discussed above, a dark environment will increase the efficiency of the image processing in segmenting the laser beam from 20 the background. However, this system is also capable of working in ambient light conditions with a smaller range of distances. For the application of this thesis this aspect will not suppose a problem. Another aspect to take into account is that the material necessary to build the system does not have a high economic cost. It will require a camera, a laser beam and a computer capable of processing the image in real time. Specifically for this project we will use a Raspberry Pi 4 Computer Model B with 4Gb of RAM along with the Raspberry Pi Camera module 2. The support for the elements of the system have been printed in PLA with a 3D printer. As far as image processing is concerned, it will only be necessary to observe whether the laser line has been cut. Thus, if there is only one line, it means that there is no obstacle present, while if there is more than one line, there is at least one object in the way. Unlike other solutions such as stereo vision that present a great complexity in software development along with a large computational burden by having to process and unify two frames, this solution is much more simplified in terms of software without presenting any drawbacks. By having only one camera, one image will only have to be processed in such a way that the laser beam is segmented from the background to be able to discern whether it has been cut by an object or not. Finally, one aspect that has been critical to the decision of which method to implement has been the detection of holes. While systems such as an ultrasonic sensor or a LiDAR radar are not capable of detecting the presence of holes, this system is able to do so. Moreover, this detection does not imply an added complexity in the programming of the system. It should be noted that although in this thesis it is only necessary to know whether or not there is an object on the path, with this system consisting of a laser and a camera it is possible to obtain additional information that other systems are unable to do. As long as the distance between the laser and the camera is fixed, it is possible to find the location of the obstacle with respect to the robot. In addition, other characteristics of the object such as its height and width can be calculated. In this way, the project is not limited at any time to be developed with more applications in the future with the need to replace the system. 21 2. CALCULATION OF PROJECT In order to see the viability of the system designed in this thesis, SolidWorks 2021 software has been used to perform different studies such as stress and frequency studies. The whole system is designed in 3D with PLA (Polylactic acid) material which presents a good resistance for the objective to be achieved in this thesis. 2.1. Static study The fastenings of the system have been defined together with the forces to which it is subjected have been defined for the purpose of the static study. Fig. 12. Forces and fastenings of the system. The green color shows the fixed fasteners. The two presented at the base of the support will be the union with the robot while the one presented on the projection of the base is the union with the rest of the system. On the other hand, the blue cylindrical shapes represent pin-type connectors as they are the ones that most closely resemble the function of the bolts located in that position. 22 In addition to the fastenings, the forces to which the system is subjected must be defined in order to make a study that is true to reality. First of all, the force of gravity has been defined, represented by a red line. Together with this we have defined the masses corresponding to the objects that interact with the system, the camera and the laser 3g and 13g respectively. These act as masses distributed on their corresponding supports. 2.1.1.- Stress study Once the forces acting on the system have been defined together with the restraints, the stress study is performed. Fig. 13. Result obtained from stress study. On the right side of the image, it can be seen the scale used for the study of stresses together with the criteria, in this case von Mises measured in N/m2. This study shows the force concentrated on a surface measured in m2. In general, a structure free of large stresses is obtained, except for the joint parts whose thickness is 5 mm. This is caused by the fact that these joints are in charge of supporting the weight of both the laser and the camera. For this purpose, bolts of metric 5 have been chosen. 29 In this parameter space (also called Hough space), each point (x, y) of the image plane becomes a line of slope -x and ordinate in origin y, which represents the locus of all lines in the image plane passing through the point (x, y). Consequently, the intersection in parameter space of two straight lines (x1, y1) and (x2, y2) gives rise to the pair (a0, b0) corresponding to the line that, in coordinate space, passes through the points (x1, y1) and (x2, y2), as illustrated in the figure. Thus, points aligned in the image plane are transformed in Hough space into straight lines that intersect at a single point (a0, b0). Fig. 19. Lines Detection with Hough Transform. [https://towardsdatascience.com/lines-detection-with-hough-transform-84020b3b1549] To apply the Hough transform it is necessary to discretize the parameter space in a series of cells called accumulation cells. All the possible values that the parameters a and b are discretized; in this way all the potential lines existing in the image will be searched, giving rise to what is called the accumulation matrix. At the end of the process, the number of votes obtained in each cell indicates the number of points of the contour image that, except for discretization errors, satisfy the equation of the corresponding line. Therefore, the cells with the highest accumulation of votes constitute the set of detected straight lines. For this purpose, a threshold is used, above which the line is said to exist. This threshold can be modified, so that one can be more or less restrictive when considering whether a cell is a straight line or not. 30 A problem that arises when using equation 4 to represent the lines is that both the slope and the ordinate to the origin can become infinite as the line becomes vertical. One way to solve this problem is to use the polar representation of the straight line.  senyx += cos (4) where  is the distance from the line to the origin and  is the angle that the normal forms with the x-axis: Fig. 20. Parameters of a line in polar coordinates. Source: J. Hernández and R. Rodríguez, “Segmentación de Imágenes: Técnicas de Ajuste a Modelos” The way of constructing the accumulation matrix in the plane - is similar to the one described above, the only difference being that, instead of straight lines, sinusoidal curves will be obtained. Thus, M collinear points belonging to a straight line as shown in equation 5, will give rise to M sinusoidal curves that will intersect, in parameter space, at the point (j ,j). jjj senyx  += cos (5) (a) Image space. (b) Parameter space corresponding to (m,c) parametrization.   x y 31 (c) Accumulator array corresponding to (m,c) parameterization. (d) Parameter space corresponding to {,} parameterization. Fig. 21. Hough Transformation process. Source: Daniel C.I.Walsh, “The Importance Sampling Hough Transform” Since the contour points used usually come from a contour detection method, their position may be affected by errors due to noise, spurious effects, illumination, etc.. Therefore, the cells with the highest accumulation will not appear in isolation in the parameter space, but will be found as part of clusters of cells with high votes. To control this in the call to the function that performs this transformation, it is possible to indicate the resolution of the concentration matrix of both  and . If the orientation of the contours is known, information provided by the edge detection, for each contour point it is only necessary to vote in the box corresponding to that contour line defined by the point and orientation. Attention must be paid to the accuracy of the calculation of the gradient direction. Therefore, it is recommended to vote also in the boxes corresponding to +-20º deviations. A drawback of the Hough transform is its computational cost since the number of operations is high. Although it is becoming less and less due to the development of computers. 3.2.2.- RANSAC RANSAC is the abbreviation for "RANdom SAmple Consensus". It is a robust estimation algorithm that makes it possible to find a mathematical model from data contaminated with many outlier data. 32 For the use of this method, it is necessary to have previously performed the identification of contours with a suitable threshold of the image. Then, two random points of the image are selected and linearly adjusted by the least squares method to a straight line. Once the parameters of the line made by the two randomly taken points have been obtained, a verification process begins. In this process it is checked if the mathematical model obtained is valid or not, and it is decided if it is necessary to obtain another one from another set of points. For this purpose, the number of points in the image that fit the line found with a tolerance t is determined. If the number of found inliers is the highest, it is saved as the current model. The algorithm will be repeated as many times as indicated by the defined k parameter (J. Hernández Hernández, 2008). The algorithm will be repeated as many times as indicated by the defined k parameter. Finally, once the loop is finished, the model will be valid as long as d, the algorithm parameter, or more points match the model. Therefore, the algorithm needs three parameters to control the estimation process of the model: 1. The maximum number of iterations k that the algorithm has to perform. 2. The tolerance t to determine when a pixel fits a model. 3. The number of inliers d that guarantees that a model is valid. The algorithm is in principle programmed to stop after a certain number of iterations presenting the best model obtained but it can also be programmed to stop if the number of points close to the model is higher than a preset threshold, considering that the fit is already valid. RANSAC is not a deterministic algorithm and therefore the model it provides is valid only with a given probability, and this probability increases as more iterations are carried out. Fig. 22. RANSAC applied in a noisy dataset. 33 [https://www.researchgate.net/figure/An-example-of-line-fitting-to-a-noisy-dataset-using- RANSAC-Two-points-are-chosen-to_fig21_317964315] Due to the fact that these methods are only capable of detecting straight lines, the navigation system would not be able to work on surfaces with irregularities in the ground. Not only that would be the problem, but also this system would not be able to detect the projection over a hole as it could take a curved shape. These limitations, together with the large computational load involved in executing these methods, have resulted in the search for another method for the navigation system. One of the possibilities studied is blob analysis. 3.2.4.- Blob analysis Image labeling consists of locating connected components in a binary image. In order to determine their connectivity, some properties are analyzed looking for similarities. This technique locates different regions of an image making easier the segmentation task. In OpenCV there are four possible ways to perform blob analysis: 1. cv2.connectedComponents 2. cv2.connectedComponentsWithStats 3. cv2.connectedComponentsWithAlgorithm 4. cv2.connectedComponentsWithStatsWithAlgorithm The most common and the one that will be used in this thesis is the third one. The output is a matrix commonly called Stats whose length corresponds to the number of connected elements found. This matrix takes the form stats [label, COLUMN] where label identifies the component and column gives certain features of that component as where bounding box is, which size does it have and the centroid of it. The flowchart is shown in Fig. 31 representing the algorithm explained above. It can be visualized in A1 format in the point referring to the drawings in the annexes at the end of this document. 34 Fig. 23. Flowchart of algorithm of management. 35 The system has as input the image captured by the Raspberry Pi camera 2. Then the first thing to do is the segmentation of the laser and the background for which the red channel of the RGB image will be taken since the laser is of that color. In this channel will appear red dots not coming from the laser beam which are not interesting to take into account, for this reason it has been decided to make a histogram to establish a threshold with which to discriminate the noise and the laser beam. Finally, a binarization is performed with the established threshold obtaining as output the binarized image. It should be noted that it is not interesting to process the image completely because it is only relevant to study if there is any kind of obstacle or hole on the ground. For this reason, only a strip has been taken in the image to look for the presence of objects. In the same way, the width of the image is limited, since outside this band the presence of an obstacle would not imply the need to change trajectory. For example, if there is an obstacle on the far left and far right of the image, the robot is able to pass between the two without any problems. Once the frame of interest of the image is obtained, the continuity of the laser line in the image is studied. For this purpose, each blob of the image has been labeled and colored in order to detect more quickly the number of laser beam sections. The image obtained is displayed on the screen together with the number of isolated objects recognized. The number of blobs will be high because the image contains noise that must be filtered out. The filter used is a size filter defining the minimum and maximum area that the spots must have in order to be detected. For this, all the blobs of the image are traversed and the conditional sentence is established if the area meets with the thresholds. If it does, it implies that it is a laser section, therefore it is a spot of interest and it will be stored in a new array of filtered spots. In addition, a counter associated with the blobs of interest is incremented. On the other hand, if such a blob does not meet the established area thresholds, iterate to the next one until all the blobs have been covered. Finally, the number of laser fragments detected is displayed on the screen. The next step is to go through the blob by blob again, counting the number of spots on the left and right side of the image. This information will be of great interest to recognize an obstaclefree path where the robot can deviate. 36 At this point the number of laser beam fragments in the image is accurately measured, which assumes that it is possible to discern the presence of an obstacle or not. The system will not only be able to do this, but in the event that the robot cannot continue its trajectory due to the presence of an obstacle in the path, it will give an answer as to where to turn. A conditional statement is established that will differentiate whether there are discontinuities in the detected laser line or not. If there are no discontinuities it assumes that there are no obstacles in the path and that the robot can continue with the planned trajectory. On the contrary, in case the laser line presents discontinuities, it implies that there is at least one obstacle in the trajectory and that it is therefore essential to change the trajectory. The direction of the new path that the robot will follow will be given by the difference of the line projected on the left side versus the one on the right side. Thus, if the amount of continuous laser beam on the left is longer than that on the right, it means that the path on the left contains fewer obstacles and irregularities in the path and vice versa. Therefore, the system has three possible outputs: to continue with the planned trajectory and to recalculate a new path to follow by turning left or right. Finally, the image is re-acquired and the loop starts again, allowing a collision-free navigation of the mobile robot in real time. 3.3. Results. The results obtained with the three algorithms explained above are shown below: Hough Transform, RANSAC and Blob analysis. The advantages and disadvantages of each of them will be studied. 3.3.1.- Results: Hough Transform and RANSAC The detection of laser lines projected on the ground is similar for the RANSAC algorithm and Hough transform. In both algorithms a good laser detection is obtained as we can see in the following figures. The difference between the two methods is that on the one hand it is much easier to adjust the values of the RANSAC parameters with respect to Hough (D.A. Forsyth, 2016). On the other hand, the computation time of the first one is much longer than Hough because it must perform a larger number of operations. 37 Fig. 24. Original image and image obtained with R channel. Fig. 25. Canny image and result image with lines detected. Fig. 26. Program Output. First of all, the red channel of the RGB image has been taken since we are working with a red laser. Subsequently a contour detection has been performed together with the application of numerous filters to eliminate noise. Finally, the lines of the image are detected, in case there are more than two, it means that there is an object in the path of the robot. As set out above, due to the fact that these methods are only capable of detecting straight lines so that the navigation system would not be able to work on surfaces with irregularities in the ground. Another problem that presents this method is that the system would not be able to detect the projection over a hole as it could take a curved shape. It has been decided to search for another method for the navigation system not only for these limitations but for the large computational load involved in executing these methods. Another possible method for detecting line laser is blob analysis. 38 3.3.2.- Results: Blob analysis First of all, once the image has been acquired, the laser beam must be segmented from the background. To do this, the image can be processed in the RGB or HSV color space. In the case of RGB, it will be enough to take the channel of the same color as the laser, in this case red. HSV (Hue; Saturation; Value) is a cylindrical model that defines a color model in terms of its components. To carry out the segmentation with this color space, a pair of vectors of three values are defined to act as thresholds. Thus, values within the threshold will take the value 1 and those outside the threshold will take the value 0 [11]. Fig. 27. RGB and HSV color space. [https://www.researchgate.net/figure/Espacios-de-colores-RGB-y-HSV_fig1_351785444] For the application developed in this thesis it has been decided to work with the red channel of the RGB color space since the environment will have a very low illumination highly contrasting with the laser beam. Fig. 28. Original image and image obtained with R channel. Once the red channel of the image has been taken, a binarization is performed, for which it is necessary to establish a threshold. It has been decided to make a histogram of the image to see the weight and location of the pixels at high and low level, in this case we have taken the value 80. 45 Finally, an operator is needed to place the parts to be printed and to assemble them. It has been estimated that the preparation time needed to start printing, which may include small calibrations or adjustments of the printer, is 15 minutes. On the other hand, the operator will have another 15 minutes to perform the final assembly, since it is not very complex. Taking into account these times and the fact that the operator's salary is 15€/h, the cost associated with the worker's salary for each printed piece is 3.75€. Adding the assembly cost, the price per manufactured unit is €15 per assembled system. Table 2. Variable and fix costs. PLA cost (€/Kg) 20 Light cost (€/KWh) 0,15 Average consumption (KW) 0,5 Light cost per hour (€/h) 0,075 Operator hourly cost (€/h) 15 Preparation time for piece (h) 0,25 Postproduction time (h) 0,25 Cost operator per piece (€/piece) 3,75 Assembly cost (€/piece) 3,75 3D printer cost (€) 1500 Amortization time (years) 5 Active days per year (days) 250 Active hours per day (h) 8 Amortization cost (€/h) 0,15 Local renting (Eur) 1500 Time for produce 1 unit (h) 9 Units per month 17 Cost local per unit (Eur) 88,23529 Once the costs have been defined, the calculation of the cost associated with each part that makes up the system has been carried out. For this purpose, the weight of the part has been taken into account together with the estimated printing time. In this way it is possible to calculate the cost associated with PLA, electricity, labor and amortization of the machinery used. It should be noted that all the parts have been printed with 20% density, so this has not entailed any additional cost. As a final result, the cost of printing the three pieces that make up the system is 17.62€. Table 3. Printed pieces cost. 46 Printed pieces Base-Camera support joint Camera support Base-Robot joint TOTAL (Eur) Weight (g) 11,1 3,9 20,3 35,3 Printing time (h) 3 1 4,5 8,5 PLA Cost (Eur) 0,22 0,08 0,41 0,71 Electric cost (Eur) 0,23 0,08 0,34 0,64 Workforce cost (Eur) 3,75 3,75 3,75 11,25 Amortization cost (Eur) 0,45 0,15 0,68 1,28 Sum (Eur) 4,65 4,05 5,17 13,87 Assembly (Eur) 3,75 TOTAL SET 17,62 The total cost of manufacturing each navigation system is estimated. To do so, previous calculations will be used, resulting in a total cost of 228.33 €. To this it is necessary to add the profit that will be obtained by the sale of each unit. The selling price to the public has been set at 255 €, leaving a profit of 26.67 €, assuming about 10% benefit, per item. Below is a table specifying the costs associated with each unit along with the pie chart. Table 4. Cost per unit produced. Cost per unit Eur Material cost (Eur) 123,19 Electric cost (Eur) 0,64 Workforce cost (Eur) 15,00 Amortization cost (Eur) 1,28 Net profit (Eur) 26,67 Local renting (Eur) 88,24 Total cost without profit 228,33 Selling price 255,00 47 Fig. 32. Economical estimation per unit produced. The payback period is then calculated. For this purpose, the profit obtained per unit sold has been equated to the cost generated by the production of the unit. The equations that model the profit and cost are as follows where q represents the quantity of units sold. 228.33q+1500=(q)Cost (6) 255q=(q)Profit (7) Equating both equations result in the point of intersection. This point symbolizes the point at which profit begins to be made on the product manufactured (Dr. Audrius Dzikevičius, 2019). In this case, it will only be necessary to manufacture 57 units to start making a profit. These units represent an economic amount of both benefits and costs of 14535€. Profit=Cost (8) 255q=228.33q+1500 units 57=q € 14535=Profit(57)=Cost(57) 48 Fig. 33. Payback period. This product has many advantages over other navigation systems that are currently available on the market. First of all, this system can be implemented on any robot that is going to work in low light conditions. It proves to be very flexible for numerous applications since both the inclination of the laser and the camera is adjustable for any kind of environment. The vision system is able to locate obstacles and holes not only on a flat floor but also on irregular or even circular floors such as a pipe. It should also be noted that the durability of the system is high due to the low number of electronic components it requires being only a Raspberry, a camera and a laser, this is a great saving in the long term. In case it is necessary to replace any of the components it will not be a problem because all of them are easily accessible and removable. 49 CONCLUSIONS 1. Currently, the number of obstacle avoidance systems on the market is very large and continues to increase considerably due to the rise of autonomous vehicles. Some of them are sensors such as ultrasonic, infrared, LiDAR (Light Detection and Ranging), monocular camera and line-laser. Therefore, it is important to carry out an exhaustive study of the requirements in order to implement the system that best suits them. In the case of this thesis, a vision-based navigation system has been chosen. 2. The developed navigation system features a compact design, with easy maintenance, which will reduce future costs. Furthermore, it is able to react in real time without a high computational load, which is a prerequisite for the application. Therefore, the system is robust and cost-effective compared to other solutions available on the market. 3. Different design studies have been carried out in SolidWorks software such as stress study, displacement study and frequency study. A maximum stress in the system of the order of e- 04 Nm2 has been obtained, which shows that the system is able to withstand the masses and forces applied on it without presenting problems. The displacement study is also positive since the maximum displacement is of the order of e-04 mm in the upper part of the chamber support. Finally, it has also been verified that the assembly does not resonate with the working environment. Therefore, it has been verified that the design is robust. 4. The electrical diagram of the system has been made showing the interaction of the different components of the robot. The vision system consists of a Raspberry Pi 4B together with the Raspberry Pi camera module v2 and a red linear laser. 5. Three different algorithms have been developed to identify the presence or absence of an obstacle in the robot's trajectory. The first two, Hough Transform and RANSAC, showed good results, however, being iterative methods, they were computationally intensive and slower. Being a real-time system, it is strictly necessary that the system reacts quickly. In addition, these two methods have great limitations of the robot's working space, as the surface on which the trajectory is performed must be completely flat and regular. This led to the search for a new method, blob analysis. This is able to work on irregular surfaces and can even detect the presence of holes in the ground. Another advantage is that the computational load is much lower than the previous ones and therefore the response is faster, being more convenient for a real time system. 50 6. Some important aspects to be taken into account when setting up and using the system have been detailed. These are relevant not only for the maintenance of the equipment but also for the safety of people in the proximity of the robot. In addition, some instructions for the correct operation of the system have been provided. In case these steps are not followed, the proper functioning of the system is not ensured. 7. A study of the costs involved in producing the designed article has been carried out. It has been found that this solution is significantly less expensive than others on the market. One of the most significant parameters is the payback period which establishes the number of units that must be sold in order to start making a profit, in this case it has turned out to be only 57 units. 51 LIST OF LITERATURE 1. “Application of artificial vision in production environments. Model adjustment and detection.” Master's Degree in Industrial Informatics. University of Valladolid. 2. Amruta Nikam, Akshata Doddamani, Divya Deshpande, Shrinivas Manjramkar. “Raspberry Pi based obstacle avoiding robot”. International Research Journal of Engineering and Technology (IRJET). Volume: 04 Issue: 02. Feb -2017. 3. D.A. Forsyth, I. Kokkinos. “Introduction to Computer Vision Hough Transform and RANSAC.” University of Virginia. 4. Detection of a specific color (blue here) using OpenCV with Python. December 2021. Detection of a specific color(blue here) using OpenCV with Python - GeeksforGeeks 5. Dr. Audrius Dzikevičius. Slides “Economic part”. Euroconsultant goup financial, investment and business consulting services. 2019. 6. Extracting a laser line in an image (using OpenCV). Stack Overflow. c++ - Extracting a laser line in an image (using OpenCV) - Stack Overflow 7. Fitri Utaminingrum, Hurriyatul Fitriyah, Randy Cahya Wihandika, M Ali Fauzi, Dahnial Syauqy, Rizal Maulana. “Fast Obstacle Distance Estimation using Laser Line Imaging Technique for Smart Wheelchair”. Faculty of Computer Science, Brawijaya University, Malang, Indonesia. 2016. 8. Gowtham Rajmohan, “Obstacle detection and avoidance methods for autonomous mobile robot”. June 2016. 9. Guoqiang Fu, Paolo Corradi, Arianna Menciassi, and Paolo Dario. “An Integrated Triangulation Laser Scanner for Obstacle Detection of Miniature Mobile Robots in Indoor Environment”. IEEE Xplore. August 2011. 10. J. Hernández Hernández, R. Rodríguez Vicente. “Implementation of a RANSAC algorithm for image segmentation.” September 2008. 11. Laser Pointer Safety. The Laser Institute. August 2017. https://www.lia.org/resources/lasersafety-information/laser-pointer-safety 12. Microcontroller Tips. “The working principle, applications and limitations of ultrasonic sensors”. August 2019. https://www.microcontrollertips.com/principle-applications-limitations- ultrasonic-sensors-faq/ 13. Miki Suetsugu, Kanako Kinoshita, Shiyuan Yang, Siichi Serikawa. “A Method for Detection of Obstacle Using Line Laser and Camera”. Proceedings of the 7th IIAE International Conference on Industrial Application Engineering 2019. 52 14. Obstacle detection using Laser and image processing on LOGI-Bone. Dec 2014. Obstacle detection using Laser and image processing on LOGI-Bone - Blog - FPGA - element14 Community 15. Peter Neal. Obstacle detection using OpneCV. December 2014. https://bigfacerobotics.wordpress.com/2014/12/18/obstacle-detection-using-opencv/ 16. R. Gowtham. “Obstacle Detection and Avoidance Methods for Autonomous Mobile Robot”. International Journal of Science and Research (IJSR). June 2016. 17. Raspberry Pi Regulatory Compliance and Safety Information. Fanell. https://www.farnell.com/datasheets/1835724.pdf 18. Sam Westby Tech. How to Install OpenCV on a Raspberry Pi. (1188) How to Install OpenCV on a Raspberry Pi - YouTube 19. Tekkie Tak-Kei Chiu. “Stereo Vision Based Obstacle Avoidance in Indoor Environments”. School of Mechanical and Manufacturing Engineering. University of New South Wales. 20. Todd Danko. Webcam Based DIY Laser Rangefinder. https://sites.google.com/site/todddanko/home/webcam_laser_ranger 21. Tzung-Han Lin, Chi-Yun Yang, and Wen-Pin Shih.” Fall Prevention Shoes Using Camera-Based Line-Laser Obstacle Detection System.” National Taiwan University. May 2017. 22. What is LiDAR and How Does it Work? GeoSLAM, March 2022. https://geoslam.com/what-is- lidarsurveying/#:~:text=LiDAR%20is%20an%20acronym%20for,maps%20of%20objects%20a nd%20environments. 53 THE ANNEXES 54 ANNEX 1: Installation of Raspbian on Raspberry Pi 4B First of all, it was necessary to install a graphical operating system on the raspberry to be able to edit and run the image processing program. To do this, the Raspberry Pi 4B was first booted with the traditional MicroSD card. Then the following commands were executed to update the system: sudo apt update sudo apt full-upgrade Once the update has been performed, it is recommended to restart the system. The reboot command is used for this purpose. sudo reboot Finally, the system is prepared to boot from a MicroSD card. To do this, enter the terminal settings and then select the "Advanced Options" option. A new menu will be displayed on the screen in which we will find the option A6 referred to "Boot Order". Again, another menu will be displayed in which you can configure the order of devices to boot the Raspberry Pi, including the MicroUSB and a USB in case of having any connected. Many performance tests have shown that booting the system and using programs is much faster and smoother with a micro-SD than with a flash drive connected to a USB port. Using a flash drive in the Raspberry will cause the micro-computer to run much slower than using a memory card. In the development of this navigation system a fast image processing in real time is needed so it has been decided to boot the system in the fastest possible way, that is, by MicroSD. sudo raspi-config Fig. 34. Raspberry Pi software configuration tool. Fig. 35. Advanced Options menu. 61 total_line = line_left + line_right if w-total_line > w*0.3: #obstacle is bigger than 30% width, need to turn if line_left >= line_right: print('Turn left') else: print('Turn right') else: #not a big obstacle print('Go forward') 62 ANNEX 4: Photos of the assembly on the robot Fig. 43. Front view of the robot. 63 Fig. 44. Right view of the robot. 64 ANNEX 5: Bill of Materials. 65 66 67 ANNEX 6: Drawings. Range of rotation of camera: 35º to 180º Range of rotation of base: 0º to 90º Image processing by Raspberry Pi 4B 4Gb. Raspberry Pi 4B Voltage 5V DC Camera: Raspberry Pi Camera Module 2. Sensor resolution: 3280 × 2464 pixels. Still resolution: 8 Megapixels. Optical Size: 1/4". Laser: Red linear - Positioning laser. Output power: 5mW. Working voltage: 3 ~ 5V. Working temperature: + 10 ~ + 40C 3 1 2 5 4 27,00 180,00° 35,00° 90,00° ,00° 138,20 20,51 1 Additional information Owner VGTU MRfuc-18 Drawn by Eva de la Fuente Garcia Approved by Consulted by Case No. Scale 2:1 Language Document status Educational Title General View Type of document Material Sign Date 2022/04/21 Release A EN Page Engineering Responsible department MERS BM 22 01 01 00 00 GV Producto SOLIDWORKS Educational. Solo para uso en la enseñanza. MERS BM 22 01 01 00 00 GV 3 1 2 12 11 14 13 4 65 10 9 8 27,00 180,00° 35,00° 90,00° ,00° 7 15 125,00 20,51 The camera must be fixed by the 4 metric bolts 2. The angle of inclination of the camera must be chosen in such a way that it is able to capture the projection of the laser on the ground. The laser must be inserted in its support and fixed with the two metric bolts 3. In the same way as the camera, the angle of inclination of the laser must be adjusted by means of the base-body union. This angle of inclination will be decided according to the distance at which you want to detect the objects. Robot base joint bolts: M6. Bolts for base and body: M5. Laser support bolts: M3. Camera and camera support joint bolts: M2. 2 Additional information Owner VGTU MRfuc-18 Drawn by Eva de la Fuente Garcia Approved by Consulted by Case No. Scale 2:1 Language Document status Educational Title Assembly Type of document Material Sign Date 2022/04/21 Release A EN Page Engineering Responsible department MERS BM 22 01 01 01 00 AD Producto SOLIDWORKS Educational. Solo para uso en la enseñanza. MERS BM 22 01 01 01 00 AD Mechatronics Responsible department Case No. Scale 1.4:1 Type of document Document status Material Educational Additional information Consulted by 2/7 Page EN LenDate SignDrown by: Daniel Calvo Sanz Approved by Owner VGTU Tittle Assembly Drawing Release Eva de la Fuente García Flowchart 10/05/2022 3 VGTU MRfuc-18 Engineering