maliput
maliput::utility Namespace Reference

Namespaces

 mesh
 

Classes

struct  GenerateStringOptions
 Parameters that specify what details about an api::RoadGeometry to print. More...
 
struct  Material
 Material information for built meshes. More...
 
struct  ObjFeatures
 Multitude of parameters for generating an OBJ model of a road surface, with sensible defaults. More...
 
struct  RoadGeometryMesh
 
class  ThreadPool
 Creates a pool of threads and a pool of tasks to be executed by the threads simultaneously. More...
 

Enumerations

enum  MaterialType {
  Asphalt, Lane, Marker, HBounds,
  BranchPointGlow, GrayedAsphalt, GrayedLane, GrayedMarker,
  Sidewalk
}
 

Functions

std::string GetSuffixFromPath (const std::string &filepath)
 Extracts the suffix of a file. More...
 
std::vector< std::string > GetAllFilePathsFromDirectory (const std::string &directory_path, const std::optional< std::string > &ends_with_suffix)
 Get all filepaths from a particular directory. More...
 
std::vector< std::string > GetAllPathsFromEnvironment (const std::string &env_var)
 Retrieves a list of paths that live in a environment variable. More...
 
std::pair< mesh::GeoMesh, MaterialBuildMesh (const api::RoadGeometry *rg, const ObjFeatures &features, const api::LaneId &lane_id, const MaterialType &mesh_material)
 Builds a map of meshes based on features properties and the RoadGeometry. More...
 
std::pair< mesh::GeoMesh, MaterialBuildMesh (const api::RoadGeometry *rg, const ObjFeatures &features, const api::BranchPointId &branch_point_id, const MaterialType &mesh_material)
 Builds a map of meshes based on features properties and the RoadGeometry. More...
 
std::pair< mesh::GeoMesh, MaterialBuildMesh (const api::RoadGeometry *rg, const ObjFeatures &features, const api::SegmentId &segment_id, const MaterialType &mesh_material)
 Builds a map of meshes based on features properties and the RoadGeometry. More...
 
RoadGeometryMesh BuildRoadGeometryMesh (const api::RoadGeometry *rg, const ObjFeatures &features)
 Builds a complete RoadGeometryMesh based on features properties and the RoadGeometry. More...
 
std::map< std::string, std::pair< mesh::GeoMesh, Material > > BuildMeshes (const api::RoadGeometry *road_geometry, const ObjFeatures &features)
 Builds a map of meshes based on features properties and the api::RoadGeometry. More...
 
std::map< std::string, std::pair< mesh::GeoMesh, Material > > BuildMeshes (const api::RoadNetwork *road_network, const ObjFeatures &features)
 Builds a map of meshes based on features properties and the api::RoadNetwork. More...
 
void GenerateObjFile (const api::RoadGeometry *road_geometry, const std::string &dirpath, const std::string &fileroot, const ObjFeatures &features)
 Generates a Wavefront OBJ model of the road surface of an api::RoadGeometry. More...
 
void GenerateObjFile (const api::RoadNetwork *road_network, const std::string &dirpath, const std::string &fileroot, const ObjFeatures &features)
 Generates a Wavefront OBJ model of the road surface of an api::RoadNetwork. More...
 
const MaterialGetMaterialByName (const std::string &material_name)
 Gets a Material based on material_name key. More...
 
std::string GenerateString (const api::RoadGeometry &road_geometry, const GenerateStringOptions &options)
 Generates and returns a string containing details about the provided api::RoadGeometry. More...
 
void GenerateUrdfFile (const api::RoadGeometry *road_geometry, const std::string &dirpath, const std::string &fileroot, const ObjFeatures &features)
 Generates a URDF file which models the road surface of an api::RoadGeometry. More...
 
std::unordered_set< const api::Segment * > FindConfluentSegments (const api::Segment *seed_segment)
 Finds all Segments connected to seed_segment via confluent Lanes. More...
 
std::vector< std::unordered_set< const api::Segment * > > AnalyzeConfluentSegments (const api::RoadGeometry *road_geometry)
 Analyzes how Segments in road_geometry are connected via confluency of their Lanes at BranchPoints. More...
 
std::string to_str (double value, int precision)
 Converts a double to a string with the specified precision. More...
 
Material GetMaterialFromMesh (const MaterialType mesh_material)
 

Enumeration Type Documentation

◆ MaterialType

enum MaterialType
strong
Enumerator
Asphalt 
Lane 
Marker 
HBounds 
BranchPointGlow 
GrayedAsphalt 
GrayedLane 
GrayedMarker 
Sidewalk 

Function Documentation

◆ AnalyzeConfluentSegments()

std::vector< std::unordered_set< const api::Segment * > > AnalyzeConfluentSegments ( const api::RoadGeometry road_geometry)

Analyzes how Segments in road_geometry are connected via confluency of their Lanes at BranchPoints.

Two Lanes which are confluent at a BranchPoint necessarily overlap near the BranchPoint, so the Segments which own those Lanes ought to belong to a common Junction. The output of this function is thus a lower-bound for how Segments should be grouped together into Junctions, which can be used for verifying or synthesizing (approximately) the Junction structure. (This function will not detect Lanes which have overlapping geometries independent of their BranchPoints.)

Returns
the set of connected components of Segments, as a vector of unordered_sets. The ordering of the components in the vector is arbitrary. Each Segment in road_geometry shall belong to exactly one component.

◆ BuildMesh() [1/3]

std::pair< mesh::GeoMesh, Material > BuildMesh ( const api::RoadGeometry rg,
const ObjFeatures features,
const api::BranchPointId branch_point_id,
const MaterialType mesh_material 
)

Builds a map of meshes based on features properties and the RoadGeometry.

Parameters
rgThe api::RoadGeometry to model.
featuresParameters for constructing the mesh.
branch_point_idThe ID of the api::BranchPoint to model.
mesh_materialThe material to use for the api::BranchPoint.
Returns
A pair with of a mesh and the corresponding material

◆ BuildMesh() [2/3]

std::pair< mesh::GeoMesh, Material > BuildMesh ( const api::RoadGeometry rg,
const ObjFeatures features,
const api::LaneId lane_id,
const MaterialType mesh_material 
)

Builds a map of meshes based on features properties and the RoadGeometry.

Parameters
rgthe api::RoadGeometry to model.
featuresParameters for constructing the mesh.
lane_idThe ID of the api::Lane to model.
mesh_materialThe material to use for the api::Lane.
Returns
A pair with of a mesh and the corresponding material
Exceptions
ifmesh_material is not one of Lane's valid mesh materials

◆ BuildMesh() [3/3]

std::pair< mesh::GeoMesh, Material > BuildMesh ( const api::RoadGeometry rg,
const ObjFeatures features,
const api::SegmentId segment_id,
const MaterialType mesh_material 
)

Builds a map of meshes based on features properties and the RoadGeometry.

Parameters
rgThe api::RoadGeometry to model.
featuresParameters for constructing the mesh.
segment_idThe ID of the api::Segment to model.
mesh_materialThe material to use for the api::Segment.
Returns
A pair with of a mesh and the corresponding material
Exceptions
ifmesh_material is not one of Segment's valid mesh materials

◆ BuildMeshes() [1/2]

std::map< std::string, std::pair< mesh::GeoMesh, Material > > BuildMeshes ( const api::RoadGeometry road_geometry,
const ObjFeatures features 
)

Builds a map of meshes based on features properties and the api::RoadGeometry.

Parameters
road_geometryThe api::RoadGeometry to model.
featuresParameters for constructing the mesh.
Returns
A map with the meshes. Keys will be std::string objects in the following list:
  • asphalt
  • lane
  • marker
  • h_bounds
  • branch_point
  • grayed_asphalt
  • grayed_lane
  • grayed_marker
  • sidewalk

◆ BuildMeshes() [2/2]

std::map< std::string, std::pair< mesh::GeoMesh, Material > > BuildMeshes ( const api::RoadNetwork road_network,
const ObjFeatures features 
)

Builds a map of meshes based on features properties and the api::RoadNetwork.

Rules in the api::RoadRulebook will be used to change the direction of the of the lanes and the type of lanes when that information is available.

Parameters
road_networkThe api::RoadNetwork to model.
featuresParameters for constructing the mesh.
Returns
A map with the meshes. Keys will be std::string objects in the following list:
  • asphalt
  • lane
  • marker
  • h_bounds
  • branch_point
  • grayed_asphalt
  • grayed_lane
  • grayed_marker
  • sidewalk
Exceptions
maliput::common::assertion_errorWhen road_geometry is nullptr.

◆ BuildRoadGeometryMesh()

RoadGeometryMesh BuildRoadGeometryMesh ( const api::RoadGeometry rg,
const ObjFeatures features 
)

Builds a complete RoadGeometryMesh based on features properties and the RoadGeometry.

Parameters
rgthe api::RoadGeometry to model.
featuresparameters for constructing the mesh.
Returns
A RoadGeometryMesh with all segment, lane, and branch point meshes
Exceptions
ifmesh_material is not one of BranchPoint's valid mesh materials

◆ FindConfluentSegments()

std::unordered_set< const api::Segment * > FindConfluentSegments ( const api::Segment seed_segment)

Finds all Segments connected to seed_segment via confluent Lanes.

This function performs a breadth-first search over the graph of Segments, Lanes, and BranchPoints originating at seed_segment. It does not explore any other elements and does not require these elements to have valid ownership pointers upwards to Junctions or to a RoadGeometry.

Returns
an unordered_set of Segments connected to seed_segment, including seed_segment itself.

◆ GenerateObjFile() [1/2]

void GenerateObjFile ( const api::RoadGeometry road_geometry,
const std::string &  dirpath,
const std::string &  fileroot,
const ObjFeatures features 
)

