opendrive_road.md 5.65 KB
Newer Older
1
2
3
4
5
6
7
COpendriveRoad
==============

## Description

This class describes the whole road as a set of [COpendriveRoadSegment](opendrive_road_segment.md) objects. This class handles the creation and destruction of all road elements (road segments, lanes and road node) when the opendrive file is loaded. Once loaded, it is possible to access all the elements and information of the road, but its impossible to modify it.

8
9
10
11
12
13
14
15
16
17
18
19
## Example road

The road shown in the next figure will be used to complete the description of all classes with an example. The opendrive road descrption can be downloaded [here]().

<img src="images/original_road.png" alt="Opendrive road description used as an example" width="814" height="594">

The dotted lines represent the limits of adjacent road segments. Each road segment include its name and the opendrive segment identifier (in parenthesis). The name of the two road junctions are also displayed but the name of each junction road is omitted for clarity. The names of the road junctions follows the next format:

```
<junction_name>_<origin_road_id>_<origin_lane_id>_<target_road_id>_<target_lane_id>
```

20
21
22
23
24
25
## Main features

The main features of this class are:

* Load the Opendrive description from a file. At the moment the only supported Opendrive version is the 1.4.
* Provides access to all the road segments of the road defined as [COpendriveRoadSegment](opendrive_road_segment.md) objects. The road segments can be accessed by several different ways:
26
    * **by index**: which is a unique arbitrary number assigned when the road is loaded and coincides with the order in which the road segments are described in the Opendrive file. This approach may be useful to cycle through all the segment to gather global information.
27
28
    * **by id**: which is the numerical identifier assigned in the Opendrive file.
    * **by name**: which is the string identifier assigned in the Opendrive file.
29
    * **by the closest pose**: in this case when the position of interest is known (i.e. the position of the car, an obstacle, etc...), it is possible to get the road segment which is closest to this position. It is possible to get the index of the road segment of interest or a reference to it.
30
* Provides access to all the road lanes of the road defined as [COpendriveLane](opendrive_lane.md) objects. The road lanes can be accessed by two different ways:
31
32
    * **by index**: which is a unique arbitrary number assigned when the road is loaded. This approach may be useful to cycle through all the lanes to gather global information.
    * **by the closest pose**: in this case when the position of interest is known (i.e. the position of the car, an obstacle, etc...), it is possible to get the road lane which is closest to this position. It is possible to get the index of the road lane of interest or a reference to it.
33
* Provides access to all the road nodes of the road defined as [COpendriveRoadNode](opendrive_road_node.md) objects. The road nodes can be accessed by two different ways:
34
35
36
37
38
39
40
    * **by index**: which is a unique  arbitrary number assigned when the road is loaded. This approach may be useful to cycle through all the lanes to gather global information.
    * **by the closest pose**: in this case when the position of interest is known (i.e. the position of the car, an obstacle, etc...), it is possible to get the road node which is closest to this position. It is possible to get the index of the road node of interest or a reference to it.
* It is possible to find the closest position to the road independently of the road element where it belongs.
* It is possible to get a set of poses that are closer to a given pose than a given distance threshold, independently of the road element where they belong.
candidate.
* It is possible to generate a new road object as a subset of the original road, which are completely independent from each other. See the [sub-roads](#sub_roads) section for further details.
* In case of unexpected errors, this class throws an instance of CException. All other errors are reported to the user.
41
42
43
44
45

For further details on the implementation of these features check the doxygen API documentation.

## Unsupported Opendrive features

46
Not all features of the Opendrive standard are supported by the current implementation. The limitations are listed here:
47
48
49
50

* Each road segment can have only one lane section, which implies that the number of left and right lanes is the same for all the segment.
* Each lane must have the same width for each segment.

51
52
53
54
55
56
57
58
59
60
61
62
## Sub-roads

One important feature of this class is the possibility to create new roads with a sub-set of the original road elements. The original road elements are created when the Opendrive file is loaded and can not be modified afterwards. When a sub-road is generated, new elements are created while keeping the required original information and connectivity, resulting in two completely independent objects. The only information that changes in the new sub-road is:

* the remaining road segments, lanes and road nodes are re-indexed, so that their unique index is coherent with the new data structure. 
* for any open road segment (that is, a road segment that is not connected), new road nodes are placed at the end of the open road segment to keep its lane and link geometric information.

Three different ways to create a new sub-road are supported:

* copy: in this case the new road is just a copy of the original one.
* path: in this case the new road only has the road elements that include a set of road nodes (a path). 
* distance: in this case the new road only has the road elements that within a distance to a given pose, following the direction of the traffic.
63

64
The next images shows an example of sub-road generation for the last two cases.
65