RoadGeometry

Struct RoadGeometry 

Source
pub struct RoadGeometry<'a> { /* private fields */ }
Expand description

Represents the geometry of a road network.

RoadGeometry is the top-level container for the road network’s geometric description. It is composed of a set of Junctions, which in turn contain Segments and Lanes.

It provides access to the entire road network’s geometric structure, allowing for queries about its components (e.g., finding a Lane by its ID) and for coordinate conversions between the inertial frame and the road network’s intrinsic coordinate systems (lane coordinates).

An instance of RoadGeometry is typically obtained from a RoadNetwork.

More info can be found at https://maliput.readthedocs.io/en/latest/html/deps/maliput/html/maliput_design.html.

§Example of obtaining a RoadGeometry

use maliput::api::RoadNetwork;
use std::collections::HashMap;

let package_location = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let xodr_path = format!("{}/data/xodr/TShapeRoad.xodr", package_location);
let road_network_properties = HashMap::from([("road_geometry_id", "my_rg_from_rust"), ("opendrive_file", xodr_path.as_str())]);
let road_network = RoadNetwork::new("maliput_malidrive", &road_network_properties).unwrap();
let road_geometry = road_network.road_geometry();
println!("RoadGeometry ID: {}", road_geometry.id());

Implementations§

Source§

impl<'a> RoadGeometry<'a>

Source

pub fn id(&self) -> String

Returns the id of the RoadGeometry.

Source

pub fn num_junctions(&self) -> i32

Returns the number of Junctions in the RoadGeometry.

Return value is non-negative.

Source

pub fn linear_tolerance(&self) -> f64

Returns the tolerance guaranteed for linear measurements (positions).

Source

pub fn angular_tolerance(&self) -> f64

Returns the tolerance guaranteed for angular measurements (orientations).

Source

pub fn num_branch_points(&self) -> i32

Returns the number of BranchPoints in the RoadGeometry.

Return value is non-negative.

Source

pub fn to_road_position( &self, inertial_position: &InertialPosition, ) -> Result<RoadPositionQuery, MaliputError>

Determines the RoadPosition on the 3D road manifold that corresponds to InertialPosition inertial_position.

The RoadGeometry’s manifold is a 3D volume, with each point defined by (s, r, h) coordinates. This method returns a RoadPositionQuery. Its RoadPosition is the point in the RoadGeometry’s manifold which is, in the Inertial-frame, closest to inertial_position. Its InertialPosition is the Inertial-frame equivalent of the RoadPosition and its distance is the Cartesian distance from inertial_position to the nearest point.

This method guarantees that its result satisfies the condition that result.lane.to_lane_position(result.pos) is within linear_tolerance() of the returned InertialPosition.

The map from RoadGeometry to the Inertial-frame is not onto (as a bounded RoadGeometry cannot completely cover the unbounded Cartesian universe). If inertial_position does represent a point contained within the volume of the RoadGeometry, then result distance is guaranteed to be less than or equal to linear_tolerance().

The map from RoadGeometry to Inertial-frame is not necessarily one-to-one. Different (s,r,h) coordinates from different Lanes, potentially from different Segments, may map to the same (x,y,z) Inertial-frame location.

If inertial_position is contained within the volumes of multiple Segments, then to_road_position() will choose a Segment which yields the minimum height h value in the result. If the chosen Segment has multiple Lanes, then to_road_position() will choose a Lane which contains inertial_position within its lane_bounds() if possible, and if that is still ambiguous, it will further select a Lane which minimizes the absolute value of the lateral r coordinate in the result.

§Arguments
§Return

A RoadPositionQuery with the nearest RoadPosition, the corresponding InertialPosition to that RoadPosition and the distance between the input and output InertialPositions.

Source

pub fn to_road_position_surface( &self, inertial_position: &InertialPosition, ) -> Result<RoadPosition, MaliputError>

Determines the RoadPosition on the road surface that corresponds to InertialPosition inertial_position.

This method is similar to RoadGeometry::to_road_position, in a way that it determines if inertial_position is within the RoadGeometry’s 3D volume. If it is, a RoadPosition is returned where the height h is set to 0, effectively placing the point on the road surface.

§Arguments
§Return

The corresponding RoadPosition on the road surface or a MaliputError if the inertial_position is not on the road surface (i.e., the distance is greater than linear_tolerance).

§Example
use maliput::api::{RoadNetwork, InertialPosition};
use std::collections::HashMap;

