Roads

Whenever the car’s behavior is simulated, a road is necessary.

Important

Roads are python scripts within simulation/models/env_db. The name of the file is the road’s name.

The repositories already comes with a few predefined roads.

simulation/models/env_db
├── base_world
│   ├── model.config
│   └── model.sdf
├── ci_roads
│   ├── blocked_area.py
│   ├── curves.py
│   ├── double_intersection.py
│   ├── intersection.py
│   ├── obstacles.py
│   ├── parking.py
│   ├── randomized_parking.py
│   ├── random_road.py
│   ├── speed_curve.py
│   ├── speed_intersection.py
│   ├── speed.py
│   ├── straight.py
│   ├── traffic_island.py
│   ├── traffic_sign_road.py
│   ├── traffic_sign_straight_road.py
│   └── zebra_crossing.py
├── fast_world
│   ├── model.config
│   └── model.sdf
├── real_roads
│   ├── cc20_scans
│   │   ├── training_loop.yaml
│   │   ├── training_part1.yaml
│   │   └── training_part2.yaml
│   ├── cc20_train.py
│   └── mrt.py
├── default_freeride_road.py
├── default_road.py
├── onboarding_complex.py
├── onboarding_simple.py
├── scan_road_demo.py
├── scan_road_demo.yml
├── simple.py
└── test.py

5 directories, 33 files

The renderer expects to find py:attr:road of type simulation.utils.road.road.Road within the road script.

This implies that:

Note

A new road can be any script which defines a global road variable of type simulation.utils.road.road.Road within simulation/models/env_db.

E.g. the file simulation/models/env_db/custom_road.py with content:

from simulation.utils.road.road import Road
from simulation.utils.road.sections import *

road = Road()

road.append(StraightRoad())  # Replace with other road sections

creates a very simple straight road, called custom_road.

There are a number of different types of road sections which are explained in Road Sections.

default_road

When the simulation is launched without any additional road parameter:

roslaunch gazebo_simulation master.launch

the default_road is used. It consists of multiple simulation.utils.road.generator.road_sections concatenated using a simulation.utils.road.road.Road:

default_road
"""The default road when launching this simulation."""
import math

from simulation.utils.road.road import Road  # Definition of the road class
from simulation.utils.road.sections import (
    Intersection,
    LeftCircularArc,
    ParkingArea,
    ParkingLot,
    ParkingObstacle,
    ParkingSpot,
    StaticObstacle,
    StraightRoad,
    ZebraCrossing,
)
from simulation.utils.road.sections.road_section import RoadSection

road = Road()
road.append(StraightRoad(length=1))

# Create a parking area with different kinds of parking spots
road.append(
    ParkingArea(
        length=4,
        start_line=True,
        left_lots=[
            ParkingLot(
                start=1, spots=[ParkingSpot(), ParkingSpot(kind=ParkingSpot.BLOCKED)]
            )
        ],
        right_lots=[
            ParkingLot(
                start=0.2,
                spots=[
                    ParkingSpot(
                        kind=ParkingSpot.OCCUPIED,
                        width=0.7,
                        obstacle=ParkingObstacle(x=0.15, y=-0.2, width=0.3, depth=0.25),
                    ),
                    ParkingSpot(kind=ParkingSpot.BLOCKED),
                ],
            )
        ],
    )
)
road.append(
    LeftCircularArc(
        radius=2, angle=math.pi / 2, right_line_marking=RoadSection.MISSING_LINE_MARKING
    )
)
road.append(StraightRoad(length=0.45))
road.append(LeftCircularArc(radius=2, angle=math.pi / 2))
road.append(Intersection(size=3, turn=Intersection.RIGHT))
road.append(LeftCircularArc(radius=1.5, angle=math.pi, obstacles=[StaticObstacle()]))
road.append(Intersection(size=3, turn=Intersection.RIGHT))

left_arc = LeftCircularArc(
    radius=1.5,
    angle=math.pi / 2,
    left_line_marking=RoadSection.MISSING_LINE_MARKING,
)
left_arc.add_speed_limit(arc_length=0, speed=30)
road.append(left_arc)

road.append(ZebraCrossing())
road.append(StraightRoad(length=1))

left_arc = LeftCircularArc(radius=1.5, angle=math.pi / 2)
left_arc.add_speed_limit(0, -30)
road.append(left_arc)

road.append(StraightRoad(length=0.95))