• No results found

A framework for traffic management and collision avoidance in underground mines

N/A
N/A
Protected

Academic year: 2021

Share "A framework for traffic management and collision avoidance in underground mines"

Copied!
48
0
0

Loading.... (view fulltext now)

Full text

(1)

UPTEC F14053

Examensarbete 30 hp

5 December 2014

A framework for traffic management

and collision avoidance in underground

mines

(2)

Teknisk- naturvetenskaplig fakultet UTH-enheten Besöksadress: Ångströmlaboratoriet Lägerhyddsvägen 1 Hus 4, Plan 0 Postadress: Box 536 751 21 Uppsala Telefon: 018 – 471 30 03 Telefax: 018 – 471 30 00 Hemsida: http://www.teknat.uu.se/student

Abstract

A framework for traffic management and collision

avoidance in underground mines

Mikaela Åhlén

Mining is an ancient occupation and the purpose is to access and extract minerals in the ground, which after being brought to the surface can be processed and sold at a profit. A mine, especially when active, is a dangerous place; mine collapse and other accidents have over the years claimed many lives. To improve the safety of personnel and equipment, there is an increased market for automating the vehicles operating in the mines. With no drivers in the vehicles, it is necessary to make sure the vehicles get to their goals without colliding with each other or perhaps with vulnerable personnel working in the mine. This can be done by performing traffic management. The traffic management is also important from a scheduling point of view; by planning where and when a vehicle should go to a certain part of the mine, the material flow can be optimized and so also the profit.

This project has been carried out with the purpose of creating a framework to be used for simulating autonomous vehicles in underground mines. The framework is dynamic and supports e.g. fast map generation, and has an anti-collision algorithm to prevent collisions when the simulated vehicles all try to go to different destinations in the map. With a total runtime of 100 hours using this framework, 2 total shutdowns have occurred (a state where all vehicles are stopped as a result from a pair of vehicles getting too close to each other) and 1 dead lock (a case where no collision has occurred, yet none of the vehicles could continue to their goal). Hence, due to the rarity of these, the conclusion that the overall concept of the collision

avoidance algorithm seems to work has been made.

ISSN: 1401-5757, UPTEC F14053 Examinator: Tomas Nyberg Ämnesgranskare: Mikael Sternad Handledare: Krister Landernäs

(3)

Contents

1 Introduction . . . 2 1.1 Purpose . . . 2 1.2 Background . . . 3 2 Challenges . . . 5 3 Theory . . . 7 3.1 Graph theory . . . 7 3.2 Pathfinding . . . 7 3.3 Dijkstra’s algorithm . . . 8 3.4 A* algorithm . . . 9

3.5 Breadth-first search and Depth-first search . . . 12

3.6 Iterative-deepening depth-first search . . . 14

3.7 IDA* algorithm . . . 14

4 Model . . . 16

4.1 Model construction . . . 16

4.2 Assumptions and limitations . . . 16

5 Implementation . . . 17

5.1 Map representation . . . 17

5.2 The main structure of the program . . . 19

5.3 Pathfinding . . . 21

5.4 Collision avoidance . . . 22

5.5 Dead ends – switching priorities . . . 29

5.6 Dead ends shorter than one safety distance . . . 30

6 Results . . . 31 7 Discussion . . . 32 7.1 Pathfinding algorithm . . . 32 7.2 Modified A* . . . 33 7.3 Future work . . . 33 8 Conclusions . . . 35 Appendices 37 A Examples of algorithms 38 A.1 The pathfinding algorithm (modified A*) . . . 38

A.2 Collision avoidance . . . 41

(4)

1

Introduction

Underground mines have a special infrastructure consisting of a network of tunnels which connect with the surface through shafts, adits or declines. Due to the time and cost of blasting and drilling in underground mines, the tunnels are most often only made wide enough for one vehicle to be able to pass through, see Figure 1. Thus, there is a problem when two vehicles meet at places where only one vehicle can pass, since one of the vehicles then has to reverse to the closest meeting point, which can be far away. To avoid situations like these, and in worst case collisions, many workers in today’s mines use radio communication to report their current position and heading in the most critical parts of the mine. This is however not by far an ideal solution. Meetings in undesired places do still occur, causing vehicles to reverse through narrow passages or in extreme cases even to collide. Hence, it is now desired to be able to track the vehicles in order to be able to perform traffic management – avoiding collisions, queuing and meetings in narrow passages.

Figure 1: A load-haul-dump vehicle passing through a narrow tunnel in an underground mine.1

1.1 Purpose

The purpose of this work is to create a framework for traffic management in underground mines. The framework is to visualize simulations of vehicles operating in the mine, show-ing their current positions and goals. All the vehicles are to traverse toward their respec-tive goal without colliding with each other. Hence, a collision avoidance algorithm is to be created along with the framework.

(5)

1.2 Background

1.2.1 Mining

Mining is an ancient occupation and the purpose is to access and extract minerals in the ground, which after being brought to the surface can be processed and sold at a profit. A mine has a special infrastructure consisting of a network of tunnels. This network enables the transportation of the minerals from inside the mine to the surface where the miner-als can be processed. Figure 2 shows an example of how this infrastructure may look. The spiral-formed road going downwards is a ramp, which is the road through which vehicles and other equipment get to and from the surface. This ramp leads to different levels of the mine, marked with white ovals in the figure. These levels consist of various tunnels leading into an ore body, which is where the extraction of the valuable minerals takes place.

Figure 2: An example of the structure of a mine. The tunnels lead into an ore body to the left, which is where the extraction of the valuable minerals takes place.2

To access and extract the minerals, drilling, charging and blasting is performed. In the process of extracting the ore and bringing it to the surface, heavy machinery such as bulldozers, drilling machines, trucks, load-haul-dump vehicles, etc. are used. These ma-chines vary in size and maneuvering capabilities, which means that the different types of vehicles are usually given different priorities, where drilling machines and ascending or loaded vehicles typically have high priority. This means that when these highly priori-tized vehicles meet other vehicles, they can generally continue traversing while the other vehicles will have to make way for them.

(6)

1.2.2 Scheduling

In mining, scheduling is performed to optimize the material flow. An estimate of the time required to perform different activities such as drilling, blasting, loading, etc. is found, and it is often pessimistic to make sure everything gets done in the specified time frame to avoid rescheduling. The transportation time is also necessary to estimate e.g. the time it will take for a drilling machine to reach the point of interest. Due to the special infras-tructure of a mine; in many cases with single-lane roads, long tunnels and only one path from a starting point to a certain goal; traffic congestion frequently occurs. It is thus diffi-cult to estimate the time it will take for all necessary equipment to get to a point where an activity (e.g. blasting or drilling) is to take place. Consequently, this obstructs the adop-tion of scheduling the different activities in the mine. Thus, it is now desired to keep track of the positions of all vehicles to be able to plan the different vehicles’ routes and know when a vehicle will have to alter its path or slow down. This could, as explained, be used in the scheduling as an improved estimate of the time for a vehicle to get to a certain point in the mine, but also to avoid unnecessary queuing and preventing vehicles from being forced to reverse longer distances, and in worst case collisions.

1.2.3 Autonomous vehicles

