Ejemplo n.º 1
0
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
roads[4].add_predecessor(xodr.ElementType.road,0,xodr.ContactPoint.end,lane_offset=-2)
roads[4].add_successor(xodr.ElementType.road,2,xodr.ContactPoint.start)

# create the junction struct 
junction = xodr.create_junction(roads[3:],1,roads[0:3])

# create the opendrive
odr = xodr.OpenDrive('myroad')
for r in roads:
    odr.add_road(r)
odr.adjust_roads_and_lanes()
odr.add_junction(junction)

# write the OpenDRIVE file as xodr using current script name
odr.write_xml(os.path.basename(__file__).replace('.py','.xodr'))

# uncomment the following lines to display the road using esmini
#from scenariogeneration import esmini
#esmini(odr,os.path.join('esmini'))
Ejemplo n.º 2
0
numintersections = 4  # 3 or 4
angles = []
for i in range(numintersections):
    roads.append(xodr.create_straight_road(i))
    # use this instead to change the number of lanes in the crossing
    #roads.append(xodr.generators.create_straight_road(i, length=100, junction=-1, n_lanes=2, lane_offset=3))
    angles.append(i * 2 * np.pi / numintersections)

# use this for a T-crossing instead
# angles = [0,np.pi/2, 3*np.pi/2]

print(roads)
junc = xodr.create_junction_roads(roads, angles, 8)

odr = xodr.OpenDrive('myroad')
junction = xodr.create_junction(junc, 1, roads)

odr.add_junction(junction)
for r in roads:
    odr.add_road(r)
for j in junc:
    odr.add_road(j)

odr.adjust_roads_and_lanes()

# write the OpenDRIVE file as xodr using current script name
odr.write_xml(os.path.basename(__file__).replace('.py', '.xodr'))

# uncomment the following lines to display the road using esmini
#from scenariogeneration import esmini
#esmini(odr,os.path.join('esmini'))
Ejemplo n.º 3
0
# add connections to the junctionroad that continues
roads[6].add_predecessor(xodr.ElementType.road, 1, xodr.ContactPoint.end)
roads[6].add_successor(xodr.ElementType.road, 5, xodr.ContactPoint.start)

# add connections to the entry junction road
roads[7].add_predecessor(xodr.ElementType.road,
                         1,
                         xodr.ContactPoint.end,
                         lane_offset=2)
roads[7].add_successor(xodr.ElementType.road, 8, xodr.ContactPoint.start)

# add connection to the entry road
roads[8].add_predecessor(xodr.ElementType.junction, 2)

# create the junction struct
exit_junction = xodr.create_junction(roads[3:5], 1, roads[0:3])
entry_junction = xodr.create_junction(roads[6:8], 2,
                                      [roads[x] for x in [1, 5, 8]])
# create the opendrive
odr = xodr.OpenDrive('myroad')
for r in roads:
    odr.add_road(r)
odr.adjust_roads_and_lanes()
odr.add_junction(exit_junction)
odr.add_junction(entry_junction)

# write the OpenDRIVE file as xodr using current script name
odr.write_xml(os.path.basename(__file__).replace('.py', '.xodr'))

# uncomment the following lines to display the road using esmini
#from scenariogeneration import esmini