Generates a Wavefront OBJ model of the road surface of an api::RoadGeometry.

Parameters
road_geometrythe api::RoadGeometry to model
dirpathdirectory component of the output pathnames
filerootroot of the filename component of the output pathnames
featuresparameters for constructing the mesh

GenerateObjFile actually produces two files: the first, named [dirpath]/[fileroot].obj, is a Wavefront OBJ containing the mesh which models the api::RoadGeometry. The second file is a Wavefront MTL file named [dirpath]/[fileroot].mtl, containing descriptions of materials referenced by the OBJ file.

The produced mesh covers the area within the segment-bounds of the road surface described by the RoadGeometry.

Exceptions
maliput::common::assertion_errorWhen road_geometry is nullptr.
maliput::common::assertion_errorWhen road_geometry->linear_tolerance() is zero.

◆ GenerateObjFile() [2/2]

void GenerateObjFile ( const api::RoadNetwork road_network,
const std::string &  dirpath,
const std::string &  fileroot,
const ObjFeatures features 
)

Generates a Wavefront OBJ model of the road surface of an api::RoadNetwork.

Rules in the api::RoadRulebook will be used to change the direction of the lanes and the type of lanes when that information is available.

Parameters
road_networkThe api::RoadNetwork to model.
dirpathDirectory component of the output pathnames.
filerootRoot of the filename component of the output pathnames.
featuresParameters for constructing the mesh.

GenerateObjFile actually produces two files: the first, named [dirpath]/[fileroot].obj, is a Wavefront OBJ containing the mesh which models the api::RoadNetwork. The second file is a Wavefront MTL file named [dirpath]/[fileroot].mtl, containing descriptions of materials referenced by the OBJ file.

The produced mesh covers the area within the segment-bounds of the road surface described by the road_network->road_geometry().

Exceptions
maliput::common::assertion_errorWhen road_network is nullptr.

◆ GenerateString()

std::string GenerateString ( const api::RoadGeometry road_geometry,
const GenerateStringOptions options 
)

Generates and returns a string containing details about the provided api::RoadGeometry.

Parameters
road_geometryThe api::RoadGeometry.
optionsOptions that affect the types of information to include in the returned string.
Returns
The generated string.

◆ GenerateUrdfFile()

void GenerateUrdfFile ( const api::RoadGeometry road_geometry,
const std::string &  dirpath,
const std::string &  fileroot,
const ObjFeatures features 
)

Generates a URDF file which models the road surface of an api::RoadGeometry.

Parameters
road_geometrythe api::RoadGeometry to model
dirpathdirectory component of the output pathnames
filerootroot of the filename component of the output pathnames
featuresparameters for constructing the mesh

GenerateUrdfFile() actually produces three files:

  • [dirpath]/[fileroot].urdf the URDF file, which is little more than a wrapper for an OBJ file;
  • [dirpath]/[fileroot].obj a Wavefront OBJ file containing the visual mesh which models the surface;
  • [dirpath]/[fileroot].mtl a Wavefront MTL file describing the materials referenced by the OBJ file.

The produced mesh covers the area within the lane-bounds of every api::Lane in the RoadGeometry.

◆ GetAllFilePathsFromDirectory()

std::vector< std::string > GetAllFilePathsFromDirectory ( const std::string &  directory_path,
const std::optional< std::string > &  ends_with_suffix 
)

Get all filepaths from a particular directory.

Parameters
directory_pathPath to the directory.
ends_with_suffixWhen it is not nullopt, filepaths must end with the ends_with_suffix value.
Returns
The paths to all the files within directory_path. The returned paths are absolute if the directory_path is an absolute path, otherwise it will return relative paths.

◆ GetAllPathsFromEnvironment()

std::vector< std::string > GetAllPathsFromEnvironment ( const std::string &  env_var)

Retrieves a list of paths that live in a environment variable.

When environment variable isn't set the list will be empty.

Parameters
env_varEnvironemnt variable.
Returns
A list of paths extracted from env_var.

◆ GetMaterialByName()

const Material & GetMaterialByName ( const std::string &  material_name)

Gets a Material based on material_name key.

Possible material_name values may be any of the following:

  • asphalt
  • lane
  • marker
  • h_bounds
  • branch_point
  • grayed_asphalt
  • grayed_lane
  • grayed_marker
  • sidewalk
Parameters
material_nameThe key to get the material.
Returns
A const Material&
Exceptions
std::out_of_rangeif key is not found.

◆ GetMaterialFromMesh()

Material maliput::utility::GetMaterialFromMesh ( const MaterialType  mesh_material)

◆ GetSuffixFromPath()

std::string GetSuffixFromPath ( const std::string &  filepath)

Extracts the suffix of a file.

Parameters
filepathPath to a file.
Returns
The suffix of the file.

◆ to_str()

std::string to_str ( double  value,
int  precision 
)

Converts a double to a string with the specified precision.

Parameters
valueThe double to convert.
precisionThe number of digits after the decimal point.
Returns
The string representation of the double.