3. Road¶
This section is an introduction to the construction of routes for our simulation environment. The routes for our simulation, which we call roads, consist of different sections. A single road is made up of different road sections which are placed consecutively. All length specifications are in meters.
3.1. Road sections¶
Available road sections are:
simulation.utils.road.sections.road_section.RoadSection
: This is the abstract parent to all other road sections.simulation.utils.road.sections.straight_road.StraightRoad
: Simple straight road with a default length of 1 m.simulation.utils.road.sections.circular_arc.LeftCircularArc
andsimulation.utils.road.sections.circular_arc.RightCircularArc
: Circular arcs take an angle and radiussimulation.utils.road.sections.bezier_curve.QuadBezier
andsimulation.utils.road.sections.bezier_curve.CubicBezier
: Bézier curves are parametric curve which is defined by a number of control points.simulation.utils.road.sections.intersection.Intersection
: Four-way intersection; by default the crossing roads are perpendicular to each other, but this angle can be freely modified. It is also possible to close up endings to get a T-junction for example.simulation.utils.road.sections.zebra_crossing.ZebraCrossing
: A cross walk; the default length is 0.45 m.simulation.utils.road.sections.parking_area.ParkingArea
: The ParkingArea can have multiple ParkingLots on the left and right side of the road. According to the rules of the Carolo-Cup ParkingLots on the right side are meant for parallel parking, those on the left require perpendicular parking. ParkingLots consist of ParkingSpots which can have three different states:FREE: please park here
BLOCKED: spots which are blocked are marked with a cross
OCCUPIED: spots occupied by ParkingObstacles which are simple cuboids
Another important part is the StartLine which is also available inside the ParkingArea. The StartLine defines both the beginning of a road and the start of a ParkingArea.
StaticObstacles can be placed on every RoadSection. Every road section has a middle, right, and left line. Lines can be dashed, solid or missing. The width of a single lane is 0.4 m thus making the road 0.8 m in width. The origin of every road is at the beginning of the first middle line. The x-Axis points in the driving direction (along the middle line), the y-Axis is defined pointing towards the left line. These axes are also shown in gazebo (x-axis: red, y-axis: green).
3.2. Road directory¶
Roads are defined in a single python file. All of these road files are located in simulation/models/env_db/
.
After rendering a road file called road_name.py
a .road_name
folder is created in the same directory.
Amongst other things, this hidden folder contains pictures of the rendered road which are later used in the simulation.
Tip
Hidden files or directories can be recognized by the dot (.) before their file or directory name.
By default, they are not shown to the user. In most file managers, you can use the Ctrl+H
keyboard shortcut to
toggle between displaying or hiding hidden files.
In a terminal you can use the ls command to display all files, including the hidden ones:
ls -a
3.3. Simple road¶
Inside the road directory, there is a road file called onboarding_simple.py
.
It is a very simple road only containing StraightRoads and a basic right-angle intersection.
Let’s take a look at onboarding_simple.py
:
1 2 3 4 5 6 7 8 9 10 | """A simple road for the onboarding task."""
from simulation.utils.road.road import Road # Definition of the road class
from simulation.utils.road.sections import Intersection, StraightRoad
road = Road()
road.append(StraightRoad())
road.append(StraightRoad(length=2))
road.append(Intersection())
road.append(StraightRoad())
|
Lines 3 to 5 are imports for the abstract road class and the used road sections. In line 8 a Road called road is constructed and in the following lines different road sections are added to this road:
>>> straight_road = road.append(road_section)
A StraightRoad with the default length of 1 m can be added by calling:
>>> StraightRoad()
StraightRoad(_Transformable__transform=Transform(translation=Vector(0.0, 0.0, 0.0),rotation=Quaternion(1.0, 0.0, 0.0, 0.0)), id=0, is_start=False, left_line_marking='solid', middle_line_marking='dashed', right_line_marking='solid', obstacles=[], traffic_signs=[], surface_markings=[], _speed_limits=[], prev_length=0, length=1)
If you want to pass a different length add the argument length
in the constructor. For example a 2 m long StraightRoad:
>>> StraightRoad(length=2)
StraightRoad(_Transformable__transform=Transform(translation=Vector(0.0, 0.0, 0.0),rotation=Quaternion(1.0, 0.0, 0.0, 0.0)), id=0, is_start=False, left_line_marking='solid', middle_line_marking='dashed', right_line_marking='solid', obstacles=[], traffic_signs=[], surface_markings=[], _speed_limits=[], prev_length=0, length=2)
In the next section you are going to learn how to start the simulation with a custom road.