A mine, especially when active, is a dangerous place; mine collapse and other accidents have over the years claimed many lives. To improve the safety of personnel and equip-ment, and also to increase the productivity, there is an increased market of automating the vehicles operating in the mines. In mines using autonomous vehicles today, the cor-responding area of operations are closed for others in order to maintain the safety. How-ever, it is now desired to integrate the autonomous vehicles onto the same roads as the other, manually operated vehicles. Especially here, with no drivers in the vehicles, it is necessary to on a higher level perform traffic management to make sure the vehicles reach their goals without colliding with each other or perhaps with vulnerable personnel working in the mine.

(7)

2

Challenges

There are some challenges when performing traffic management for autonomous vehi-cles in an underground mine. The following list states some of the challenges in this project that had to be solved in order to simulate vehicles going to their goals without colliding with each other:

• How to find the shortest path from a vehicle’s current position to its next goal • How to detect whether any pair of vehicles will collide with each other

• If a possible collision between two vehicles is detected, which one of the two vehi-cles can continue traversing and should the other vehicle alter its path completely or is it sufficient if it halts to a stop?

• If a vehicle has to alter its path to avoid a possible collision, how to find where it should go in order to move away from the other vehicle while still going toward its goal if possible

• How to ensure that a vehicle that has altered its path will not cause a new collision with yet another vehicle.

In a mine, different vehicles may have different priorities. Thus, one attempt in imple-menting a collision avoidance algorithm could be to let the higher prioritized vehicles traverse toward their goals, while the lower prioritized vehicles stay out of the other vehicles’ way if necessary, until they also can continue to their goals without causing a collision. However, this is not sufficient in order to avoid collisions. The algorithm has to be able to consider more than two vehicles at a time to avoid collisions and sometimes, vehicles with a high priority have to stay out of the way of lower prioritized vehicles. Consider the case shown in the leftmost image in Figure 3. The numbers on the vehicles represent their priority, where 1 is the highest, 2 is the second highest, etc., and the ar-rows represent their heading. One can see that vehicle 1 and 4 are heading toward each other, and so do vehicle 2 and 3 on the other road. If the algorithm were only to consider two vehicles at a time, it would compare the priorities of vehicle 1 with vehicle 4, and vehicle 2 with vehicle 3. It would find that vehicle 1 had a higher priority than vehicle 4, and that vehicle 2 had higher than 3. Hence, it would let vehicle 4 and 3 reverse to let vehicle 1 and 2 continue toward their goals. However, this introduces a new problem, see the rightmost image in Figure 3. If vehicle 4 and 3 were to continue here, they would collide with each other when reaching the intersection. Hence, to let vehicle 1 continue toward its goal since it has the highest priority, somehow the algorithm should see that vehicle 4 has to continue away from vehicle 1, and therefore let vehicle 3 stop to avoid the collision with vehicle 4, even though vehicle 3 has a higher priority than vehicle 4. Also, since vehicle 3 stopped, vehicle 2 has to stop to avoid colliding into vehicle 3 even though it is a lower prioritized vehicle.

Another problem occurs when there are dead ends in the mine. Consider the case where a vehicle with a high priority enters a tunnel in order to get to its goal. This tunnel leads to a dead end, where another vehicle with lower priority is located. If the vehicle with the higher priority were to continue toward its goal, it would collide into the other vehicle at the end of the tunnel. Thus, the algorithm has to see that the higher prioritized vehicle

(8)

Figure 3: Two images showing a challenge that has to be considered and solved when creating a collision avoidance algorithm.

has to wait outside for the other vehicle to exit the tunnel, to then enter the dead end tunnel when it is empty.

(9)

3

Theory

3.1 Graph theory

A graph is a mathematical structure used to model how different states relate to one an-other. These states are modelled using so called nodes (sometimes referred to as vertices) where some of these nodes are linked together, representing possible transitions between these nodes. These transitions are represented using so called edges, (or simply links), see the graph shown in Figure 4.

nodes

edges

Figure 4: A directed graph with 6 nodes representing different states. The connections between the nodes are called edges, and they represent possible transitions from one state to another.

In a graph, the edges often have a direction, where the direction is represented using an arrow. In this particular graph, there is sometimes only one arrow between two nodes. This means that it is only possible to transition from one of these nodes to the other via that edge in the direction of which the arrow points. When there are two arrows between a pair of nodes however, it is possible to transition between these two in either direction. Also, in some graphs, the edges have cost values. If the cost to transition along an edge in a graph is always the same, independent of the edge, the graph is non-weighted; if the costs vary depending on edge, the graph is weighted.

3.2 Pathfinding

Pathfinding is the process of finding the route with the lowest cost, e.g. the shortest route, between two points in a graph. Dijkstra’s algorithm was an early example of an algorithm solving the pathfinding problem and ever since, an increasing amount of other algorithms have been developed. The one of these other algorithms which is probably the most well-known is the A* algorithm. Many other pathfinding algorithms are based upon A* and two examples are the IDA* and D* algorithms that use the advantages of A* but these algorithms are slightly modified, in order to (hopefully) improve the memory usage and execution time.

(10)

3.3 Dijkstra’s algorithm

Dijkstra’s algorithm is an algorithm solving the shortest path problem for a graph with non-negative edge costs. It can be used to solve the single-source shortest path problem, which means that the shortest path from one specified node to all other nodes in the graph can be found. However, it can also be used when only one goal is present. Then the algorithm can run in the same manner as in the single-source shortest path problem, to then terminate earlier when the shortest path to this one goal has been found.

The algorithm uses two empty sets to store information about the nodes found so far in the attempt of finding the goal node – the frontier and the visited set. In the first step, the start node S is added to the frontier. This node is then expanded, which means that the node is moved to the visited set and all its neighbors are added to the frontier. Then, in the next iteration, the one node in the frontier with the least cumulative path length from the start node will be expanded, i.e. that node will be moved to the visited set and all its neighbors which are not yet visited will in turn be added to the frontier. This is then done iteratively, expanding the nodes in the frontier with the least cumulative path length from the start node, until the goal node is visited. Then, one has the shortest path from the start node to the goal node, given that there exists such a path.

Since Dijkstra’s algorithm chooses the node in the frontier with the shortest distance found so far to be visited first, the algorithm will slowly move from node to node in a circle-like behaviour until it has found the shortest path to the goal node. This is the reason why the algorithm can preferably be used when solving the single-source shortest path problem, i.e. when it is desired to find the shortest path from one node to several goal nodes at the same time.

However, even though Dijkstra’s algorithm is an adequate algorithm when solving the single-source shortest path problem, it is not optimal when only one goal is present. For example, the A* search algorithm is an alternative that is also guaranteed to find the optimal path (if such a path exists) but most often with a considerably lower execution time. Consider the case in Figure 5 where one wants to find the shortest path from the start node S in the bottom left corner to the goal node G in the upper right part of the figure. The nodes in the graph form an 8-connected grid and there is an obstacle between the start node and the goal node, which means that a path around the object has to be found. In this example one can see how the Dijkstra’s algorithm expands all nodes that are within a circle with centre in the start node until the goal node is reached, while the A* search algorithm expands considerably fewer nodes. This means that even though both algorithms are guaranteed to find the optimal solution (if such exists), the A* search algorithm is often more preferable than the Dijkstra’s when solving the pathfinding prob-lem for a single goal. [1]

(11)

