# add connections to the second junction road, the exit roads[4].add_predecessor(pyodrx.ElementType.road,0,pyodrx.ContactPoint.end,lane_offset=-3) roads[4].add_successor(pyodrx.ElementType.road,2,pyodrx.ContactPoint.start) # add connections to the final road roads[5].add_predecessor(pyodrx.ElementType.junction,2) # add connections to the junctionroad that continues roads[6].add_predecessor(pyodrx.ElementType.road,1,pyodrx.ContactPoint.end) roads[6].add_successor(pyodrx.ElementType.road,5,pyodrx.ContactPoint.start) # add connections to the entry junction road roads[7].add_predecessor(pyodrx.ElementType.road,1,pyodrx.ContactPoint.end,lane_offset=2) roads[7].add_successor(pyodrx.ElementType.road,8,pyodrx.ContactPoint.start) # add connection to the entry road roads[8].add_predecessor(pyodrx.ElementType.junction,2) # create the junction struct exit_junction = pyodrx.create_junction(roads[3:5],1,roads[0:3]) entry_junction = pyodrx.create_junction(roads[6:8],2,[roads[x] for x in [1,5,8]]) # create the opendrive odr = pyodrx.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) # display the road using esmini pyodrx.run_road(odr,os.path.join('..','..','esmini'))
id=4, left_lanes=0, right_lanes=1, road_type=1)) # add some connections to non junction roads roads[0].add_successor(pyodrx.ElementType.junction, 1) roads[1].add_successor(pyodrx.ElementType.junction, 1) roads[2].add_predecessor(pyodrx.ElementType.junction, 1) # add connections to the first connecting road roads[3].add_predecessor(pyodrx.ElementType.road, 0, pyodrx.ContactPoint.end) roads[3].add_successor(pyodrx.ElementType.road, 2, pyodrx.ContactPoint.start) # add connections to the second connecting road with an offset roads[4].add_predecessor(pyodrx.ElementType.road, 1, pyodrx.ContactPoint.end) roads[4].add_successor(pyodrx.ElementType.road, 2, pyodrx.ContactPoint.start, lane_offset=-2) junction = pyodrx.create_junction(roads[3:], 1, roads[0:3]) # create the opendrive odr = pyodrx.OpenDrive('myroad') for r in roads: odr.add_road(r) odr.adjust_roads_and_lanes() odr.add_junction(junction) pyodrx.run_road(odr, os.path.join('..', '..', 'esmini'))
dynamic="no", orientation="+", zOffset=0.00, country="US", Type="R1", subtype="1", value=0.00) signals = pyodrx.Signals() signals.add_signal(signal1) roads.append(pyodrx.create_straight_road(i, signals=signals)) # use this instead to change the number of lanes in the crossing # roads.append(pyodrx.generators.create_straight_road(i, length=100, junction=-1, n_lanes=2, lane_offset=3)) angles.append(i * 2 * np.pi / incoming_roads) # use this for a T-crossing instead # angles = [0,np.pi/2, 3*np.pi/2] print(roads) junc = pyodrx.create_junction_roads(roads, angles, 8) odr = pyodrx.OpenDrive('myroad') junction = pyodrx.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() pyodrx.run_road(odr, os.path.join("..", "pyoscx", "esmini"))