예제 #1
0
    def road(self, **kwargs):

        road = xodr.create_road([
            xodr.Spiral(0.0000000001, kwargs['road_curvature'], 100),
            xodr.Arc(kwargs['road_curvature'], 50),
            xodr.Spiral(kwargs['road_curvature'], 0.0000000001, 100),
            xodr.Line(100)
        ],
                                id=0,
                                left_lanes=2,
                                right_lanes=2)
        odr = xodr.OpenDrive('myroad')
        odr.add_road(road)
        odr.adjust_roads_and_lanes()
        return odr
예제 #2
0
# add two geometries based on exact position
planview.add_fixed_geometry(xodr.Line(100), 0, 0, 0)
planview.add_fixed_geometry(xodr.Arc(0.01, length=100), 100, 0, 0)

# create simple lanes
lanes = xodr.Lanes()
lanesection1 = xodr.LaneSection(0, xodr.standard_lane())
lanesection1.add_left_lane(xodr.standard_lane(rm=xodr.STD_ROADMARK_SOLID))
lanesection1.add_right_lane(xodr.standard_lane(rm=xodr.STD_ROADMARK_SOLID))
lanes.add_lanesection(lanesection1)

road1 = xodr.Road(0, planview, lanes)

# create a simple second road for connection
road2 = xodr.create_road(xodr.Line(100), 1)

# connect the roads with successor/predecessor
road1.add_successor(xodr.ElementType.road, 1, xodr.ContactPoint.start)
road2.add_predecessor(xodr.ElementType.road, 0, xodr.ContactPoint.end)

odr = xodr.OpenDrive('my_road')
odr.add_road(road1)
odr.add_road(road2)

# will adjust the second road and the lanes and lane links correctly
odr.adjust_roads_and_lanes()

odr.write_xml(os.path.basename(__file__).replace('.py', '.xodr'))

# uncomment the following lines to display the road using esmini
예제 #3
0
lanelinker.add_link(predlane=lane1,succlane=lane3)
lanelinker.add_link(predlane=lane2,succlane=lane5)
lanelinker.add_link(predlane=lane3,succlane=lane6)
lanelinker.add_link(predlane=lane4,succlane=lane7)

# create the lanes with the correct links
lanes = xodr.Lanes()
lanes.add_lanesection(lanesec1,lanelinker)
lanes.add_lanesection(lanesec2,lanelinker)
lanes.add_lanesection(lanesec3,lanelinker)

# create the road
roads.append(xodr.Road(0,planview,lanes))

# create the other roads
roads.append(xodr.create_road(xodr.Line(100),id =1,left_lanes=0,right_lanes=2))
roads.append(xodr.create_road(xodr.Line(100),id =2,left_lanes=0,right_lanes=1))
# create the junction roads
roads.append(xodr.create_road(xodr.Spiral(0.001,0.02,30),id =3,left_lanes=0,right_lanes=2,road_type=1))
roads.append(xodr.create_road(xodr.Spiral(-0.001,-0.02,30),id =4,left_lanes=0,right_lanes=1,road_type=1))

# add predecessors and succesors to the non junction roads
roads[0].add_successor(xodr.ElementType.junction,1)
roads[1].add_predecessor(xodr.ElementType.junction,1)
roads[2].add_predecessor(xodr.ElementType.junction,1)

# add connections to the first junction road
roads[3].add_predecessor(xodr.ElementType.road,0,xodr.ContactPoint.end)
roads[3].add_successor(xodr.ElementType.road,1,xodr.ContactPoint.start)

# add connections to the second junction road, together with an offset
예제 #4
0
from scenariogeneration import xodr
import os

# create some simple roads
roads = []
# start road
roads.append(
    xodr.create_road([
        xodr.Spiral(-0.004, 0.00001, 100),
        xodr.Spiral(0.00001, 0.005, 50),
        xodr.Arc(0.005, 50)
    ],
                     id=0,
                     left_lanes=3,
                     right_lanes=4))
# intermittent road
roads.append(
    xodr.create_road(
        [xodr.Spiral(0.0001, 0.003, 65),
         xodr.Spiral(0.003, 0.00001, 50)],
        id=1,
        left_lanes=3,
        right_lanes=3))

#exit road
roads.append(xodr.create_road(xodr.Line(50), id=2, left_lanes=0,
                              right_lanes=1))
# junctions for exit
roads.append(
    xodr.create_road(xodr.Spiral(0.005, 0.0001, 50),
                     id=3,