Figure 5: An example showing the difference between the Dijkstra’s algorithm (the left-most image) and A* (the rightleft-most image). One wants to find the shortest path between the start node S and the goal node G, between which there is an obstacle (the hatched boxes). One can see that both algorithms find a shortest path from the start node to the goal (the path marked as a line connecting the start and the goal), but A* has to expand considerable fewer nodes.

3.4 A* algorithm

The A* search algorithm is a best-first search algorithm; it explores the most promising nodes first to in the subsequent steps be able to dismiss others that cannot be as good as the ones found so far. To do so, a heuristic evaluation function f(n) is used, where n de-notes the current node in the search of finding the optimal path to the goal. f(n) depends on g(n) and h(n) as follows: f(n)=g(n)+h(n), where

f(n) – [estimated distance from start node S to goal node G via node n] g(n) – [length of shortest path from S to n found so far]

h(n) – [heuristic: estimated distance from node n to goal node G].

g(n) is clearly deterministic but h(n) is an estimated value of the distance left to the goal node G from node n and it is important that h(n) is admissible, i.e. the true distance must be equal to or greater than our heuristic. The reason for using a heuristic h(n) is to de-crease the number of explored possible moves. The greater heuristic, the fewer possible moves would be explored, resulting in a lower execution time. Hence, it is preferable to have a heuristic with a high value, but one should not choose the heuristics arbitrarily. A high value for the heuristic has the positive effect that less possible paths are explored, but the heuristic cannot be greater than the actual true distance from node n to goal node G, since then the algorithm would not be guaranteed to give the optimal solution no more – the heuristic would not be admissible any longer. Thus, we need a heuristic that is equal to or less than the true distance left to the goal node, i.e. h(n) ≤ h*(n), where h*(n) is the true shortest distance from node n to the goal. [2]

(12)

3.4.1 How to choose the heuristic value h

A sliding tile puzzle is a puzzle where several tiles are placed within a frame in scram-bled order. One of the tiles is missing, making it possible to slide the neighboring tiles into that empty space. By doing so, one can change the order of the tiles. The objective of this puzzle is to slide the tiles horizontally and vertically to put them in the right order, see Figure 6 where the left puzzle is an example of how it may look when beginning the game and the right puzzle shows how it should look when finished.

1 2 3

4 5 6

7 8

8 1 6

3 4

7

5 2

1 2 3

4 5 6

7 8

8 1 6

3 4

7

5 2

Figure 6: A sliding tile puzzle. The left is a scrambled puzzle ready to be solved and the right puzzle shows how it should look when finished, all numbers arranged from 1-8 beginning with the top left corner.

Consider the puzzle shown in Figure 6 once again. To solve this puzzle with the least possible number of moves, one could use the A* algorithm. To use A* to solve this puz-zle, we need a guess of how many moves we need to do in order to solve the puzzle – we need to find a heuristic h(n).

One way of achieving a heuristic to this problem is to count the number of tiles that are currently not in the right position. By comparing the two different puzzles in the fig-ure, one can see that none of the tiles are in the right place. This means that one heuristic could be the total number of tiles, i.e. h=8.

Another way of achieving a heuristic for this problem is to count the least number of moves each tile has to do in order to get to the right position. For example, tile number 1 has to move one step horizontally to the left, tile number 2 has to do two steps upwards, etc. Adding all these numbers one gets 1+2+3+1+2+1+2+3=15. So, the heuristic 15 is less than or equal to the actual least number of moves necessary to solve the puzzle. Since this value is greater than 8, this heuristic is better than the other – it is more informed, resulting in fewer expanded nodes.

To summarize, a high value of the heuristic makes the algorithm more efficient, but it cannot be greater than the true least number of moves necessary to solve the puzzle. However one needs to remember that there is a trade-off of how good the estimated heuristic should be. Of course one could spend time on finding a heuristic that is equal to the actual number of moves, but then one would not gain anything from the algorithm since the solution would already be retrieved! So one should try to find a heuristic that is as great as possible (however without compromising the admissibility) without having to do heavy computations to retrieve it.

(13)

3.4.2 The algorithm

The steps of the A* search algorithm are very similar to the ones of the Dijkstra’s algo-rithm. The main difference is the usage of a heuristic in the A* algorithm; instead of expanding the node in the frontier with the least cumulative path length as done in Dijk-stra’s, the node in the frontier with the lowest evaluation function value f is chosen, see Figure 7.

Start

Add the start node S to the frontier Create two empty sets; the

frontier and the visited set

Take the one node in the frontier that has the lowest f value and

move it to the visited set

Has the goal node G been found

so far?

If vehicle v continues on its path towards its goal, will

it collide with another vehicle?

No

Yes

Expand this new node, i.e. investigate which neighbors it has

and add the new nodes to the frontier along with their f values respectively. If an old node shows up again, update the f value if it is

smaller than before.

Is the f value of the goal node G lower than the f value of all

nodes in the frontier?

Yes

No

Backtrack in the tree from the goal node G to the start node

S to get the shortest path

Finish

(14)

3.5 Breadth-first search and Depth-first search

Breadth-first search (BFS) and Depth-first search (DFS) are two uninformed graph search algorithms. Both algorithms begin at the root node and expand it, finding all its neigh-bors, to then proceed to expand one of the other found but not yet expanded nodes, and so on. The uninformedness means that the algorithms do not in advance know in which direction the goal node is until it is found. Thus, they will both systematically search through all nodes, only having information about the nodes found so far, until the goal node is reached. A B C D E F G

Figure 8: A directed graph where the shortest path from node A to node G is desired. Consider the graph shown in Figure 8. Here, A is the root node and G is the goal node. What differs BFS from DFS is the order in which the nodes found so far are expanded. BFS will order the frontier, the set of nodes found so far but not yet expanded, as: first in, first out. Considering the graph as a state space consisting of layers at different transi-tions away from the origin, ordering the frontier as first in, first out means that all nodes in one layer are expanded before continuing to the next layer of nodes, see Figure 9. This means that the algorithm is guaranteed to find the goal node, and thus the shortest path, as long as the goal node is accessible by finite number of transitions from the origin and if the number of transitions from each node in the graph is finite. [3]

DFS however, orders the frontier such that the first node in is the last one out, in contrast to BFS. This means that if the last expanded node has at least one child, this child is ex-panded before progressing to any other of its children or another node in the same layer. So it will expand the nodes through all layers until it cannot proceed any further, at which point it will backtrack to search for the goal by choosing other routes. However, this can cause problems if the graph contains directed loops as in Figure 8. With such a loop, the algorithm may get trapped, as seen in Figure 10, where the nodes will be expanded in the sequence A-B-D-A-B-D and so on repeatedly. [4]

This means that if the graph contains directed loops, the DFS is not guaranteed to find the goal. However, there is an important advantage using DFS over BFS – memory. While BFS has to store information of all nodes found so far, DFS only has to store information about the current path it is evaluating. This means that given that b is the breadth of each node (i.e. the number of transitions from one node to others) and d is the depth of the goal (i.e. the least number of transitions required to get to the goal from the root), the frontier of DFS is much less than the one of BFS (O(b ∗ d) rather than O(bd)). Hence, when the search spaces are very large, BFS is not the optimal algorithm to choose due to its large memory requirements.

(15)

A B C D E F A A B D C A B D E F C A B D E F C A A B D E F C F A G A B D E F C F A A B C

Figure 9: The steps of the BFS algorithm. It expands all nodes at one layer before contin-uing to the next. The yellow nodes illustrate found but not yet expanded nodes while the red nodes illustrate already expanded ones. The node G is marked as green as it is the node to which a path is desired; since it was found, the objective was met.

A B C D E F A B C A B D C A B D C A B D C A B C A A A B D C A B C D

...

...

...

Figure 10: The steps of the DFS algorithm. It expands all nodes at one branch before continuing to the next. The yellow nodes illustrate found but not yet expanded nodes while the red nodes illustrate already expanded ones. The algorithm is in this example trapped in an infinite loop and node G is therefore never found.

(16)

3.6 Iterative-deepening depth-first search

Breadth-first search (BFS) and Depth-first search (DFS) both have their disadvantages. Not only are they both uninformed, but BFS’s memory usage is very high and DFS is not guaranteed to find the optimal solution. There is however an algorithm that uses the advantages of these two algorithms and it is called Iterative-deepening depth-first search (IDDFS). It has the same low memory requirements (O(b ∗ d)) as DFS but is guaranteed to find the goal node in finite number of iterations, (as long as there are finite number of transitions from each node in the graph and the goal node is at a finite number of transitions from the root), as BFS. To do this, the algorithm runs DFS repeatedly, each iteration only to a certain level, specified by a depth bound d. The first depth bound equals to 1, and when all nodes at the level in question has been found, it will backtrack to the root to then run a DFS again but to one level further away from the root (i.e. the depth bound is increased by one), and so on. These iterations are done until the goal node is found, see Figure 11 that shows an example of how an iterative-deepening depth-first search algorithm could look when considering the state space in Figure 8 once again. [5]

3.7 IDA* algorithm

The iterative deepening A* (IDA*) algorithm is an algorithm that solves the shortest path problem. It uses the advantages from both A* and the uninformed iterative deepening depth-first search. A* alone has the drawback that it has to keep information of all nodes found so far and the iterative deepening depth-first search is uninformed, generally re-sulting in more expanded nodes. However, combining those two as in IDA*, one can get an informed algorithm, guaranteed to find the optimal solution if such exists, without the memory contraints; while A* has to keep information of all nodes found so far, IDA* only has to keep information about the current path it is evaluating, resulting in a lower memory usage than in A*.

The algorithm runs as iterative deepening depth-first search, with a depth bound that increases for each iteration. However, in IDA*, this depth bound is not increased by one in each iteration as in the ordinary depth-first search; instead, the depth bound is increased to the lowest of all f values that at the same time exceeds the previous depth bound. If a node is found and its f value exceeds the depth bound, that branch will be cut off during that iteration – the algorithm will continue to another branch. [5]

(17)

A B C D E F A B C A B D C A B D E F C

d=2

d=1

A B D C A A B D E F C F A G A B D E F C F A

d=3

A B C A B D C A B D E F C A B D E F C A A B D E F C F A G A B D E F C F A

d=2

A B D E F C A A A B C A B D C A A B C A

Figure 11: The steps of the IDDFS algorithm. It runs a depth-first search multiple times, but each time only to a certain depth d. The first time, the depth equals 1. Every time all nodes within the defined depth d have been reached without encountering the goal node, the depth-first search will terminate and the algorithm will backtrack to the root node A. The depth d is then increased by 1 to then run the search again, this time one layer further. The blue boxes illustrate the different depth-first searches for the depths d=1,2,3. The yellow nodes illustrate found but not yet expanded nodes while the red nodes illustrate already expanded ones. The node G is marked as green as it is the node to which a path is desired; since it was found, the objective was met.

(18)

4

Model

4.1 Model construction

The framework created in this project allows the user to define a map of which to be used for simulating vehicles traversing toward goals at different locations in the map in question. The user can himself define the structure of the map and the speed limits of the different road segments. The number of vehicles to be simulated can also be defined and so their starting positions. All vehicles have a list of goals. These lists (or a part of them) may be empty when starting a new simulation. Then, one goal will be found and added to each empty list respectively. These goals will be found stochastically, choosing between all nodes in the map, where the likelihood of choosing the different nodes are uniformly distributed. When the goal in question has been reached by the concerned vehicle, a new goal will be found and added to the list in the same manner. However, if wanted, these goal lists may also be filled manually before starting the simulation if it is desired for the vehicles to traverse to specific goals in a predefined order. The lists can be made arbitrarily long, and if a list is short enough to run empty during a simu-lation, a new goal is found and added to the list as previously described. This means that a vehicle will always get a new goal toward which it will start to traverse when its most recently found goal has been reached. Moreover, if it is desired to change the lists of goals during a simulation, this can easily be done. Just by pausing the simulation, the list may be changed manually. When completed, the simulation can easily be continued again from where it was before.

4.2 Assumptions and limitations

When constructing the model, certain limitations and assumptions were defined. The first assumption for this model is that there exists a positioning system in the mine, meaning that the positions of all vehicles are known at all times. The second assump-tion concerns a communicaassump-tion system free of delays, from vehicles to a control center. Based on these assumptions, vehicles are controlled with instantaneous precision. One limitation is that there are no variations in the vehicles’ speeds. Thus, when a vehi-cle traverses in the simulations, its speed is constant and equal to the speed limit of the current road segment defined when creating the map. Also, infinite acceleration is pos-sible in the simulations. This means that a vehicle goes from speed 0 to a constant speed immediately. With other words, the vehicles’ speeds are discontinuous.

Another limitation is that the vehicles can turn around, changing heading by 180 de-grees, at any point. This means that the vehicles in the simulations with this model can turn around even when currently being in the middle of a very narrow tunnel. Of course, this is physically not possible. However, to make it a bit more realistic, one can see it as if the vehicles are reversing when suddenly changing direction in this manner.

Finally, another limitation of this model is that only one level of a mine can be simulated at once since the framework only supports creating two-dimensional maps. Moreover, vehicles cannot enter nor exit the defined map, i.e. it cannot leave for another level of the mine.

(19)

5

Implementation

The framework created in this project was implemented in Matlab. The following sec-tion explains the main structure of the program and how the different funcsec-tions work. It presents how a map is built up using the framework, how the vehicles find the short-est path from their current position to their goal, how the collision avoidance algorithm works, among other things. Furthermore, the solutions to the problems presented in Sec-tion 2 (the secSec-tion named ’Challenges’) is presented.

5.1 Map representation

The framework supports fast map generation. One example of a map created by the framework is shown in Figure 12. To store the map information, it is first segregated into smaller parts. These parts, called segments, are created by placing one node in each in-tersection and endpoint of the map, see Figure 13 where all nodes of the map are marked with filled circles.

Figure 12: An example of a map created by the framework.

A segment is defined as the part of a road connecting two nodes, in the figure shown as the shaded area connecting two of the filled circles. For each segment, the framework stores the x- and y coordinate of these two nodes (i.e. the segment’s starting point and end point), the segment’s width and finally the speed limit of the segment in question. Nothing else has to be specified by the user in order to get a map that will get plotted and used in the simulations. Information regarding neighboring segments is computed automatically by the framework after specifying a map.

(20)

Figure 13: A map created by the framework with all nodes marked with circles and a segment marked as the shaded part of the road connecting two of the nodes.

All vehicles in the map are color-coded together with its path, starting point and goal. A starting point is represented using a triangle and a goal using a square, see Figure 14. If several vehicles, say n vehicles, share the same starting point, the triangle will be split up into n pieces, all being of equal size. All pieces then share the same color as its vehicle respectively. The same thing happens to the square if several vehicles share the same goal. If the starting point of some vehicles coincide with the goal of others, the triangle will be plotted on top of the square to make sure it is not hidden beneath. In this way, all starting points and goals are at all times shown, even when they coincide with each other (unless they are temporarily hidden beneath a vehicle). Every time a vehicle can go directly from the previous goal to the new goal, a path, shown as a line connecting the triangle and the square, is plotted. However, if the vehicle has lower priority than another vehicle with which there is a potential collision detected by the algorithm, this vehicle’s path will instead be plotted out to another location, avoiding the collision (or the vehicle will stand still until it can continue traversing toward the goal).

(21)

Figure 14: An example of how a vehicle is represented along with its start (marked as a triangle), its goal (marked as a square) and its path (illustrated as a line), all in the same color as the vehicle.

5.2 The main structure of the program

When the user has created a map, he can also define how many vehicles to be simulated. If desired it is also possible to define the vehicles’ starting positions and their lists of goals, which are set in the function named ’main’, see Figure 15. This is also where all other variables are set once in the beginning, before starting the simulation.

traverse (starts the simulation)

Take the one node in the frontier that has the lowest f value and

move it to the visited set

Is this new node the goal node

G?

If vehicle v continues on its path towards its goal, will

it collide with another vehicle?

No

Yes

Finish

Expand this new node, i.e. investigate which neighbors it has and add the new nodes to the frontier

along with their f values respectively

avoidance (collision avoidance algorithm) get_info_about_new_segment

(determine the vehicle’s new heading, etc. when reaching a new segment)

move_each_vehicle pathfinding avoidance_link (recursive function) remaining_path_incl_surroundings _contain_point2 standing_still_link (if a vehicle has to stop it has to make

sure all vehicles behind it also stops) cd3_v_ov (collision detection) get_temporary_path _avoiding_collision main traverse avoidance get_info_about_new_segment move_each_vehicle pathfinding plot_vehicle avoidance_link remaining_path_including_surro undings_cointain_point2 standing_still_link cd3_v_ov get_temp_path_a vo_coll main

(sets all variables once in the beginning)

Figure 15: A simplified block diagram of the program. The bold text indicates the tion name and the normal text within a parenthesis gives a short explanation of the func-tion in quesfunc-tion.

(22)

In the end of ’main’, another function named ’traverse’ is called, which is where the sim-ulation is started. This function consists of one big loop. In each iteration of this loop, the vehicles3 are all being traversed one step, by calling the function ’move_each_vehicle’. Furthermore, in ’traverse’, it is always checked whether any vehicle has reached its goal or enters a new segment along its way to get to the goal. Every time a new segment has been reached, the vehicle resets its heading and step length to match the new segment. This is done in the function ’get_info_about_new_segment’. Moreover, when a vehicle has reached its goal, the function ’pathfinding’ (sec. 5.3) is called, and it will return the shortest path from the vehicle’s current position to its next goal in the goal list.

If all vehicles were to traverse toward their respective next goal at the same time, many vehicles would collide with each other along the way. Therefore, the collision avoidance function ’avoidance’ is called regularly (however not by far at each iteration of the loop in traverse). It is also called whenever a vehicle has reached its goal and been given a new path, to prevent this vehicle with its changed route from colliding with other vehicles. Thus, a vehicle will continue on the same path until the next time ’avoidance’ is called, or when any vehicle has reached its goal.

The collision avoidance function and its child ’avoidance_link’ along with its children will be further explained in section 5.4.

(23)

5.3 Pathfinding

Pathfinding is used to help the vehicles find the shortest path from their current position to their goals, or to find a path leading away from a possible collision. The pathfinding algorithm used in this framework is the A* search algorithm (see section 3.4), however slightly modified. While A* uses nodes, this pathfinding algorithm uses the segments (i.e. the edges), since it is only information about the segments that is stored. Further-more, the starting point does not have to be a node; any point, anywhere, on any road in the defined map can be used as a starting point from which the shortest path to a goal is desired. See Algorithm 1 to learn how this modified A* algorithm works.

Algorithm 1Pathfinding (modified A*)

1. Begin with the starting point, S. (Observe that the point does not have to be a node.) 2. Find all segments containing point S.

3. Add these segments to the frontier along with the corresponding g, h and end node. Observe that if the starting point S is not a node, then there will be two and only two elements in the frontier, where these two elements will have the same first segment saved, but the end nodes will differ since they will store information about one of the two end nodes each. Due to this, the corresponding g values will consequently also differ, unless the point is exactly in the middle of a segment.

4. Then, iteratively do

(a) Find the element in the frontier which has the lowest f. Move it from the frontier to the visited set.

(b) Expand its end node, i.e. find all segments containing this node (except from the current segment) and add these to the frontier, along with the correspond-ing g, h and end node. However, this time one should not only save informa-tion about the current segment, but now save it as a vector containing infor-mation about all segments taken so far to reach this end node, including the current segment.

(c) Now, if

i. the end node to this element in the visited set equals the goal node, or the goal node has been found in an earlier iteration, and

ii. the f value for this element is lower than any f value for all elements in the frontier

then exit the loop.

5. Loop through every element in the visited set that ended up in the goal node, and find the one with the lowest f value. This element’s saved vector with segments corresponds to the optimal path from the starting point S to the goal node G, so this vector is the path to be returned.

For an example of this algorithm, including an explanation of the different steps, see sec-tion A.1 in the appendix.

(24)

5.4 Collision avoidance

All vehicles are, thanks to the pathfinding algorithm, guaranteed to find the shortest path to their next goal given their current position. However, some vehicles may have to al-ter these paths in order to avoid collisions with other vehicles. The following section will explain how the collision avoidance algorithm works, and questions regarding how the algorithm determines which vehicles can continue to their goals and which vehicles should alter their paths to avoid a possible collision will be answered.

5.4.1 Priorities

All vehicles in the simulations have different priorities; the vehicle with priority 1 has the highest priority, priority 2 is the second highest, etc. This means that the vehicle with priority 1 always will go toward its goal (with a few exceptions, to be further discussed in section 5.5 and 5.6). Furthermore, the vehicles always strive to keep at least a safety distance between each other, meaning that if a vehicle stands on another higher prior-itized vehicle’s path or in the close surroundings of it, then the former vehicle finds a route avoiding the possible collision. Otherwise, if the lower prioritized vehicle does not stand on the other’s remaining path or in the close surroundings of it, but the two vehi-cles would collide if they both continue (this is investigated in the function ’cd3_v_ov’, see Figure 15), the vehicle with a lower priority will stand still until it can continue with-out causing a collision.

However, there are more things to consider. The framework needs to accommodate for more than two vehicles at a time; it is not always as easy as letting the highest prioritized vehicles traverse while all other vehicles stay out of their way. Sometimes, a higher pri-oritized vehicle has to stand still or find a path away from a lower pripri-oritized vehicle. Consider the scenario shown in Figure 3 once again, first presented in Section 2. If noth-ing at all is done, vehicle 1 and 4 would collide, and also vehicle 2 and 3. Therefore, the vehicles’ priorities is compared to determine what actions should be done. Vehicle 4 has a lower priority than vehicle 1, and hence it should turn trying to go away from vehicle 1. In the same way vehicle 3 has a lower priority than vehicle 2 and should therefore turn trying to go away from vehicle 2. However, this introduces the new problematic scenario. If vehicle 4 and 3 were to continue away from the higher prioritized vehicles, they would collide with each other when reaching the intersection. Hence, the algorithm has to be able to consider more than two vehicles at a time, sometimes letting a vehicle with the higher priority stop or turn around, going away from a lower prioritized vehicle. In the scenario shown in Figure 3, perhaps vehicle 3 and 2 should stop for vehicle 4, which has the lowest priority of all vehicles shown in this case, in order to let the highest prioritized vehicle 1 continue. See section ”Avoidance link” to find out how this is solved by the algorithm.

5.4.2 Avoidance link

Consider the case shown in Figure 16. There are two vehicles meeting in a tunnel through which only one vehicle can pass; the white vehicle, a vehicle with priority 1 and thus the vehicle with the highest possible priority, and the purple vehicle, a vehicle with priority 3. Vehicle 1 has the highest priority and should thus continue traversing while vehicle 3 turns, avoiding the collision. However, consider the case shown in Figure 17, where

(25)

there is yet another vehicle present – the blue vehicle with priority 2, thus with a priority higher than vehicle 3 but lower than vehicle 1. If to determine which vehicle to alter its path solely based on comparing the priorities of every pair of vehicles, it would in this case be found that vehicle 3 has a lower priority than both vehicle 1 and 2 and would thus try to go away from both. This is physically not possible in this case since it is trapped in between the two. Therefore, it is not as easy as just comparing priorities between every pair of vehicles that could cause a collision; vehicle 2 should in a situation as described see that it has to go away from vehicle 3 even though the priorities say otherwise.

Figure 16: Two vehicles meeting in a tunnel through which only one vehicle can pass due to its limited width. If both vehicles continue, they will collide.

Figure 17: A scenario illustrating a situation that the collision avoidance algorithm has to be able to handle. If comparing priorities, shown as numbers on top of the vehicles, it will be found that vehicle 3 has a lower priority than both vehicle 1 and 2. However, it cannot go away from both. Thus, to avoid a collision, vehicle 2 have to see that it should turn around, going away from a vehicle that has a lower priority than itself.

In order to realize that vehicle 2 should turn and go away from vehicle 3, there is a vari-able telling that vehicle 3 is currently going away from another vehicle, and that this vehicle has priority 1. Thus, when vehicle 2 and 3 compare priorities, it will be found that vehicle 3 temporarily has a higher priority than vehicle 2, (1 rather than 2). This also works recursively, meaning that there can be arbitrarily many vehicles between vehicle 1 and 2; as long as the space between all the vehicles are small enough and there are no intersections along the way through which some of the vehicles go, creating some more space between the remaining vehicles, there will be a long link of vehicles going away from vehicle 1, all having a temporary priority of 1 – including vehicle 2. In this way, the challenge shown in Figure 3 in the section ’Challenges’ is solved; there will be a link of vehicles staying out of the way from vehicle 1, meaning that vehicle 4 traverses upwards, away from vehicle 1, while vehicle 3 and 2 stand still.

5.4.3 Remaining path including surroundings

In the previous section we learned that the vehicles in the model have different priorities and that the higher prioritized vehicles generally traverse toward their goals while the lower prioritized vehicles stay out of the way, if necessary. So, in order to know whether the lower prioritized vehicle, vl, has to move to avoid a possible collision with a higher

prioritized vehicle vh, one has to investigate if this vehicle is on the other, higher

priori-tized vehicle’s path.

(26)

remaining path of vh. Consider the case shown in the leftmost image in Figure 18, where

the white vehicle (the vehicle traversing upwards) is the vehicle with the higher priority, vh, and the light blue vehicle, vl, has the lower. Vehicle vl is standing very close to an

in-tersection through which vh’s path goes. Hence, their paths do not coincide, but if vehicle

vl stands still, vhwill eventually collide into the other.

Hence, in order to avoid collisions due to situations like these, not only the remaining path of vhis investigated, but also the surroundings. Consider the image in the center of

Figure 18. The shaded area illustrates the remaining path of the white vehicle, including the surroundings of it. Here, the surroundings refers to the part of the roads being within a certain distance (hereby referred to as a safety distance) from the vehicle’s remaining path. Hence, at each intersection the path goes through, the part of the roads being within one safety distance from the path are also included. It will also, as the figure shows, be able to see backwards at a length of one safety distance. Another important thing is that all segments (or part of segments), independent of how many branches the roads will split up into, will be found as long as they are within one safety distance from the path, see the rightmost image in Figure 18.

Figure 18: Images showing the meaning of a vehicle’s remaining path including sur-roundings, (which is marked as the shaded area in the two images to the right), along with the reason for not only considering the remaining part of a vehicle’s path (the left-most image).

However, sometimes the whole remaining path including surroundings is not consid-ered when searching for other vehicles on a highly prioritized vehicle’s path. This occurs if the length of the remaining path of the vehicle is greater than a certain threshold. If d is the distance a vehicle can travel between each time the collision avoidance algorithm is called, this threshold should be set to be at least the sum of one safety distance and 2∗d. If the threshold is set to this value, one can guarantee that the vehicles will not be

(27)

closer to each other than the length of one safety distance before the collision avoidance algorithm will be called again – even in the case where the two vehicles traverse right toward each other. This can be guaranteed since each vehicle will not travel further than the distance d before the next function call, which means that one safety distance remains to make sure the vehicles do not get too close to each other. Why one should even con-sider to introduce such a threshold is to prevent vehicles from finding temporary paths, going away from their goals, when not necessary. Consider the case where a vehicle with a high priority, vh, has a goal that is on the other side of the mine. If it takes a very long

time for the vehicle to travel to its goal, another vehicle being far away but still on vh’s

path should not have to alter its path for this vehicle, since they are too far from each other to possibly cause a collision.

5.4.4 The collision avoidance algorithm

In order to make sure that all vehicles alter their paths when necessary, there is an algo-rithm that is called regularly. The time interval between these function calls is empirically tested such that it is called whenever necessary to prevent vehicles from getting too close to each other.

The first thing that happens when calling this algorithm is that all vehicles are set to stand still and the shortest path to their goals are found. The remaining part of the algo-rithm consists of one main loop, see the flow chart shown in Figure 19. Every iteration of this loop corresponds to one vehicle, where the first iteration corresponds to the vehicle with the highest priority, the second to the vehicle with the second highest priority, etc. – i.e. the vehicles will be looped through in decreasing order of priority.

Simplified, there are three things that are investigated whether they are true at each iter-ation, and they are as follows:

1. Is this vehicle (v) currently going away from another vehicle?

2. If v continues on its path toward its goal, will it collide with a vehicle with higher priority?

3. Is there another vehicle with lower priority on v’s remaining path including surroundings (however not too far away)?

(∗)

The answers to these questions will result in different actions taking place, see Figure 19 and 20 where question 1 is asked in the former figure and question 2 and 3 are asked in the latter. If the first question is true, the algorithm immediately continues to the next it-eration of the loop without investigating the second or third question, see Figure 19 once again. This is done since if vehicle v is already going away from another vehicle, that vehicle with absolute certainty has higher priority than any other vehicle that may ap-pear in subsequent iterations, since the algorithm loops through all vehicles in the order of decreasing priority. However, if 1 is not true, question 2 and 3 will be asked.

(28)

avoidance_link(v)

Start

Let all vehicles stand still

For each vehicle, find the shortest path to

its next goal

vehicle_index++ vehicle_index=0 Vehicle v = order_prio (vehicle_index) Is vehicle v currently going away

from another vehicle?

If vehicle v continues on its path towards its goal, will

it collide with another vehicle?

Yes

No

Is vehicle_index equal to the total

number of vehicles? No Yes Finish avoidance_link(v) order_prio is a vector containing all vehicles, where the first element corresponds to the vehicle with the highest priority, the second element to the vehicle with the second highest priority, etc.

Q1.

P PPq

main

loop

Figure 19: A flow chart of the collision avoidance function. All vehicles in the map are investigated one by one, in decreasing order of priority. For each vehicle, the function avoidance_link is called if the current vehicle has not already been given a new path due to a possible collision with another vehicle. Q1 represents question 1 given in (∗).

Due to the fact that the algorithm loops through all vehicles in the order of decreasing priority and asks question 3 to these vehicles (the ones that have not been told to stand still), the algorithm will ensure that all vehicles being on a higher prioritized vehicle’s path will be found and can thus be given a new path to avoid the other vehicle. So, when at the end of iteration i in the loop, vehicle i will already have been told to go away from the first of all vehicles 1,2,...,i-2,i-1 if standing on its path.

(29)

avoidance_link(ov) avoidance_link(ov) avoidance_link(v) If vehicle v continues on its path towards its goal, will

it collide with another vehicle? If

vehicle v continues on its current path, will it collide with another vehicle with

a higher priority? Yes No Is there any other vehicle, ov, on vehicle v’s remaining path

including surroundings that have lower

priority than v?

Yes

No

Let vehicle v traverse toward its goal

Let’s call this other vehicle ov_p. Let vehicle v stand still, and temporarily give v the same priority as the

priority of ov_p.

Now, if vehicle v was going away from another vehicle since before, ov_old, let ov_old stop too. In

the same way, if ov_old was going away from another vehicle since earlier, let ov_old stop, etc. For

all vehicles in this link stopping to a halt, give them a temporary priority that equals the one of ov_p.

Return

If several vehicles ov, order them in an array with increasing spatial distance from vehicle v. Then call avoidance_link(ov(i)) for all i in the array ov. Let vehicle ov traverse,

and give it a new path going away from vehicle v.

Is vehicle ov in front of v, meaning that ov can continue toward

its goal without causing a collision with

vehicle v?

Yes

No

Let vehicle ov traverse, and give it a new path going away from vehicle v. If several possible paths due to an

intersection, choose the one minimizing the distance to the goal.

Q2.

P PPq

Q3.

P PPq

Figure 20: A flow chart of the recursive function avoidance link called from the main loop in the collision avoidance algorithm. This function makes vehicles stop or find a new path if otherwise risking to cause a collision. Q2 and Q3 represent question 2 and 3 given in (∗) respectively.

However, this may not be clear to be true since if one considers the flow chart in Figure 19 once again, one may think that question 3 is not asked to each vehicle. This question is only asked in the function avoidance_link, and that function call is skipped if the cur-rent vehicle in the main loop is already going away from another vehicle; in that case, the loop will continue to the next iteration of the loop immediately. But observe that if

(30)

this is the case, question 3 has already been asked to this particular vehicle in an earlier iteration of the main loop (again, if it has not been told to stand still). The function avoid-ance_link is a recursive function, and if a highly prioritized vehicle v have this vehicle i on its remaining path including surroundings, avoidance_link will be called with vehicle i as input already here, see the flow chart shown in Figure 20 once again. This means that as soon as a vehicle has been told to go away from another vehicle, e.g. for being on its remaining path including surroundings, question 3 will be asked and does therefore not have to be asked again in a subsequent iteration of the loop. Hence, the earlier statement that any vehicle standing on a higher prioritized vehicle’s path will have been seen and been given a new temporary path, trying to avoid the possible collision, is true.

So, due to the third question in previous iterations of the loop, the vehicle corresponding to the current iteration of the loop, vehicle v, will already be going away from another vehicle if standing on or in the closest surroundings of the path of another higher prior-itized vehicle, ovp. However, a collision may still occur between vehicle v and ovp, even

though vehicle v does not stand close to ovp’s path, if v traverses towards ovp. This is

the reason why to investigate the answer to question 2. If it will collide with a higher prioritized vehicle if continuing to traverse, vehicle v should instead stand still to avoid the collision, and get a temporary priority that equals the priority of the vehicle it stops for. Question 3 does not have to be investigated now since v is standing still. However, if vehicle v was going away from another vehicle since earlier, say from vehicle ovold, then

also ovoldhas to halt to a stop not to continue into vehicle v. In the same way, the vehicle

ovoldwas traversing away from, if any, has to halt to a stop, and so on. All these vehicles,

halting to a stop to prevent colliding into the stationary vehicle before them, create a link of vehicles. When there are no more vehicles to be added to this link, they all get a tem-porary priority that equals the priority of ov.

Finally, if neither question 1 nor 2 returned true as an answer, vehicle v can continue to traverse toward its goal and the algorithm will also check question 3 – whether vehicle v has another, lower prioritized vehicle on its remaining path including surroundings. If not, nothing more will happen; if yes, that other vehicle, ov, will get a temporary priority that equals the one of v, and it will start to traverse away from vehicle v. If ov reaches an intersection doing so, it will choose the way that minimizes the driving distance to its goal, if possible (if not a dead end where there already is a vehicle, blocking the way). But here, since it is likely that this other vehicle ov had to alter its path, question 2 has to be checked once again. If it returns true, i.e. if it will collide with a higher prioritized vehicle if continuing, this vehicle will stand still and change its temporary priority to this new vehicle’s priority, and the algorithm will go back in a link checking all vehicles behind, including vehicle v, telling them to stop and to change their priority temporarily. How-ever, if question 2 returned false, question 3 also has to be investigated. This is because if there is any other vehicle on ov’s remaining path including surroundings, this vehicle also has to go away from vehicle ov in order to avoid collision. This is a typical example of the so-called avoidance link function. This means that if there are several vehicles in a line, all vehicles will in a link go away from the vehicle with the highest priority in the link, see the recursive function-call in Figure 20.

Also, if question 3 is investigated and there are several vehicles on vehicle v’s remain-ing path includremain-ing surroundremain-ings, they are all ordered with increasremain-ing drivremain-ing distance from vehicle v. Then one of these vehicles at a time, in the order of the list, will be told to traverse along a new path going away from vehicle v, and at the same time be given a temporary priority that equals the one of vehicle v. But, before continuing on the list of

(31)

