ed
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ed::models::ModelLoader Class Reference

#include <model_loader.h>

Public Member Functions

bool create (const tue::config::DataConstPointer &data, const UUID &id_opt, const UUID &parent_id, UpdateRequest &req, std::stringstream &error, const std::string &model_path="", const geo::Pose3D &pose_offset=geo::Pose3D::identity())
 create add entity to update_request from config data. More...
 
bool create (const tue::config::DataConstPointer &data, UpdateRequest &req, std::stringstream &error)
 create add entity to update_request from config data. "_root" will be used as id. More...
 
bool create (const UUID &id, const std::string &type, UpdateRequest &req, std::stringstream &error, const bool allow_sdf=false)
 create add entity to update_request with id 'id' of the type 'type'. If allow_sdf is true, also sdf models are considered. Otherwise only ED yaml models are used. More...
 
bool createSDF (const tue::config::DataConstPointer &data, const UUID &parent_id, const geo::Pose3D &parent_pose, const UUID &id_override, const boost::shared_ptr< const geo::Pose3D > pose_override, UpdateRequest &req, std::stringstream &error)
 createSDF add SDF entity to update_request from config data. More...
 
bool exists (const std::string &type) const
 exists Check of a model of type 'type' exist More...
 
 ModelLoader ()
 
 ~ModelLoader ()
 

Private Types

typedef std::pair< tue::config::DataConstPointer, std::vector< std::string > > ModelData
 

Private Member Functions

std::string getModelPath (const std::string &type) const
 getModelPath get file path of model of type 'type' More...
 
std::string getSDFPath (const std::string &uri) const
 getSDFPath get file path of SDF model with uri 'uri' More...
 
tue::config::DataConstPointer loadModelData (std::string type, std::vector< std::string > &types, std::stringstream &error, const bool allow_sdf=false)
 loadModelData load data of model of type 'type' More...
 
tue::config::DataConstPointer loadSDFData (std::string uri, std::stringstream &error)
 loadSDFData load data of SDF model of uri 'uri' More...
 
ModelData readModelCache (std::string type) const
 readModelCache read the model cache, which contains the data and all types More...
 

Private Attributes

std::vector< std::stringed_model_paths_
 
std::vector< std::stringfile_paths_
 
std::map< std::string, ModelDatamodel_cache_
 
std::vector< std::stringmodel_paths_
 
std::map< std::string, geo::ShapePtrshape_cache_
 

Detailed Description

Definition at line 18 of file model_loader.h.

Member Typedef Documentation

◆ ModelData

Definition at line 87 of file model_loader.h.

Constructor & Destructor Documentation

◆ ModelLoader()

ed::models::ModelLoader::ModelLoader ( )

Definition at line 51 of file model_loader.cpp.

◆ ~ModelLoader()

ed::models::ModelLoader::~ModelLoader ( )

Definition at line 78 of file model_loader.cpp.

Member Function Documentation

◆ create() [1/3]

bool ed::models::ModelLoader::create ( const tue::config::DataConstPointer data,
const UUID id_opt,
const UUID parent_id,
UpdateRequest req,
std::stringstream error,
const std::string model_path = "",
const geo::Pose3D pose_offset = geo::Pose3D::identity() 
)

create add entity to update_request from config data.

Parameters
datashould contain the right data and should be at the correct reading point
id_optOptional id, if no id in data
parent_idprefix to id, unless starting with "_"
reqUpdateRequest to 'fill'
errorerror stream
model_pathpath where the data is read. Is used for relative paths in the data
pose_offsetpose offset, if no pose in data, this pose will be the final pose.
Returns
bool, which indicates succes

Definition at line 329 of file model_loader.cpp.

◆ create() [2/3]

bool ed::models::ModelLoader::create ( const tue::config::DataConstPointer data,
UpdateRequest req,
std::stringstream error 
)

create add entity to update_request from config data. "_root" will be used as id.

Parameters
datashould contain the right data and should be at the correct reading point
reqUpdateRequest to 'fill'
errorerror stream
Returns
bool, which indicates succes

Definition at line 322 of file model_loader.cpp.

◆ create() [3/3]

bool ed::models::ModelLoader::create ( const UUID id,
const std::string type,
UpdateRequest req,
std::stringstream error,
const bool  allow_sdf = false 
)

create add entity to update_request with id 'id' of the type 'type'. If allow_sdf is true, also sdf models are considered. Otherwise only ED yaml models are used.

Parameters
idnew id of the entity
typetype of the entity
reqUpdateRequest to 'fill'
errorerror stream
allow_sdfAllow SDF models, or only ED yaml models
Returns
bool, which indicates succes

Definition at line 285 of file model_loader.cpp.

◆ createSDF()

bool ed::models::ModelLoader::createSDF ( const tue::config::DataConstPointer data,
const UUID parent_id,
const geo::Pose3D parent_pose,
const UUID id_override,
const boost::shared_ptr< const geo::Pose3D pose_override,
UpdateRequest req,
std::stringstream error 
)

createSDF add SDF entity to update_request from config data.

Parameters
datashould contain the right data and should be at the correct reading point
parent_idprefix to id, unless starting with "_"
parent_posepose offset which will always be applied
id_overrideif not empty, this will override the id of the model
pose_overrideif not empty, this will override the pose of the model
reqUpdateRequest to 'fill'
errorerror stream
Returns
bool, which indicates succes

Definition at line 466 of file model_loader.cpp.

◆ exists()

bool ed::models::ModelLoader::exists ( const std::string type) const

exists Check of a model of type 'type' exist

Parameters
typemodel type
Returns
bool, which indicates of type exist

Definition at line 264 of file model_loader.cpp.

◆ getModelPath()

std::string ed::models::ModelLoader::getModelPath ( const std::string type) const
private

getModelPath get file path of model of type 'type'

ModelLoader::getModelPath.

Parameters
typetype of the model
Returns
path of the model, empty if model not found
Parameters
typetype
Returns
The full path or empty string, if not found

Definition at line 90 of file model_loader.cpp.

◆ getSDFPath()

std::string ed::models::ModelLoader::getSDFPath ( const std::string uri) const
private

getSDFPath get file path of SDF model with uri 'uri'

Parameters
uriuri of the model
Returns
path of the model, empty if model not found

Definition at line 104 of file model_loader.cpp.

◆ loadModelData()

tue::config::DataConstPointer ed::models::ModelLoader::loadModelData ( std::string  type,
std::vector< std::string > &  types,
std::stringstream error,
const bool  allow_sdf = false 
)
private

loadModelData load data of model of type 'type'

Parameters
typetype of the model
typesvector of model types for recursive inheritance
errorerror stream
allow_sdfAllow SDF models, or only ED yaml models
Returns
DataConstPointer with the data, empty in case of error

Definition at line 156 of file model_loader.cpp.

◆ loadSDFData()

tue::config::DataConstPointer ed::models::ModelLoader::loadSDFData ( std::string  uri,
std::stringstream error 
)
private

loadSDFData load data of SDF model of uri 'uri'

Parameters
uriuri of the model
errorerror stream
Returns
DataConstPointer with the data, empty in case of error

Definition at line 225 of file model_loader.cpp.

◆ readModelCache()

ModelLoader::ModelData ed::models::ModelLoader::readModelCache ( std::string  type) const
private

readModelCache read the model cache, which contains the data and all types

Parameters
typetype of the model to look for
Returns
ModelData, DataPointer is empty in case type not in cache

Definition at line 143 of file model_loader.cpp.

Member Data Documentation

◆ ed_model_paths_

std::vector<std::string> ed::models::ModelLoader::ed_model_paths_
private

Definition at line 96 of file model_loader.h.

◆ file_paths_

std::vector<std::string> ed::models::ModelLoader::file_paths_
private

Definition at line 98 of file model_loader.h.

◆ model_cache_

std::map<std::string, ModelData> ed::models::ModelLoader::model_cache_
private

Definition at line 90 of file model_loader.h.

◆ model_paths_

std::vector<std::string> ed::models::ModelLoader::model_paths_
private

Definition at line 97 of file model_loader.h.

◆ shape_cache_

std::map<std::string, geo::ShapePtr> ed::models::ModelLoader::shape_cache_
private

Definition at line 93 of file model_loader.h.


The documentation for this class was generated from the following files: