• No results found

2.4 Summary

3.1.2 Target Systems

3.1.2.2 Route Planning

The Open Street Map (OSM) database is much like open source software packages. The website hosts mapping information similar to mainstream commercial map makers, however, all of the data used to create these maps is freely downloadable in XML for- mat. OSM XML files can be imported into MATLAB structures using OpenStreetMap Functions for MATLAB [122].

Upon running the functionparse openstreetmapon a downloaded openstreetmap.xml file the resulting two structures are: parsed osm and osm xml. Both files contain the same information although the formatting of the parsed osm structure is more favourable as it has fewer sub structures and simpler formatting. The parsed osm structure is as follows:

• parsed osm.bounds[minlon, maxlon,minlat,maxlat];

• parsed osm.node struct

• parsed osm.node.id [1xn] vector of node id values

• parsed osm.node.xy [2xn] vector of node xy coordinates in long, lat decimal degrees

• parsed osm.waystruct

• parsed osm.way.id[1xm] vector of route id values - routes are sets of nodes

• parsed osm.way.nd{1xm} [1xk] vector of node ids that make route

• parsed osm.way.tag{1xm}{1xj} set of information varies from 1-3 containing the following:

• parsed osm.way.tag{1xm}{1xj}.Attributes.k string type of attribute (‘natural’, ‘highway’, etc.)

• parsed osm.way.tag{1xm}{1xj}.Attributes.v string sub type of attribute (‘coast- line’, ‘primary’, etc.)

• parsed osm.Attributescontains string information about the source copyright etc.

The OpenStreetMap Functions also contain connectivity functions. The following three functions are used in sequence:

• [connectivity matrix, intersection node indices] = extract connectivity(parsed osm);

• intersection nodes =

get unique node xy(parsed osm, intersection node indices);

• dg = or(connectivity matrix,connectivity matrix’);

The output from these functions can be used to find the shortest path between two nodes using Dijkstra’s algorithm [123]. The limit of the built inroute planner func- tion is that it will only work if both the start and end points chosen are intersection nodes. This is because the connectivity matrix only contains nodes that are inter- sections. Consequently the output route provided by the route planner is made up of only intersection nodes. This would suffice if each road between intersection points were made up of only one point to point line, however, it is far more common that the roads in-between these intersection nodes contain a number of nodes that represent the road between them.

In order to have a robust node-to-node shortest path algorithm that is not depen- dent on intersection nodes, and provides the complete route with all nodes between intersection points, a new function was created namedroute planner any node. The function uses several key steps in order to find the complete route.

• Check if Start and End points are intersection nodes.

• If they are not intersection nodes, find the ‘ways’ (roads) that they belong to.

• On those roads, find the nearest intersection nodes.

• Use those intersection nodes to run theroute planner algorithm.

• Append the nodes needed to get from the Start point to its nearest intersection node.

• For each intersection–>intersection node route leg provided by route planner append the way nodes between them.

• Append the nodes needed to get from the last intersection node to the End point.

• Extract the Latitude and Longitude for the complete route. Theroute planner any node returns a number of vectors containing information about the complete route.

These are:

• Route id - holds the actual id number of the nodes used in the route [1xn].

• Route index - holds the index within theparsed osm.node array.

• Route LL - holds the decimal degrees [longitude;latitude] pairs in a [2xn] array.

• Way id - holds the actual id number of the way to which the node belongs [1xn].

• Way index - holds the index within theparsed osm.wayarray.

The way id/index values are output for use by the moving target’s simulation. Each way has a set of attributes that contain a ‘key’ and a ‘value’. The ‘key’ is used to identify the type of information contained in the way - for example ‘natural’ for geographical features, or ‘highway’ for road networks. The ‘value’ then contains information about the type of the key, for example the ‘highway’ key contains values to describe the type of road, ‘motorway’, ‘primary’ etc. This information can be used by the moving targets simulation to infer speed limits along the different sections of the route to be driven.

−2.9552 −2.9551 −2.955 −2.9549 −2.9548 −2.9547 53.3965 53.3966 53.3967 53.3967 53.3967 53.3968 Longitude (o) Time: 180.30 Pause: 0.00

Lat: 53.396650 Lon: −2.954998 Accel: 0 Brake: 0 Steer: 1 Act Speed 11 Des Speed 11

Act Hdg 142 Des Hdg 164 Wpt 48 Dist 61.3806

Latitude (

o)

Figure 3.23: Simulation of a Car Type Vehicle in MATLAB Driving on OSM Roads

Figure 3.23 shows the overview of a simulation of a car type vehicle on roads loaded in from an OSM database. Actual speed, desired speed, actual heading and desired heading are shown, as well as the current position and the desired mode that the vehicle is in – accelerating, braking and/or steering.