pageldev / libOpenDRIVE

Small, lightweight C++ library for handling OpenDRIVE files
Apache License 2.0
388 stars 136 forks source link

Generating 90 degree angle on adjacent lanes with different lane heights #93

Open ge25bec opened 10 months ago

ge25bec commented 10 months ago

Fixes issue #92

It seems the problem is that Road::get_surface_pt uses LaneSection::get_lane_id, which doesn't take a height parameter. For a point on the border of two lanes, the method will always create a vertex with the outer height of the inner lane. I changed Road::get_lane_mesh so it now generates another vertex, which has the inner height of the outer lane and is linked in the mesh accordingly.

ge25bec commented 10 months ago

I also added a fix for situations like this:

generated in the Online OpenDRIVE viewer with this .xodr file

<?xml version="1.0" standalone="yes"?>
<OpenDRIVE>
    <header revMajor="1" revMinor="4" name="" version="1.00" date="Wed Jul  1 07:28:45 2020" north="0.0" south="0.0" east="0.0" west="0.0">
    </header>
    <road name="test road" length="2.0000000000000000e+02" id="0" junction="-1">
        <link>
        </link>
        <planView>
            <geometry s="0.0000000000000000e+00" x="0.0000000000000000e+00" y="0.0000000000000000e+00" hdg="0.0000000000000000e+00" length="1.0000000000000000e+02">
                <line/>
            </geometry>
            <geometry s="1.0000000000000000e+02" x="1.0000000000000000e+02" y="0.0000000000000000e+00" hdg="0.0000000000000000e+00" length="1.0000000000000000e+02">
                <arc curvature="0.02"/>
            </geometry>
        </planView>
        <lateralProfile>
        </lateralProfile>
        <lanes>
            <laneSection s="0">
                <left>
                    <lane id="1" type="driving" level= "false">
                        <link>
                        </link>
                        <width sOffset="0.0" a="3.0" b="0.0" c="0.0" d="0.0"/>
                    </lane>
                </left>
                <center>
                    <lane id="0" type="driving" level= "false">
                        <link>
                        </link>
                    </lane>
                </center>
                <right>
                    <lane id="-1" type="driving" level= "false">
                        <link>
                        </link>
                        <width sOffset="0.0" a="3.0" b="0.0" c="0.0" d="0.0"/>                     
                    </lane>
                    <lane id="-2" type="driving" level= "false">
                        <link>
                        </link>
                        <width sOffset="0.0" a="3.0" b="0.0" c="0.0" d="0.0"/>                     
                    </lane>
                    <lane id="-3" type="curb" level= "false">
                        <link>
                        </link>
                        <width sOffset="0.0" a="2.5" b="0.0" c="0.0" d="0.0"/>
                        <height sOffset="0.0" inner="0.0" outer="0.0"/>
                        <height sOffset="25.0" inner="1.0" outer="1.0"/>
                    </lane>
                    <lane id="-4" type="border" level= "false">
                        <link>
                        </link>
                        <width sOffset="0.0" a="5.0" b="0.0" c="0.0" d="0.0"/>
                    </lane>
                </right>
            </laneSection>
        </lanes>
        <objects/>     
        <signals/>
        <surface/>
    </road>
</OpenDRIVE>

where the inner lane has multiple height offsets different from the outer lane. Now the outer lane also generates vertices at the s_to_height_offset values from the inner lane and connects to them in the mesh.