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 Junction
s, which in turn contain
Segment
s and Lane
s.
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>
impl<'a> RoadGeometry<'a>
Sourcepub fn num_junctions(&self) -> i32
pub fn num_junctions(&self) -> i32
Returns the number of Junctions in the RoadGeometry.
Return value is non-negative.
Sourcepub fn linear_tolerance(&self) -> f64
pub fn linear_tolerance(&self) -> f64
Returns the tolerance guaranteed for linear measurements (positions).
Sourcepub fn angular_tolerance(&self) -> f64
pub fn angular_tolerance(&self) -> f64
Returns the tolerance guaranteed for angular measurements (orientations).
Sourcepub fn num_branch_points(&self) -> i32
pub fn num_branch_points(&self) -> i32
Returns the number of BranchPoints in the RoadGeometry.
Return value is non-negative.
Sourcepub fn to_road_position(
&self,
inertial_position: &InertialPosition,
) -> Result<RoadPositionResult, MaliputError>
pub fn to_road_position( &self, inertial_position: &InertialPosition, ) -> Result<RoadPositionResult, MaliputError>
Determines the RoadPosition corresponding to InertialPosition inertial_position
.
Returns a RoadPositionResult. 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
inertial_position
- The InertialPosition to convert into a RoadPosition.
§Return
A RoadPositionResult with the nearest RoadPosition, the corresponding InertialPosition to that RoadPosition and the distance between the input and output InertialPositions.
Sourcepub fn find_road_positions(
&self,
_inertial_position: &[InertialPosition],
_radius: f64,
) -> Result<Vec<RoadPositionResult>, MaliputError>
pub fn find_road_positions( &self, _inertial_position: &[InertialPosition], _radius: f64, ) -> Result<Vec<RoadPositionResult>, MaliputError>
TODO(#197): Implement find_road_positions 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
inertial_position
- The InertialPosition to search around.radius
- The radius around the InertialPosition to search for RoadPositions.
§Return
A vector of RoadPositionResults.
Sourcepub fn get_lanes(&self) -> Vec<Lane<'_>>
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());
}
Sourcepub fn get_segment(&self, segment_id: &String) -> Option<Segment<'_>>
pub fn get_segment(&self, segment_id: &String) -> Option<Segment<'_>>
Sourcepub fn get_junction(&self, junction_id: &String) -> Option<Junction<'_>>
pub fn get_junction(&self, junction_id: &String) -> Option<Junction<'_>>
Sourcepub fn get_branch_point(
&self,
branch_point_id: &String,
) -> Option<BranchPoint<'_>>
pub fn get_branch_point( &self, branch_point_id: &String, ) -> Option<BranchPoint<'_>>
Sourcepub fn backend_custom_command(
&self,
command: &String,
) -> Result<String, MaliputError>
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.
Sourcepub fn geo_reference_info(&self) -> String
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.