vehicles on v’s path, this vehicle that just got a new path will investigate question 2 and 3 again, see the recursions from the avoidance link function-call in Figure 20. This is to ensure that the link of vehicles going away from the highest prioritized vehicle in ques-tion, go away in the right direction and from the right vehicle. This is important since if this would be done in the wrong order, some vehicles in the link would go in the wrong direction, causing a collision.

For an example of this algorithm, including images and an explanation of the different steps, see section A.2 in the appendix.

5.5 Dead ends – switching priorities

Since the collision avoidance algorithm works with priorities, letting the highest prior-itized vehicles traverse while making others stay away, there may be problems when reaching a dead end. Consider a case as shown in Figure 21, where a vehicle with high priority (here the white vehicle with priority 1) traverses toward its goal which is at the end of a tunnel, and there is also another lower prioritized vehicle between the first ve-hicle and its goal. If veve-hicle 1 were to continue toward its goal, it would collide into the other vehicle.

Figure 21: Two vehicles in a dead end, with the higher prioritized vehicle traversing into the dead end toward its goal and the other vehicle in front of it. If they both continue there will be a collision.

To prevent the occurrence of situations like these, vehicles temporarily switch priorities with each other, if found necessary. To find when to switch priorities, two things are checked for each vehicle v leaving a node:

1. If vehicle v continues on its path, how many dead ends will there be when reaching the next node?

2. How many other vehicles is there in these tunnels?

If the number of vehicles found is equal to or exceeds the number of dead ends, vehi-cle v compares its priority with the vehivehi-cles in these tunnels. If vehivehi-cle v has a higher priority than any of the vehicles in the dead end tunnels, the current position of vehicle v is remembered as the point of switch, and the vehicle will switch its priority with the one of the other vehicles which has the highest priority. This means that there is now a new vehicle that has the highest priority (in this area of the mine). Thus, the new vehicle with the highest priority, vh, can go toward its goal and vehicle v will stay out of the way.

However, when vehicle vh reaches the point of switch, the priorities will be switched

back. Hence, vehicle v will start traversing toward its goal, but since vehicle vh is at a

node where there are at least 3 connecting tunnels, it will choose the one tunnel that goes away from the path of vehicle v. This means that it will not go into the dead end again, so vehicle v can now continue into the dead end, toward its goal, without forcing another vehicle into a corner – the possible collision has been avoided. For an example of this situation, including an explanation of these steps, see section A.3 in the appendix.

(32)

5.6 Dead ends shorter than one safety distance

Except for when vehicles switch priorities with each other as described in section 5.5, there is only one situation that can make a higher prioritized vehicle halt to avoid getting too close to a vehicle with lower priority. That situation is when a vehicle is in a dead end tunnel that is shorter than one safety distance. Then it waits there for any vehicle outside the dead end that is at a distance smaller than one safety distance from it, and it will do so until the other vehicle has traversed far enough to create at least one safety distance between them. Observe that the lower prioritized vehicles still try to find a path away from it if they are on the higher prioritized vehicle’s remaining path or surroundings, but this is the only scenario that can make the vehicle with the highest priority (or the one with the temporarily highest priority if priorities have been switched) halt to a stop.

(33)

6

Results

The framework along with its collision avoidance algorithm has been empirically tested. The map that was used in these simulations is illustrated in Figure 22 with 5 vehicles. Furthermore, all segments were set to have the same speed limit and the time it took for a vehicle to get from point A in the map to point B was approximately 23 seconds. The simulations have been run for a total time of 100 hours, during which a total shut-down occurred twice due to a pair of vehicles getting too close to each other. One dead lock also occurred, i.e. a case where none of the vehicles could continue to their next goal.

Figure 22: Two points A and B in a map created by the framework and the path connect-ing the two.

Furthermore, the pathfinding algorithm has been subject to many different scenarios with different maps. The maps were all constructed to investigate whether the algorithm al-ways found the shortest path between two specified points, even though there were more than one possible path between the two. During all these supervised tests, the optimal path was always found.

(34)

7

Discussion

7.1 Pathfinding algorithm

Three of the most common algorithms for solving the shortest path problem are the Dijk-stra’s algorithm, A* and IDA*, and these algorithms all have their advantages and draw-backs. Hence, it is not trivial to determine which of these algorithms is the best – it depends on the problem at hand.

If one start node is present, and the shortest path to several other locations around that very node are desired, Dijkstra’s algorithm may be an adequate algorithm to use. For instance, consider a single-player game where the main character, played by the user, should stay away from enemies at different locations, where these enemies constantly try to move toward the main character. Here, Dijkstra’s algorithm would probably be preferred since there is one source (the main character’s position) from which several shortest paths can be retrieved, one path to each enemy. When these paths are found, it is only a matter of reversing the retrieved paths to get the shortest path from all the enemies to the one main character respectively.

However, if only one path is desired, it is probably preferred to use an algorithm which has a heuristic such as A* or IDA*, since these algorithms often find the shortest path faster by exploring the most promising nodes first. One of the main differences between the A* and IDA* is the memory usage. Since IDA* uses the concept of iterative deepen-ing depth first search, this algorithm only has to keep the nodes in the current path it is evaluating in memory, while the A* has to keep all nodes found so far in memory, which is considerably heavier. Thus, IDA* can be useful when dealing with large state spaces. On the other hand, IDA* expand the same nodes multiple times, while A* only does that once. This means that A* has an advantage here.

In this particular project, the paths to be found all had different starting points (two vehi-cles cannot be at the exact same position at the same time), and the goals were randomly selected from all nodes in the map. This means that it was not a single-source pathfinding problem, but rather several problems where the shortest path was desired, all beginning at different locations. Also, an adequate heuristic was easy to find; the shortest distance between two points in two-dimensional space cannot be smaller than a straight line be-tween the two. This means that the euclidean distance, which is very easy to find given the two points, can be used as a heuristic. Hence, A* and IDA* was preferred over Dijk-stra’s algorithm due to their ability of knowing in which direction the goal is, most often resulting in fewer expanded nodes. Moreover, the search space was limited; the number of nodes in the map was relatively few, which means that the memory constraint of A* was not a problem. Hence, based on these facts, the pathfinding algorithm chosen to be used as a basis for this particular project was the A* search algorithm – an algorithm guaranteed to find the optimal solution given an admissible heuristic, without having to explore all possible paths.

References

Related documents

As the train was travelling at a speed of 125 km/h, a rail failure initiated the derailment of the trailing bogie of the eighth car and the leading bogie of the ninth car,

The empirical findings show that even if the management practices related to employee engagement towards environmental sustainability are not established, those

Försvarsmaktens koncept för expeditionär förmåga är för närvarande det enda officiella dokument som definierar och beskriver krav för förmågan till expeditionära

Ett annat hinder som ungdomarna belyser är boendesegregation, många av ungdomarna umgås inte med svenska ungdomar eftersom de bor för långt bort, de bor inte i samma område

The level of improvement potential for the different OS and IS areas identified by the self-assessment questionnaire match the roughly the improvement potential

Det är rapporterat i litteraturen, se exempelvis [1,3,4], att martensitiska stål mjuknar vid upprepad belastning vid förhöjda temperaturer. Detta mjuknande påverkas ytterligare

Within the benefits management process of Ward & Daniel (2006) the authors propose a number of roles and responsibilities, for example project sponsors,