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

Adds base RoadNetwork/RoadGeometry Rust API. #32

Merged

Conversation

francocipollone
Copy link
Contributor

🎉 New feature

Related to #30 #31

Summary

Adds Rust API for a minor part of the maliput::api::RoadNetwork/RoadGeometry (cpp) interface.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if it affects the public API)

@francocipollone
Copy link
Contributor Author

@agalbachicar Note that this case for the RoadNetwork and RoadGeometry is probably not the one that is related to the F2F talk about rust vs cpp ownership and heap allocation
In this case we have a road network being created in cpp world and we consume from there. Its allocaiton is in the head and managed by the cpp world.
It sounds that therefore makes sense ...:

  • Having a RoadNetwrok (Rust) that has a reference to a cpp binding:
    • UniquePtr<maliput_sys::api::ffi::RoadNetwork>
  • And having a RoadGeometry (rust) using a reference to the RoadGeometry cpp binding:
    • &maliput_sys::api::ffi::RoadGeometry

A different case happens with simpler structs/classes like LanePosition or InertialPosition. In those cases, having a cpp heap allocation sounds wrong and it is where I should narrow down the search for investigating that use case.

Copy link
Contributor Author

@francocipollone francocipollone Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could bring the xodr files from the maliput_malidrive binary installation. However I do think that from the Rust API perspective makes sense to have XODR files in the package. Otherwise the source files might be hard to follow:

  • maliput(rust) -> maliput-sdk -> maliput(bazel) -> maliput (repo where the xodr files' src code are located)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to simplify now, but with a TODO.
I think we should not repeat resources and expose a variable to installed resources through the bindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#33

agalbachicar
agalbachicar previously approved these changes Mar 5, 2024
Copy link
Contributor

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 42 to 44
let mut properties = HashMap::new();
properties.insert("road_geometry_id", "my_rg_from_rust");
properties.insert("opendrive_file", xodr_path.as_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut properties = HashMap::new();
properties.insert("road_geometry_id", "my_rg_from_rust");
properties.insert("opendrive_file", xodr_path.as_str());
let road_network_properties = HashMap::from([("road_geometry_id", "my_rg_from_rust"), ("opendrive_file", xodr_path.as_str())]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 31 to 32
use maliput::api::RoadNetwork;
use std::collections::HashMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move these inside the main function, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Franco Cipollone <[email protected]>
Copy link
Contributor

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@francocipollone francocipollone merged commit c8b4eef into main Mar 5, 2024
3 checks passed
@francocipollone francocipollone deleted the francocipollone/add_basic_rust_api_for_road_geometry branch March 5, 2024 12:17
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

Successfully merging this pull request may close these issues.

2 participants