Closed jiaoL06 closed 7 months ago
the red marked as reference line,how to link the green road with other roads, the predecessor can add by:
road.add_predecessor(xodr.ElementType.road, pre_roadid, xodr.ContactPoint.end, 1) ##offset=1,
but the successor road can not link correctlly, how to link with :
road.add_successor(xodr.ElementType.road, suc_roadid, xodr.ContactPoint.start, offset), how to set the offset? successor laneid is 1.
do you plan for this to be a junction?
do you plan for this to be a junction?
Can't it be directly linked?
not if you want all "empty" lanes to endup somehwere..
from scenariogeneration import xodr, esmini
road1 = xodr.create_road(xodr.Line(100),1,1,2)
road2 = xodr.create_road(xodr.Line(100),2,0,1)
road3 = xodr.create_road(xodr.Line(100),3,1,1)
road1.add_successor(xodr.ElementType.junction, 100)
road2.add_predecessor(xodr.ElementType.junction, 100)
road2.add_successor(xodr.ElementType.junction, 200)
road3.add_successor(xodr.ElementType.junction, 200)
junc1 = xodr.DirectJunctionCreator(100,"my_junction")
junc1.add_connection(road1, road2, -2, -1)
junc2 = xodr.DirectJunctionCreator(200,"my_junction")
junc2.add_connection(road2,road3,-1,1)
odr = xodr.OpenDrive('my road')
odr.add_road(road1)
odr.add_road(road2)
odr.add_road(road3)
odr.add_junction_creator(junc1)
odr.add_junction_creator(junc2)
odr.adjust_roads_and_lanes()
rather easy to do with direction junctions, however the last link cannot be done as you showed since it will break the driving direction.
from scenariogeneration import xodr, esmini road1 = xodr.create_road(xodr.Line(100),1,1,2) road2 = xodr.create_road(xodr.Line(100),2,0,1) road3 = xodr.create_road(xodr.Line(100),3,1,1) road1.add_successor(xodr.ElementType.junction, 100) road2.add_predecessor(xodr.ElementType.junction, 100) road2.add_successor(xodr.ElementType.junction, 200) road3.add_successor(xodr.ElementType.junction, 200) junc1 = xodr.DirectJunctionCreator(100,"my_junction") junc1.add_connection(road1, road2, -2, -1) junc2 = xodr.DirectJunctionCreator(200,"my_junction") junc2.add_connection(road2,road3,-1,1) odr = xodr.OpenDrive('my road') odr.add_road(road1) odr.add_road(road2) odr.add_road(road3) odr.add_junction_creator(junc1) odr.add_junction_creator(junc2) odr.adjust_roads_and_lanes()
rather easy to do with direction junctions, however the last link cannot be done as you showed since it will break the driving direction.
Thank you for your suggestion. It will generate junctions here.
Yes, scenariogeneration tries not to create too messed up stuffs and linking road with different amount of lanes is one thing that it doesn't like :P so there junctions has to be added. But not much more python-code here to create what you want :)
Good luck