ed
model_loader.h
Go to the documentation of this file.
1 #ifndef ED_MODEL_LOADER_H_
2 #define ED_MODEL_LOADER_H_
3 
4 #include "ed/uuid.h"
5 
6 #include <geolib/datatypes.h>
8 
9 #include <map>
10 #include <vector>
11 
12 namespace ed
13 {
14 
15 namespace models
16 {
17 
19 {
20 
21 public:
22 
23  ModelLoader();
24 
25  ~ModelLoader();
26 
37  bool create(const UUID& id, const std::string& type, UpdateRequest& req, std::stringstream& error, const bool allow_sdf=false);
38 
47 
59  bool create(const tue::config::DataConstPointer& data, const UUID& id_opt, const UUID& parent_id,
60  UpdateRequest& req, std::stringstream& error, const std::string& model_path = "",
61  const geo::Pose3D& pose_offset = geo::Pose3D::identity());
62 
74  bool createSDF(const tue::config::DataConstPointer& data, const UUID& parent_id, const geo::Pose3D& parent_pose,
75  const UUID& id_override, const boost::shared_ptr<const geo::Pose3D> pose_override,
77 
83  bool exists(const std::string& type) const;
84 
85 private:
86 
88 
89  // Model name to model data
91 
92  // Shape filename to shape
94 
95  // Vectors which contain the paths, where models can be found
97  std::vector<std::string> model_paths_; // GAZEBO_MODEL_PATH
98  std::vector<std::string> file_paths_; // GAZEBO_RESOURCE_PATH
99 
109  std::stringstream& error, const bool allow_sdf=false);
110 
118 
119 
125  std::string getModelPath(const std::string& type) const;
126 
132  std::string getSDFPath(const std::string& uri) const;
133 
140 
141 };
142 
143 
148 enum class LoadType
149 {
150  FILE,
151  MODEL,
152 };
153 
154 
163 bool loadModel(const LoadType load_type, const std::string& source, ed::UpdateRequest& req);
164 
165 } // end namespace models
166 
167 } // end namespace ed
168 
169 #endif
datatypes.h
ed::models::ModelLoader::loadModelData
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'
Definition: model_loader.cpp:156
ed::UpdateRequest
Definition: update_request.h:24
std::string
ed::models::ModelLoader::createSDF
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.
Definition: model_loader.cpp:466
std::pair
ed::models::ModelLoader::model_paths_
std::vector< std::string > model_paths_
Definition: model_loader.h:97
geo::Transform3T::identity
static Transform3T identity()
vector
std::stringstream
ed::models::ModelLoader
Definition: model_loader.h:18
ed::models::ModelLoader::readModelCache
ModelData readModelCache(std::string type) const
readModelCache read the model cache, which contains the data and all types
Definition: model_loader.cpp:143
geo::Transform3T
ed::models::ModelLoader::loadSDFData
tue::config::DataConstPointer loadSDFData(std::string uri, std::stringstream &error)
loadSDFData load data of SDF model of uri 'uri'
Definition: model_loader.cpp:225
ed::models::ModelLoader::create
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,...
Definition: model_loader.cpp:285
ed::log::error
std::ostream & error()
Definition: logging.cpp:74
ed::models::ModelLoader::model_cache_
std::map< std::string, ModelData > model_cache_
Definition: model_loader.h:90
ed::models::ModelLoader::shape_cache_
std::map< std::string, geo::ShapePtr > shape_cache_
Definition: model_loader.h:93
ed::models::LoadType
LoadType
The LoadType enum indicates whether to load directly from a file or from a model that is part of the ...
Definition: model_loader.h:148
ed::UUID
Definition: uuid.h:10
uuid.h
map
data_pointer.h
ed::models::ModelLoader::ed_model_paths_
std::vector< std::string > ed_model_paths_
Definition: model_loader.h:96
ed::models::ModelLoader::file_paths_
std::vector< std::string > file_paths_
Definition: model_loader.h:98
ed::models::ModelLoader::ModelData
std::pair< tue::config::DataConstPointer, std::vector< std::string > > ModelData
Definition: model_loader.h:87
ed::models::ModelLoader::exists
bool exists(const std::string &type) const
exists Check of a model of type 'type' exist
Definition: model_loader.cpp:264
tue::config::DataConstPointer
ed::models::MODEL
@ MODEL
Definition: shape_loader_private.h:27
ed::models::ModelLoader::ModelLoader
ModelLoader()
Definition: model_loader.cpp:51
ed
Definition: convex_hull.h:8
ed::models::ModelLoader::getSDFPath
std::string getSDFPath(const std::string &uri) const
getSDFPath get file path of SDF model with uri 'uri'
Definition: model_loader.cpp:104
ed::models::FILE
@ FILE
Definition: shape_loader_private.h:28
ed::models::ModelLoader::getModelPath
std::string getModelPath(const std::string &type) const
getModelPath get file path of model of type 'type'
Definition: model_loader.cpp:90
ed::models::ModelLoader::~ModelLoader
~ModelLoader()
Definition: model_loader.cpp:78
ed::models::loadModel
bool loadModel(const LoadType load_type, const std::string &source, ed::UpdateRequest &req)
loadModel loads an ED model from file
Definition: load_model.cpp:21