Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when adding connection between the roads in junction scenario #258

Open
Y-1huadb opened this issue Dec 25, 2024 · 3 comments
Open

Comments

@Y-1huadb
Copy link

We are trying to use scenario generation to automatically generate junctions based on the road configuration. However, we discover that even directly use add_connection in the xodr.CommonJunctionCreator will cause the generated map faulty.

The test code is as follows;

...[Irrelevant]
# create 2 roads going into a junction
road1 = xodr.create_road(
    xodr.Line(100),
    1,
    xodr.LaneDef(0, 100, 2, 2, None, [4, 4]),
    xodr.LaneDef(0, 100, 2, 2, None, [4, 4]),
)
road4 = xodr.create_road(
    xodr.Line(100),
    4,
    [xodr.LaneDef(0, 100, 2, 2, None, [4, 4])],
    [xodr.LaneDef(0, 100, 2, 2, None, [4, 4])],
)

# create the connection in the junction
jc = xodr.CommonJunctionCreator(100, "my junc")
jc.add_incoming_road_circular_geometry(
    road1, 50, 0, "successor"
)
jc.add_incoming_road_circular_geometry(
    road4, 50, np.pi, "successor"
)

jc.add_connection(1, 4, [-1, 1], [1, -1])
jc.add_connection(1, 4, [-2, 2], [2, -2])
...[Irrelevant]

But the result we get from this is as follows:
Screenshot from 2024-12-25 23-37-23

The add_connection is even more inaccurate if the incoming roads are more. The vehicles traversing the path will sometimes have strange behaviors. We are using scenariogeneration version 0.14.9. Hope to get feedback on this problem.

@Y-1huadb Y-1huadb changed the title Error when adding connection between the roads. Error when adding connection between the roads in junction scenario Dec 25, 2024
@atingber
Copy link
Collaborator

atingber commented Jan 7, 2025

Hi @Y-1huadb, it is not clear to me what you are trying to do. Can you please provide some picture or further description.
To me this looks like you are simply trying to connect two roads. In that case a solution could be to just use:
jc.add_connection(1,4) instead of

jc.add_connection(1, 4, [-1, 1], [1, -1])
jc.add_connection(1, 4, [-2, 2], [2, -2])

but if this is the intention there is really no need to use a junction at all, see documentation Introduction to junctions

@Y-1huadb
Copy link
Author

Thank you for the suggestion. But we want to create a junction which has a connection between each lane of three roads so that vehicles could change lanes while turning. And it seems vehicles could not change lanes if we directly use jc.add_connection(1,4). So we implement it like jc.add_connection(1, 4, [-1, 1], [1, -1]). The result we get is as follow.

Image

However, this sometimes results in strange maps where some connecting roads are not properly connected to the outgoing roads.

Image

We use add_incoming_road_circular_geometry(road,angle,radius,road_connection) to add roads and ```add_connection(road_one,road_two,lane_one,lane_two) to add connections. However, we find that we will get a different result even if we change the order of the roads. Below are two different results:

Image
Image

The different betweent those two results is we add the road with two right lanes into jc at first or not.

@Y-1huadb
Copy link
Author

Here is the defination of the roads.

        road_1 = xodr.create_road(xodr.Line(100), id = 1, left_lanes=1, right_lanes=2)
        road_2 = xodr.create_road(xodr.Line(100), id = 2, left_lanes=1, right_lanes=1)
        road_3 = xodr.create_road(xodr.Line(100), id = 3, left_lanes=1, right_lanes=1)

The following is the order we add those roads into jc.
[road_1, road_2 ,road_3]

        jc.add_incoming_road_circular_geometry(
                road=road_1,
                angle=PI*0
                radius=50,
                c='successor'
            )
        
        jc.add_incoming_road_circular_geometry(
                road=road_2,
                angle=PI*0.3
                radius=50,
                c='successor'
            )
        
        jc.add_incoming_road_circular_geometry(
                road=road_3,
                angle=PI*0.3
                radius=50,
                c='successor'
            )

The result will change if we define it in a different order.
[road_2, road_1 ,road_3]

        jc.add_incoming_road_circular_geometry(
                road=road_2,
                angle=PI*0
                radius=50,
                c='successor'
            )
        
        jc.add_incoming_road_circular_geometry(
                road=road_1,
                angle=PI*0.3
                radius=50,
                c='successor'
            )
        
        jc.add_incoming_road_circular_geometry(
                road=road_3,
                angle=PI*0.3
                radius=50,
                c='successor'
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants