Full text
Application of computer vision techniques for laser-based global localization of a mobile robot in a known, static environment BACHELOR THESIS Performed with the purpose of obtaining the academic degree of Bachelor of Science (BSc) Under the supervision of Paloma de la Puente Yusty Submitted to Vienna University of Technology Faculty of Electrical Engineering and Information Technology Institute of Automation and Control by Miguel Castill´on S´anchez Matriculation number: 1428044 <Vienna, June 19th, 2015> Vision for Robotics Group A-1040 Vienna, Gußhausstraße 27, Internet: http://www.acin.tuwien.ac.at
Resumen El problema de la localizaci´on global, es decir, la localizaci´on de un robot en un entorno conocido sin informaci´on sobre sus estados previos, ha sido ampliamente estudiado mediante diferentes m´etodos en la literatura. Un gran n´umero de algoritmos han sido presentados y probados considerando varias condiciones. El objetivo de este trabajo es comparar diferentes m´etodos de representaci´on de ocupaci´on de celdillas construidos a partir de datos provistos por un l´aser utilizando t´ecnicas de visi´on por computador. El enfoque seguido usa comparaci´on visual de un mapa global con uno local, creado gracias al sensor l´aser. Esta elecci´on permite una f´acil integraci´on con sistemas rob´oticos existentes al mismo tiempo que evita problemas t´ıpicos de soluciones puramente visuales, como la influencia de cambios de iluminaci´on. Los dos algoritmos comparados—basados en ´area y en puntos caracter´ısticos, respectivamente—han sido evaluados en un entorno interior simulado. Se ha asumido una situaci´on est´atica, sin presencia de obst´aculos m´oviles. El trabajo ha sido realizado durante un programa de movilidad en el extranjero, por lo que el resto del documento se adapta en fondo y forma a las especificaciones de la Universidad de destino. I
Abstract The problem of global localization, that is, the localization of a robot in a known environment without information of its previous states, has been vastly studied through different approaches in the literature. A large number of algorithms have been presented and tested considering various conditions. The aim of this thesis is to compare different methods for occupancy-grid representations built from laser data using Computer Vision techniques. The approach followed uses visual matching of a global and a local map, created from data provided by a laser sensor. This choice allows an easy integration with existing robotic systems at the same time that avoids typical problems of purely visual solutions, such as the influence of lighting changes. The two algorithms compared—area-based and feature-based, respectively—have been tested in a simulated indoor environment. A static situation has been assumed, without presence of mobile obstacles. II
Contents 1 Description of the Problem 1 1.1 State of the Art ........................... 3 2 Approach 4 2.1 Difficulties .............................. 5 2.2 Tools used .............................. 6 2.2.1 ROS ............................. 6 2.2.2 OpenCV ............................ 7 2.2.3 Gazebo ............................ 7 2.2.4 RViz .............................. 7 2.2.5 Biicode ............................ 8 2.3 Preprocessing of local maps .................... 8 2.3.1 Dealing with occlusions ................... 8 2.3.2 Opening ........................... 9 2.4 Matching methods ......................... 10 2.4.1 matchTemplate ........................ 11 2.4.2 SURF ............................ 12 2.5 Calculating the position of the robot ............... 13 3 Integration with ROS 17 3.1 ROS node .............................. 18 4 Results 21 4.1 Local maps extracted from the global map ............ 22 4.1.1 Performance by method .................. 23 4.1.2 Influence of the angle increment in matchTemplate . . . 24 4.1.3 Influence of the size of the local map ........... 24 4.1.4 Conclusions ......................... 26 4.2 Simulation ............................... 27 4.2.1 Performance by method .................. 28 4.2.2 Influence of the characteristics of the laser sensor . . . . 29 4.2.3 Influence of the angle increment in matchTemplate . . . 30 4.2.4 Conclusions ......................... 30 5 Conclusions 33 6 Future Work 34 A Model of the Robot 35 B SLAM 36 References 37 III
List of Figures 1.1 Position of the robot referred to the global coordinate system. Figure extracted from [1] ...................... 2 2.1 Local coordinate system of the robot in the local map ...... 4 2.2 Global localization process ..................... 5 2.3 Global and local map ........................ 6 2.4 Local map before and after cropping ............... 9 2.5 Local map before and after applying opening ........... 10 2.6 Opening process not properly adjusted .............. 10 2.7 Position of the robot in the matched local map .......... 14 2.8 Cropped local map, original in dashed line ............ 15 3.1 ROS linking .............................. 17 3.2 Laser measurements into the coordinate system attached to the local map .............................. 19 3.3 Relocalization of the robot in RViz. Red dots represent the laser data ................................. 20 3.4 Relocalization of the robot in RViz. Red dots represent the laser data ................................. 20 4.1 Local map rotated 0 ° ........................ 22 4.2 Local map rotated 175 ° ....................... 22 4.3 Successful matching by SURF ................... 23 4.4 Unsuccessful matching by SURF .................. 23 4.5 Success rate and time used by each method ........... 24 4.6 Success rate and average time for different ∆α.......... 25 4.7 Influence of the size of the local map ............... 25 4.8 Number of positions checked in matchTemplate for different local map sizes .............................. 26 4.9 Robot calculating its position in real-time simulation ....... 27 4.10 Local map created in simulation before and after cropping . . . . 27 4.11 Local map created in simulation before and after opening . . . . 28 4.12 Success rate and average time used by each method ....... 28 4.13 Success rate for different fields of vision .............. 29 4.14 Average time used by different fields of vision .......... 30 4.15 Success rate and average time for different ranges ......... 31 4.16 Success rate and average time for by different angle increments . 32 4.17 Unsuccessful matching by SURF .................. 32 4.18 Two different situations simulated in gazebo ........... 32 A.1 Robot Pioneer 3-DX, used for the simulations .......... 35 A.2 Scheme of the physical model of the robot ............ 35 IV
1 Description of the Problem One of the most fundamental abilities required for the navigation of a mobile robot is that of self-localization, which consists on the recognition of the current position. A large number of methods concerning different approaches have been proposed and tested, such as [2] [3] [4]. The self-localization of a robot is usually divided into two different parts: position tracking and global localization, as stated in [ 5 ]. The first subproblem assumes that the initial location of the robot is known and tries to estimate the following ones incrementally, based on the last estimation and the data provided by the sensors. The second part, on the other hand, concerns the relocalization of the robot under global uncertainty. This means that the position of the robot in previous instants is completely unknown, and the current location may be anywhere inside the global map. The aim of this thesis is to analyze a possible solution for the second subproblem of self-localization: the global localization of a robot. It is also defended in [ 5 ] that the ability to recognize places using landmarks usually plays an important role in obtaining better localization results, since high level place recognition can detect more distinctiveness. In [ 6 ] it is stated that the key issue in the so-called kidnapped-robot problem is that of properly matching sensor data provided by exteroceptive sensors to a world model. The reason is that the information given by proprioceptive sensors lacks of utility, since the state in previous instants is not known. In the realization of this project the following hypotheses are assumed: The global environment is accurately modeled and available for the matching process—or can be a priori modeled. This is a reasonable premise, as it would not be possible for the robot to find its position if it is in an unknown area. However, it would not be appropriate for exploration purposes. The environment is static, which means that the obstacles that can be encountered do not change their position over time. It restricts its application in real-life situations, but it may be considerably useful in controlled environments with few users. The situation is two-dimensional, that is, the motion of the robot always takes place in the x−y plane, as shown in Figure 1.1. It is not a very limiting condition, as the robot is supposed to remain always on the floor in a flat, indoor environment. The main advantage is that the computation costs are significantly smaller than in a 3-D case. The robot is equipped with a laser sensor—or similar—which provides the data needed for the creation of the maps. This feature can be found in 1
1 DESCRIPTION OF THE PROBLEM most of the robots used. The solution of the problem consists on the calculation of the three variables for position ( ξ ) in a 2-D space referred to the global coordinate system, defined in equation (1.1). ξ≡ x y θ (1.1) A local coordinate system is also defined as depicted in Figure 1.1. It is attached to the robot, corresponding the x to the front direction. In both coordinate systems the z axis is going up from the floor, and the robot can only change its orientation by rotating around it an angle θ. Figure 1.1: Position of the robot referred to the global coordinate system. Figure extracted from [1] The next lines are a short explanation of the outline. In section 2the approach followed is described. Moreover, the different tools and algorithms are named and explained. Section 3discusses the integration of the method described in ROS environment. The experimental results are summed up in section 4, particularly focusing on the differences in the performance of the algorithms used, as well as on the influence of the parameters studied. Finally, sections 5and 6concern the final conclusions and the possible further work, respectively. 2
1 DESCRIPTION OF THE PROBLEM 1.1 State of the Art 1.1 State of the Art The problem of global localization has been largely treated through a number of different approaches, which are classifiable by the types of algorithms used. Several projects address it using place recognition based on visual data. Its main advantage is the high distinctiveness of the different positions in the environment, which helps solve the problem of perceptual aliasing specially in places such as long corridors. However, this technique entails diverse disadvantages, like high sensitivity to illumination changes and long time required for initial setup. Other methods employ particle filters like AMCL (Adaptive Monte Carlo Localization), which estimate the state of the robot while it is moving and sensing the environment. When solving the problem, the method starts with a uniform random distribution of particles—with each particle representing a possible state—since any point in the space is equally likely. As the robot moves, the information provided by the odometry is used to estimate the current state, which is correlated with the vision sensors to test the suitability of the prediction. Eventually, the particles should converge towards the actual position of the robot. The main downsides of this method are its slowness and the probability of large errors. Moreover, there are some algorithms based on evolutionary computation concepts. As an example, a non linear evolutionary filter known as the Evolutionary Localization Filter (ELF) is presented in [ 7 ]. This algorithm searches for the solution stochastically using an evolutionary search technique, which avoids derivatives. Therefore, it is much more robust in dealing with signals with high noise ratio. Relating to the matching process, there are many approaches different to the ones studied in this thesis. In [ 8 ] a radial sampling filter is presented. The experimental results show that it performs highly efficiently when matching two images, disregarding their rotation angle and translation. [ 9 ] introduces a point matching algorithm used for nonrigid shapes based on local neighborhood structures. It can successfully handle nonrigid deformation, noise in point locations, outliers, occlusions, and rotation. In addition, there are several project that consider more general hypotheses in order to adapt to changing environments. Some of the topics concerned are feature learning and prediction of systematic changes. Moreover, some other groups are working on robots for long-term autonomy, using semantic information for long-term recognition. 3
2 APPROACH 2.4 Matching methods Figure 2.5: Local map before and after applying opening Figure 2.6: Opening process not properly adjusted 2.4 Matching methods This project also aims at comparing two methods broadly used for global location, based on different algorithms. As presented in [12], the first of them is an areabased method called matchTemplate, while the second one is feature-based method named SURF. Area-based methods perform better when the images have not many prominent details. Their two principal limitations are that they only suit the registration of images which differ only by a translation and that their computational complexity is very high. They are often used because of their easy hardware implementation. On the other hand, feature-based methods allow to register images of completely different nature and can handle complex between-image distortions. Their main drawback is that the respective features might be hard to detect, specially when working with very simple images. As main characteristic of SURF, it is a specially fast method without any worsening of its performance. Moreover, it can handle scale and perspective changes between images, although it is not needed in this approach. 10
2 APPROACH 2.4 Matching methods 2.4.1 matchTemplate The process followed by matchTemplate consists on calculating the probability attached to each pixel of the global map to be the solution for the location of the local map, and then chooses the highest one. Therefore, the number of positions checked is N= (hglobal −hlocal + 1) ×(wglobal −wlocal + 1),(2.1) being hglobal ×wglobal the size of the static map and hlocal ×wlocal the size of the local map, with hthe number of rows and wthe number of columns. The number of positions to be checked will influence the time that will be needed. Accordingly, the bigger the global map is and the smaller the local map is, the more positions have to be checked and more time will be used. The main downside of matchTemplate is the fact that it can only handle images with a given orientation. Consequently, the rotation of the template has to be done separately, so that the matching process can be repeated for every rotated template. Now, the rotation process is discretized, and the number of positions checked is N=360 ° ∆α×(hglobal −hlocal + 1) ×(wglobal −wlocal + 1).(2.2) Then, the increment of the angle of rotation (∆ α ) becomes a crucial factor. The smaller it is, the higher success rate the matching will have, since more angles will be checked. However, its decreasing will make the number of possible positions bigger, so it will use more time. A compromise between these two factors has to be found. Moreover, matchTemplate can work with different correlation methods, and two of them will be compared: CCOEFF NORMED and SQDIFF NORMED. The correlation used by SQDIFF NORMED is R(x, y) = Px0,y0(T(x0, y0)−I(x+x0, y +y0))2 qPx0,y0(T(x0, y0)2·Px0,y0I(x+x0, y +y0))2 .(2.3) On the other hand, the correlation used by CCOEFF NORMED is 11
2 APPROACH 2.4 Matching methods R(x, y) = Px0,y0(T0(x0, y0)·I0(x+x0, y +y0))2 qPx0,y0(T0(x0, y0)2·Px0,y0I0(x+x0, y +y0))2 ,(2.4) where T0(x0, y0) = T(x0, y0)−1 w·h·X x00 ,y00 T(x00, y00) I0(x+x0, y +y0) = I(x+x0, y +y0)−1 w·h·X x00 ,y00 I(x+x00, y +y00). (2.5) An explanation of these correlations can be found in [13]. First, R is the result matrix that stores the probability of each pixel in the global map to be the location of the upper-left corner of the local map. T refers to the template (local map) and Ito image source (global map). SQDIFF matches the squared difference. Therefore, the smaller the result value stored in R is, the more probable is that pixel to be suitable for the matching, being 0 a perfect match. On the other hand, CCOEFF matches a template relative to its mean against the image relative to its mean. Consequently, it has a higher computational cost than SQDIFF, but its performance is usually better, except for some concrete applications. Unlike SQDIFF, the most probable pixel stored in R is the one with the highest value. Finally, both of the methods are normed, which usually provides results with higher success rates. 2.4.2 SURF SURF (Speeded-Up Robust Features) is an algorithm that detects interest points on images. Its main advantages are its computational speed and its robust performance. In [ 14 ] and [ 15 ], an explanation of the algorithm can be found. Once the features of the images are found, FLANN is used to match both images and RANSAC to find the rigid transformation between them. SURF is based on the Hessian matrix, H , which is a square matrix of second-order partial derivatives. When it is applied to a function f ( x, y ), the matrix is defined as in equation (2.6). 12
2 APPROACH 2.5 Calculating the position of the robot H(f(x, y)) = "∂2f ∂x2 ∂2f ∂x∂y ∂2f ∂x∂y ∂2f ∂y2#(2.6) Using the determinant of this matrix it is easier to discover if a point is a local maximum or minimum. In order to translate it to the work with images, the values of the function f ( x, y ) are replaced by the pixel intensities of the image I ( x, y ). Moreover, the second derivative of the image is achieved by its convolution with kernels for the Gaussian derivatives in x , y and combined xy direction Therefore, the new Hessian matrix His defined as in equation (2.7). H(p, σ) = Lxx(p, σ)Lxy(p, σ) Lxy(p, σ)Lyy(p, σ)(2.7) Where Lxx ( p, σ ) denotes the convolution of the second order Gaussian derivative ∂2g(σ) ∂x2 of the image at point p ( x, y ) and scale σ in the x direction, being g ( σ ) the Gaussian distribution function. It applies similarly for Lyy and Lxy. There is an important parameter called minHessian , which is a threshold that defines which minimum value is needed for a point to become a feature. Therefore, the larger this parameter is, the less points will be chosen as features. As mentioned before, FLANN-based matcher is used in order to match both images. FLANN (Fast Library for Approximate Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. A description of FLANN can be found in [16]. Finally, RANSAC (RANdom Sample And Consensus) is used to find the rotation and translation between two images processed as feature point clouds. RANSAC is broadly used for parameter estimation. Its main strength is that it can handle data affected by noise and corrupted by outliers—points which do not fit the model. It can deal with images that are more than 50 % of outlier contaminated. 2.5 Calculating the position of the robot The position returned by these two methods is the one of the first pixel of the template referred to the first pixel of the image source, starting in the upper-left corner and defining x and y axes as in Figure 2.7. Consequently, the position of the robot has to be calculated, defined as in equation (2.8). 13
2 APPROACH 2.5 Calculating the position of the robot −→ OR =Rx Ry(2.8) The easiest case to calculate the position of the robot is when the rotation angle is 0 ° and no cropping has been made, as shown in Figure 2.7. Because the position of the robot is assumed to be in the center (see Figure 2.1), it can be calculated as in equation (2.9). y x O P R Figure 2.7: Position of the robot in the matched local map −→ OR =−→ OP +−→ PR =Px Py+wlocal 2 hlocal 2,(2.9) where P is the position of the upper left corner of the local map with respect to the reference system of the global map image. However, if the cropping process explained before has taken place, the robot may not be located at the center of the cropped map, as the number of rows and columns may not be the same as each other. Therefore, the result would be as shown in Figure 2.8, and it can be calculated as in equation (2.10). −→ OR =−−→ OV +−→ V R =−→ OP +−→ PV +−→ V R =Px Py+−cleft −cup +wlocal 2 hlocal 2,(2.10) being cup and cleft the number of rows or columns cropped from the upper and the left side, respectively. Now, if the size of the cropped map is noticed, defined as in equation (2.11) , equation (2.10) can be rewritten as equation (2.12). 14
2 APPROACH 2.5 Calculating the position of the robot y x O PR V Figure 2.8: Cropped local map, original in dashed line wcropped =wlocal −cright −cleft hcropped =hlocal −cup −cdown (2.11) −→ OR =Px Py+−cleft −cup +1 2(wcropped +cright +cleft) 1 2(hcropped +cup +cdown),(2.12) being cdown and cright the number of rows or columns cropped from the down and the right side, respectively. Therefore, −→ OR =Px Py+1 2(wcropped +cright −cleft) 1 2(hcropped −cup +cdown).(2.13) Equivalently, if the variation of the dimensions of the cropped map is used, with ∆w=cright −cleft ∆h=cdown −cup,(2.14) equation (2.13) can be rewritten as −→ OR =Px Py+1 2(wcropped + ∆w) 1 2(hcropped + ∆h).(2.15) 15
2 APPROACH 2.5 Calculating the position of the robot Finally, if the cropping process has been made and the local map did not have the same orientation as the global map, the number of rows and columns cropped from each side will also rotate. Therefore, the angle of rotation has to be taken into account as shown in equation (2.16). −→ OR =Px Py+1 2(w0 cropped + (∆w)0) 1 2(h0 cropped + (∆h)0),(2.16) where w0 cropped =wcropped · | cos α|+hcropped · | sin α| h0 cropped =hcropped · | cos α|+wcropped · | sin α| (∆w)0= (cright −cleft) cos α+ (cdown −cup) sin α (∆h)0= (cdown −cup) sin α+ (cleft −cright) sin α. (2.17) Therefore, for the general case, the equation (2.18) can be applied. Rx Ry= Px+1 2[wcropped · | cos α|+hcropped · | sin α|+ (cright −cleft) cos α+ +(cdown −cup) sin α] Py+1 2hcropped · | cos α|+wcropped · | sin α|+ (cdown −cup) sin α+ +(cleft −cright] sin α) (2.18) 16
3 Integration with ROS The next step in this project is to allow the usage of the methods mentioned before in real-time simulation, which can be achieved using ROS. For doing so, a ROS node needs to be created, in which a subscriber gets the information sent by the sensor, and a publisher provides the calculated position once the whole process has succeeded. Moreover, it is worth mentioning that the actionlib ROS package is used instead of services. Services are broadly used to send a request to a node to perform some task, and also receive a reply to the request. However, actionlib becomes useful when the service takes a long time to execute, since the user might want the ability to cancel the request during execution or get periodic feedback about how the request is progressing. Consequently, as the global location may be time consuming, it should have the capacity to be preempted if necessary. Apart from the node, a client attached to it is used to initialize the global location process when needed. When the location process is used in real-time simulation, the different parts of ROS are connected as shown in Figure 3.1. Figure 3.1: ROS linking Gazebo publishes the laser data provided by the sensor in the simulation to the amcl node, along with the transforms of the physical model of the robot (as in Figure A.2), so that the position can be estimated in normal situations. However, when the robot becomes lost, the node created ( global loc ) is called by a client ( test global loc ) and the recovery process starts. The node receives the laser data and creates the local map in order to be matched with the global map. Once it is finished, the calculated position is published on the topic initialpose, to initialize the particle filter. The maps used by ROS need to be stored in a pair of files: an image file and a YAML file. The image file encodes the occupancy data, usually in gray-scale, by giving darker colors to the pixels with higher probability to be occupied. The 17
3 INTEGRATION WITH ROS 3.1 ROS node thresholds in the YAML file are used to divide the three categories—free, occupied or unknown. The YAML file includes the map meta-data, namely the name of the map, its resolution, its origin and the thresholds. 3.1 ROS node In the ROS node created, the local map is conceived as an occupancy grid map, which consists on a number of evenly divided cells, having each of them the probability of the presence of an obstacle attached, which are stored as an array. The type of message used by occupancy grid belongs to navigation messages, a family used to interact with the navigation stack. Occupancy grid consists on three fields: header,info and data. The header contains information used to communicate timestamped data in a particular coordinate frame. The field info carries the size of the map ( width and height ), its resolution and its origin . Finally, data contains the occupancy probabilities for each pixel in row-major order starting with (0,0), being in the range [0,100]. Furthermore, the package occupancy grid utils is used to deal with objects created as occupancy grids. The local map has the same resolution as the global map and its origin is in the center, as shown in Figure 2.1. This information is taken from the YAML file attached to the image of the map, and stored in the corresponding fields mentioned above. Both the width and length are double of the maximum range of the sensor, so that any obstacle that may be detected can be represented on the map. The node is subscribed to the measurements of the sensor, as stated before. The data provided consists on the discretization of the field of vision, so that each angle αi has a distance attached ri , as shown in Figure 3.2. The angles are defined as in the figure. Also, the number of measurements will be N=αmax −αmin ∆α.(3.1) With the purpose of transforming this data into their positions referred to the static coordinate system attached to the local map, the equation (3.2) is used. xi yi=1 2·wlocal −ri·sin αi 1 2·hlocal +ri·cos αi(3.2) 18
3 INTEGRATION WITH ROS 3.1 ROS node yloc xloc xl yl ri αi Pi Figure 3.2: Laser measurements into the coordinate system attached to the local map Afterwards, the positions of the obstacles, that are stored in a matrix with N elements, being N=hlocal ×wlocal = 4 ·maxrange,(3.3) need to be saved in an array of the same size, which can be used by the occupancygrid map. This array is built for growing row number, so that the index of the array, k, is defined as k=j×wlocal +i, (3.4) where iis the column number and j, the row number. Then, every index that contains an occupied pixel is given a value of OCCUPIED (100), being the rest FREE (0). Once this process is completed, an OpenCV Mat image is created painting in black those pixels that correspond to an occupied position, leaving the rest white. The class Mat is broadly used in OpenCV to deal with images. Every image is represented as a matrix with a value associated to each pixel, which is often a vector with three elements—when RGB color scale is used—called layers. The values of these layers determine the color of the pixel. 19
4 RESULTS 4.1 Local maps extracted from the global map 4.1.4 Conclusions The conclusions concerning success rate that can be extracted from these results are that matchTemplate performs much better than SURF, without a big difference between both correlations. However, when it comes to time needed, matchTemplate is significantly slower than SURF. Concerning the probability of success in the result given by matchTemplate, thresholds could be defined for CCOEFF NORMED and SQDIFF NORMED. That way, a result with a higher score than 0.70 for CCOEFF NORMED or smaller than 0.60 for SQDIFF NORMED could be considered successful with very low probability of false positives. Solutions with worse scores may also be successful, so there would be a higher number of false negatives. However, false negatives are preferred over false positives. With regard to the angle increment in matchTemplate, it has been observed that larger ∆αentails shorter times but also worse performance. Relating to the size of the local map (not taking outer white area into account), it was proved that matchTemplate is a little faster for bigger maps, whereas SURF remains unchanged. The explanation of this dependency can be found when plotting the number of positions that have to be checked versus the size of the local map, as in Figure 4.8. It shows that for the range of sizes normally used in these tests (both length and width between 100 and 300 pixels), the dependency can be assumed to be linear with a coefficient of R2≈0.93. 0 10 20 30 40 0 0.5 1 1.5 2 Size of the cropped local map (pixels2·103) Number of positions to be checked (·106) Figure 4.8: Number of positions checked in matchTemplate for different local map sizes 26
4 RESULTS 4.2 Simulation 4.2 Simulation The second part of the tests were run on a series of 23 local maps created in simulation and processed as explained in previous sections. The positions used for the experiments represent the different situations that the robot may face when solving its global localization, such as diversity of angles of rotation and lack of distinctive information. In order to consider the result of the calculation as successful, the error in x and y directions had to be both smaller than 0.2 m, whereas the error in θ lesser than 5 ° . With the purpose of studying the effect of the different parameters, they have been changed individually, remaining the rest as in the basic case (field of vision of 180 ° , range of 20 m and ∆α= 5 ° ). As an example, Figures 4.10 and 4.11 shows the local map (before and after preprocessing) created in the situation of Figure 4.9. Figure 4.9: Robot calculating its position in real-time simulation Figure 4.10: Local map created in simulation before and after cropping 27
4 RESULTS 4.2 Simulation Figure 4.11: Local map created in simulation before and after opening 4.2.1 Performance by method First, the results provided by each method were compared for a standard case: field of vision of 180 ° , range of 20 m and ∆ α = 5 ° . Their success rate and the average time used is shown in Figure 4.12. 0 20 40 60 80 100 Success (%) 0 10 20 30 40 50 60 Time (s) Figure 4.12: Success rate and average time used by each method matchTemplate has a low success rate, particularly SQDIFF NORMED, and they both perform much worse than in the previous tests. SURF did not succeed for any position. Relating to the time needed, matchTemplate has a similar average to the first series of experiments, around 45 seconds. On the other hand, SURF averages 28
4 RESULTS 4.2 Simulation less than 1 second. The reason is that not enough feature points were found in most of the cases, so the matching process did not even start. 4.2.2 Influence of the characteristics of the laser sensor Field of vision In relation to the field of vision of the sensor, two more values were tested (60 ° and 270 ° ) in order to study its influence on the results. In Figure 4.13 and 4.14 the success rate and the average time, respectively, are shown. 0 20 40 60 80 100 Field of vision ( ° ) Success (%) 60 180 270 Figure 4.13: Success rate for different fields of vision Concerning the success rate, matchTemplate improves its performance for wider fields of vision, as it was expected, being the rate of CCOEFF NORMED higher than the one of SQDIFF NORMED. SURF did not succeed for any position. When it comes to the time used, little difference can be noticed. However, the wider the field of vision is, the larger the local map gets. Therefore, the time slightly decreases, as explained before. The average time of SURF is higher for 270 ° because most of the cases had enough feature points, so the matching process was done. However, its average is around 3 seconds, which is much faster than matchTemplate. Range Relating to the range of the sensor, a comparison with a lower value was made to see how the results change. They are shown in Figure 4.15. The success rate for CCOEFF NORMED decreases for 4 m, as it was expected. 29
4 RESULTS 4.2 Simulation 0 10 20 30 40 50 60 Field of vision ( ° ) Time (s) 60 180 270 Figure 4.14: Average time used by different fields of vision However, SQDIFF NORMED remains with the same percentage. The average time used by matchTemplate increases for a range of 4 m. It was expected, as shorter ranges mean smaller local maps. On the other hand, SURF cannot find enough features, what entails that no successful positioning is achieved. 4.2.3 Influence of the angle increment in matchTemplate The success rate of each method and its average time are compared for two values of ∆αin Figure 4.16 As it was expected, the success rates of matchTemplate get worse for larger ∆ α , but the average time used is smaller. Precisely, the time for ∆ α = 15 ° is around three times shorter than for ∆ α = 5 ° . Of course, the worsening rate depends on the number of positions that are rotated an angle not multiple of 15. The performance of SURF is obviously not influenced by the change of ∆α. 4.2.4 Conclusions The results of the test in simulation reveal that the suitability of this method depends largely on the purpose and the sensor used. If a commercial sensor were 30
4 RESULTS 4.2 Simulation 0 20 40 60 80 100 Range (m) Success (%) 4 20 0 10 20 30 40 50 60 Range (m) Time (s) 4 20 Figure 4.15: Success rate and average time for different ranges used, such as Kinect, the characteristics would be similar to 60 ° and 4 m. With these parameters, the results provided may not be positive enough. However, if the sensor could provide 270 ° and 20 m, a success rate around 60% could be achieved. Moreover, ∆ α could be adjusted to find an optimum between success rate and time used, which would vary for different applications. The performance of SURF is extremely poor, which should be further investigated. If its low average time were required, some changes could be implemented on the creation of the local maps to try to increase its success rate. For instance, Figure 4.17 shows an unsuccessful matching process, in which many feature points are found but not properly matched. Concerning the probability of success in the result given by matchTemplate, thresholds could not be found in order to distinguish reliably between successful and unsuccessful solutions. This is a problematic fact, that entails further checking of the results before considering them proper. As an example, the global localization process with matchTemplate using CCOEFF NORMED for the positions shown in Figure 4.18. For the first position, the result was unsuccessful, with a score of 0.4888. On the other hand, the method succeeded for the second position, with a score of 0.0943. 31
4 RESULTS 4.2 Simulation 0 20 40 60 80 100 ∆α( ° ) Success (%) 5 15 0 10 20 30 40 50 60 ∆α( ° ) Time (s) 5 15 Figure 4.16: Success rate and average time for by different angle increments Figure 4.17: Unsuccessful matching by SURF Figure 4.18: Two different situations simulated in gazebo 32
5 Conclusions Two methods have been compared—matchTemplate, which is area-based, and SURF, feature-based. Moreover, two different correlation of matchTemplate have been tested: CCOEFF NORMED and SQDIFF NORMED. Given the results obtained, the performance of matchTemplate has a medium success rate, but may be too slow for some real applications. On the other hand, SURF has not given good results in the tests performed, since more feature points are needed when using the raw local map images. Regarding the failure of SURF, it is mainly due to its inability to find enough feature points and match them properly. A reason for it can be that the features of these maps at a local level are not characteristic enough. It is worth mentioning that it may not be the most suitable method for the images treated in this thesis, as they also lack of small obstacles, which are easier to match. Moreover, its main advantages—scale and perspective invariance—are not needed for this purpose. However, feature-based methods count on positive characteristics, such as their fast performances. Therefore, in order to take advantage of them, some changes in the method and in the image processing could be implemented to try to raise its success rate. Moreover, other descriptors different to SURF could be implemented with the aim of finding a more suitable one. In relation to the different correlations of matchTemplate studied, the average time needed by both of them are very similar. Nonetheless, when it comes to success rates, CCOEFF NORMED performs usually better than SQDIFF NORMED, sometimes significantly. Concerning the characteristics of the laser sensor, which is crucial in this approach, the results are always better for wider fields of vision and longer ranges, as expected. When working with matchTemplate, ∆ α becomes a very important factor, which, depending on the application aimed, can be adjusted for a higher success rate or for shorter execution times. Relating to the probability score given by matchTemplate to every location in the global map, a threshold cannot be found to distinguish between successful and unsuccessful matches. Therefore, the likelihood of errors when estimating the reliability of the solution is high enough to consider further checking methods. Finally, it has also been observed in the realization of this project that a dependency manager saves time during the configuration and implementation phases. 33
6 Future Work In applications using narrow fields of vision, the local maps created with the current method may not contain enough information. Therefore, an interesting process for creating it would be a 360 ° scan, that would provide further information, leading to better performances. Nonetheless, if the field of vision were wide enough, an easy improvement would be to locate the robot twice for every position—once with the initial orientation, and a second one after having turned 180 ° . Afterwards, if both processes returned the same position (with a 180 ° difference, considering an error margin), the probability of success would be significantly higher. Moreover, a problem observed in the creation of the local maps that included long corridors was the large distance between points representing the same obstacles. A possible solution would be to apply a stronger opening process, but that might lead to the joining of near corners. Consequently, a cropping algorithm that considered the density of occupied positions could be implemented as further development. Another possible approach would be the usage of the method analyzed in this project when the solution can be considered successful with very high reliability— a suitable method to assess this reliability will be necessary. For the rest of the cases, AMCL in global localization mode could be used. This way, the problem concerning the errors in the localization could be avoided. It would also be useful the incorporation of the probability given by matchTemplate to each position of the global map to be the actual location of the robot. Therefore, the covariance matrix attached to every possible solution would depend on that score, what would be a more reliable result than only returning the highest-rated position, which could be used to initialize a particle filter. As a final step, once the algorithm has been proved to perform properly, the new improvements can be added to the already released code. 34
A Model of the Robot The robot used for the simulations was the Pioneer 3-DX, which is vastly used for research purposes due to its versatility, reliability and durability. Figure A.1: Robot Pioneer 3-DX, used for the simulations Moreover, the transformation tree of the robot is shown in Figure A.2. This information allows amcl to find the right relationships between the laser measurements provided by the sensor and the rest of the parts of the robot, so that it can be located properly in the environment. Figure A.2: Scheme of the physical model of the robot 35