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

Adjacent Lanelets with oposite directions #37

Open
francocipollone opened this issue Nov 3, 2022 · 0 comments
Open

Adjacent Lanelets with oposite directions #37

francocipollone opened this issue Nov 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@francocipollone
Copy link
Contributor

francocipollone commented Nov 3, 2022

Context

Lanelets support having different directions for adjacent lanelets (what we could call a maliput:api::Segment), it is achieved by inverting the order of the linestrings, for example for two adjacent lanelets:

A  -------->
B  -------->
C <-------

Lanelet AB's direction is west-east
Lanelet CB's direction is east-west (It is achieved by inverting the B linestring)

For these two lanelets as they have opposite directions, lanelet2 doesn't support passing/driving from one lane to the other.
In our case(maliput_osm), as the code stands, we are considering AB and CB as lanelets that belong to the same direction (as AB), ergo same maliput segment.

Note: Actually we haven't changed anything to do so, the lanelet2's api for getting the right and left boundaries automatically invert the boundaries:

  ConstLineString3d Lanelet::rightBound3d() const {
    return inverted() ? constData()->leftBound().invert() : constData()->rightBound();
  }

Proposal

When parsing the lanelets we should check those linestrings that are inverted and derive a direction usage rule to be AgainstS.

Extra

I leave here just a python script for creating a map using an inverted linestring for the shared linestring.

Click to see script
    map = LaneletMap()
    ls_at_2 = LineString3d(getId(), [Point3d(getId(), i, 2, 0) for i in range(0, 3)]) # y=2
    ls_at_4 = LineString3d(getId(), [Point3d(getId(), i, 4, 0) for i in range(0, 3)]) # y=4
    ls_at_2_inv = ls_at_2.invert()
    ls_at_0 = LineString3d(getId(), [Point3d(getId(), i, 0, 0) for i in range(2, -1, -1)]) # y=0
    lanelet = Lanelet(getId(), ls_at_4, ls_at_2)
    lanelet2 = Lanelet(getId(), ls_at_2_inv, ls_at_0)
    map.add(lanelet)
    map.add(lanelet2)
    path = os.path.join('./mapfile.osm')
    projector = UtmProjector(Origin(0, 0))
    write(path, map, projector)
    mapLoad, errors = loadRobust(path, projector)
    assert not errors
    assert mapLoad.laneletLayer.exists(lanelet.id)

    gotten_lanelet = mapLoad.laneletLayer[lanelet.id]
    gotten_lanelet2 = mapLoad.laneletLayer[lanelet2.id]
    print(gotten_lanelet)
    print("\tleft_bound: " + str(gotten_lanelet.leftBound))
    print("\tright_bound: " + str(gotten_lanelet.rightBound))
    print(gotten_lanelet2)
    print("\tleft_bound: " + str(gotten_lanelet2.leftBound))
    print("\tright_bound: " + str(gotten_lanelet2.rightBound))
@francocipollone francocipollone added the enhancement New feature or request label Nov 3, 2022
@maliput-org maliput-org moved this to 🆕 Inbox in Maliput - Core development Nov 3, 2022
@francocipollone francocipollone moved this from 🆕 Inbox to 📋 ToDo in Maliput - Core development Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 ToDo
Development

No branches or pull requests

1 participant