Roads and Road Sections
Roads
Roads are simple python scripts within simulation/models/env_db.
from simulation.utils.road.road import Road
from simulation.utils.road.sections import *
road = Road()
road.append(StraightRoad()) # Replace with other road sections
- Using python scripts has advantages:
No XML! 🎉 😃
Use standard loops and python math module
Create random roads with python random module
Use environment variables to quickly change the road without editing road files
pre-commit-hook formatting, autocomplete
future: integrate roads as graphs, form closed loops
Road Sections
To create more complex roads a sequence of modular sections is placed one after another.
This simple fact allows creating a large variety of roads using just a few different
simulation.utils.road.sections.
Example: ParkingArea
This is an example of how to create a ParkingArea with two ParkingSpots on the left:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | parking_area = ParkingArea( length=4, start_line=True, left_lots=[ ParkingLot( spots=[ ParkingSpot(kind=ParkingSpot.OCCUPIED, obstacle=ParkingObstacle()), ParkingSpot(kind=ParkingSpot.BLOCKED), ], ), ParkingLot( start=2, opening_angle=math.radians(40), spots=[ ParkingSpot(), ParkingSpot(kind=ParkingSpot.OCCUPIED, obstacle=ParkingObstacle()), ], ), ], right_lots=[ ParkingLot( start=1, depth=0.4, spots=[ ParkingSpot(kind=ParkingSpot.FREE, width=0.5), ParkingSpot( kind=ParkingSpot.OCCUPIED, width=0.7, obstacle=ParkingObstacle() ), ParkingSpot(kind=ParkingSpot.BLOCKED), ], ) ], ) |
Others
- Also available:
Circular arcs, left and right
ZebraCrossing
Intersection (4-way, 3-way, turn straight, left, right, sloping
Bezier curves
Place traffic signs, obstacles and surface markings
StaticObstacle
- Coming soon:
Blocked ParkingArea
TrafficIsland
- Not yet available:
MovingObstacle
Ramp
Pedestrian
See Road Sections for more details.