let package_location = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let xodr_path = format!("{}/data/xodr/TShapeRoad.xodr", package_location);
let road_network_properties = HashMap::from([("road_geometry_id", "my_rg_from_rust"), ("opendrive_file", xodr_path.as_str())]);
let road_network = RoadNetwork::new("maliput_malidrive", &road_network_properties).unwrap();
let road_geometry = road_network.road_geometry();

// Although this isn't directly on the surface, it is within the RoadGeometry volume.
let inertial_pos = InertialPosition::new(1.0, 0.0, 1.0);
let road_pos = road_geometry.to_road_position_surface(&inertial_pos);
assert!(road_pos.is_ok());
let road_pos = road_pos.unwrap();
println!("Road position on surface: s={}, r={}, h={}", road_pos.pos().s(), road_pos.pos().r(), road_pos.pos().h());
assert_eq!(road_pos.pos().s(), 1.0);
assert_eq!(road_pos.pos().r(), 0.0);
assert_eq!(road_pos.pos().h(), 0.0);  // h is set to 0.

// An inertial position that is off the road volume.
let inertial_pos= InertialPosition::new(1.0, 0.0, 10.0);
let road_pos= road_geometry.to_road_position_surface(&inertial_pos);
assert!(road_pos.is_err());
Source

pub fn find_road_positions( &self, inertial_position: &InertialPosition, radius: f64, ) -> Result<Vec<RoadPositionQuery>, MaliputError>

Obtains all RoadPositions within a radius of the inertial_position.

Only Lanes whose segment regions include points that are within radius of inertial position are included in the search. For each of these Lanes, include the RoadPosition or RoadPositions with the minimum distance to inertial position in the returned result.

§Arguments
§Return

A vector of RoadPositionQuerys.

Source

pub fn get_lane(&self, lane_id: &String) -> Option<Lane<'_>>

Get the lane matching given lane_id.

§Arguments
  • lane_id - The id of the lane.
§Return

The lane with the given id. If no lane is found with the given id, return None.

Source

pub fn get_lanes(&self) -> Vec<Lane<'_>>

Get all lanes of the RoadGeometry. Returns a vector of Lane.

§Example
use maliput::api::RoadNetwork;
use std::collections::HashMap;

let package_location = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let xodr_path = format!("{}/data/xodr/TShapeRoad.xodr", package_location);
let road_network_properties = HashMap::from([("road_geometry_id", "my_rg_from_rust"), ("opendrive_file", xodr_path.as_str())]);
let road_network = RoadNetwork::new("maliput_malidrive", &road_network_properties).unwrap();
let road_geometry = road_network.road_geometry();
let lanes = road_geometry.get_lanes();
for lane in lanes {
   println!("lane_id: {}", lane.id());
}
Source

pub fn get_segment(&self, segment_id: &String) -> Option<Segment<'_>>

Get the segment matching given segment_id.

§Arguments
  • segment_id - The id of the segment.
§Return

The segment with the given id. If no segment is found with the given id, return None.

Source

pub fn get_junction(&self, junction_id: &String) -> Option<Junction<'_>>

Get the junction matching given junction_id.

§Arguments
  • junction_id - The id of the junction.
§Return

The junction with the given id. If no junction is found with the given id, return None.

Source

pub fn get_branch_point( &self, branch_point_id: &String, ) -> Option<BranchPoint<'_>>

Get the branch point matching given branch_point_id.

§Arguments
  • branch_point_id - The id of the branch point.
§Return

The branch point with the given id. If no branch point is found with the given id, return None.

Source

pub fn backend_custom_command( &self, command: &String, ) -> Result<String, MaliputError>

Execute a custom command on the backend.

§Details

The documentation of the custom command should be provided by the backend: https://github.com/maliput/maliput_malidrive/blob/main/src/maliput_malidrive/base/road_geometry.h

§Arguments
  • command - The command to execute.
§Return

The result of the command.

Source

pub fn geo_reference_info(&self) -> String

Obtains the Geo Reference info of this RoadGeometry.

§Return

A string containing the Geo Reference projection, if any.

Auto Trait Implementations§

§

impl<'a> Freeze for RoadGeometry<'a>

§

impl<'a> RefUnwindSafe for RoadGeometry<'a>

§

impl<'a> !Send for RoadGeometry<'a>

§

impl<'a> !Sync for RoadGeometry<'a>

§

impl<'a> Unpin for RoadGeometry<'a>

§

impl<'a> UnwindSafe for RoadGeometry<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.