ed
Classes | Enumerations | Functions
ed::models Namespace Reference

Classes

class  ModelLoader
 

Enumerations

enum  LoadType { FILE, MODEL }
 The LoadType enum indicates whether to load directly from a file or from a model that is part of the ED_MODEL_PATH. More...
 
enum  ModelOrFile { MODEL, MODEL, FILE, FILE }
 The ModelOrFile enum This is used to determine the URI type in SDF. More...
 

Functions

void createCylinder (geo::Shape &shape, double radius, double height, int num_corners=12)
 createCylinder create a mesh from radius and height More...
 
void createPolygon (geo::Shape &shape, const std::vector< geo::Vec2 > &points, double height, std::stringstream &error, bool create_bottom=true)
 createPolygon create polygon mesh from points More...
 
void createSphere (geo::Shape &shape, double radius, uint recursion_level=2)
 createSphere Create a shape of sphere More...
 
void findContours (const cv::Mat &image, const geo::Vec2i &p_start, int d_start, std::vector< geo::Vec2i > &points, std::vector< geo::Vec2i > &line_starts, cv::Mat &contour_map)
 findContours More...
 
geo::ShapePtr getHeightMapShape (const std::string &image_filename, const geo::Vec3 &pos, const double blockheight, const double resolution_x, const double resolution_y, const bool inverted, std::stringstream &error)
 getHeightMapShape convert grayscale image in a heigtmap mesh More...
 
geo::ShapePtr getHeightMapShape (const std::string &image_filename, const geo::Vec3 &pos, const geo::Vec3 &size, const bool inverted, std::stringstream &error)
 getHeightMapShape convert grayscale image in a heigtmap mesh More...
 
geo::ShapePtr getHeightMapShape (const std::string &image_filename, tue::config::Reader cfg, std::stringstream &error)
 getHeightMapShape convert grayscale image in a heigtmap mesh More...
 
geo::ShapePtr getHeightMapShape (cv::Mat &image_orig, const geo::Vec3 &pos, const geo::Vec3 &size, const bool inverted, std::stringstream &error)
 getHeightMapShape convert grayscale image in a heigtmap mesh More...
 
uint getMiddlePoint (geo::Mesh &mesh, uint i1, uint i2, std::map< unsigned long, uint > cache, double radius)
 getMiddlePoint Gets the middle point of two points in a mesh of a sphere. Uses a cache to not create double points. The new point is placed on the radius of the sphere. More...
 
static std::string getUriPath (std::string type)
 getUriPath searches GAZEBO_MODEL_PATH and GAZEBO_RESOURCH_PATH for file More...
 
bool loadModel (const LoadType load_type, const std::string &source, ed::UpdateRequest &req)
 loadModel loads an ED model from file More...
 
geo::ShapePtr loadShape (const std::string &model_path, tue::config::Reader cfg, std::map< std::string, geo::ShapePtr > &shape_cache, std::stringstream &error)
 loadShape load the shape of a model. More...
 
std::string parseURI (const std::string &uri, ModelOrFile &uri_type)
 
bool readPose (tue::config::Reader &cfg, geo::Pose3D &pose, tue::config::RequiredOrOptional pos_req=tue::config::REQUIRED, tue::config::RequiredOrOptional rot_req=tue::config::OPTIONAL)
 readPose read pose into Pose3D. Both ED yaml and SDF. Also reads pos(position) of SDF. More...
 
bool readSDFGeometry (tue::config::Reader r, geo::CompositeShapePtr &composite, std::stringstream &error, geo::Pose3D pose_offset=geo::Pose3D::identity())
 
void readVec3 (tue::config::Reader &cfg, geo::Vec3 &v, tue::config::RequiredOrOptional pos_req=tue::config::REQUIRED)
 readVec3 read x, y and z into a vector More...
 
bool readVec3Group (tue::config::Reader &cfg, geo::Vec3 &v, const std::string &vector_name, tue::config::RequiredOrOptional=tue::config::REQUIRED)
 readVec3Group read a config group into a Vec3 More...
 
std::vector< std::stringsplit (const std::string &strToSplit, char delimeter)
 split Implementation by using delimiter as a character. Multiple delimeters are removed. More...
 

Enumeration Type Documentation

◆ LoadType

enum ed::models::LoadType
strong

The LoadType enum indicates whether to load directly from a file or from a model that is part of the ED_MODEL_PATH.

Enumerator
FILE 
MODEL 

Definition at line 148 of file model_loader.h.

◆ ModelOrFile

The ModelOrFile enum This is used to determine the URI type in SDF.

Enumerator
MODEL 
MODEL 
FILE 
FILE 

Definition at line 25 of file shape_loader_private.h.

Function Documentation

◆ createCylinder()

void ed::models::createCylinder ( geo::Shape shape,
double  radius,
double  height,
int  num_corners = 12 
)

createCylinder create a mesh from radius and height

Parameters
shapefilled mesh
radiusradius of the cylinder
heightheight of the cylinder
num_cornersdivided the circumference in N points and N+1 lines

Definition at line 884 of file shape_loader.cpp.

◆ createPolygon()

void ed::models::createPolygon ( geo::Shape shape,
const std::vector< geo::Vec2 > &  points,
double  height,
std::stringstream error,
bool  create_bottom = true 
)

createPolygon create polygon mesh from points

Parameters
shapefilled mesh
points2D points which define the mesh
heightheight of the mesh
errorerror stream
create_bottomfalse: open bottom; true: closed bottom

Definition at line 451 of file shape_loader.cpp.

◆ createSphere()

void ed::models::createSphere ( geo::Shape shape,
double  radius,
uint  recursion_level = 2 
)

createSphere Create a shape of sphere

Parameters
shapeShape object to be filled
radiusradius of the sphere
recursion_levelnumber of recursions to smooth the mesh, but rapidly increases the mesh.

Definition at line 953 of file shape_loader.cpp.

◆ findContours()

void ed::models::findContours ( const cv::Mat &  image,
const geo::Vec2i p_start,
int  d_start,
std::vector< geo::Vec2i > &  points,
std::vector< geo::Vec2i > &  line_starts,
cv::Mat &  contour_map 
)

findContours

Parameters
imageGrayscale image
p_startstarting point
d_startstarting direction
points
line_starts
contour_map

Definition at line 143 of file shape_loader.cpp.

◆ getHeightMapShape() [1/4]

geo::ShapePtr ed::models::getHeightMapShape ( const std::string image_filename,
const geo::Vec3 pos,
const double  blockheight,
const double  resolution_x,
const double  resolution_y,
const bool  inverted,
std::stringstream error 
)

getHeightMapShape convert grayscale image in a heigtmap mesh

Parameters
image_filenamefull path of grayscale image
posposition of the origin of the heigtmap
blockheightheight of the heightmap of max grayscale value
resolution_xresolution in x direction in meters
resolution_yresolution in y direction in meters
invertedfalse: CV/ROS standard (black = height); true: SDF/GAZEBO (White = height)
errorerrorstream
Returns
final mesh; or empty mesh in case of error

Definition at line 400 of file shape_loader.cpp.

◆ getHeightMapShape() [2/4]

geo::ShapePtr ed::models::getHeightMapShape ( const std::string image_filename,
const geo::Vec3 pos,
const geo::Vec3 size,
const bool  inverted,
std::stringstream error 
)

getHeightMapShape convert grayscale image in a heigtmap mesh

Parameters
image_filenamefull path of grayscale image
posposition of the origin of the heigtmap
sizedimensions of the final mesh
invertedfalse: CV/ROS standard (black = height); true: SDF/GAZEBO (White = height)
errorerrorstream
Returns
final mesh; or empty mesh in case of error

Definition at line 383 of file shape_loader.cpp.

◆ getHeightMapShape() [3/4]

geo::ShapePtr ed::models::getHeightMapShape ( const std::string image_filename,
tue::config::Reader  cfg,
std::stringstream error 
)

getHeightMapShape convert grayscale image in a heigtmap mesh

Parameters
image_filenameimage_filename full path of grayscale image
cfgreader with model/shape information
errorerrorstream
Returns
final mesh; or empty mesh in case of error

Definition at line 428 of file shape_loader.cpp.

◆ getHeightMapShape() [4/4]

geo::ShapePtr ed::models::getHeightMapShape ( cv::Mat &  image_orig,
const geo::Vec3 pos,
const geo::Vec3 size,
const bool  inverted,
std::stringstream error 
)

getHeightMapShape convert grayscale image in a heigtmap mesh

Parameters
image_origgrayscale image
posposition of the origin of the heigtmap
sizedimensions of the final mesh
invertedfalse: CV/ROS standard (black = height); true: SDF/GAZEBO (White = height)
errorerrorstream
Returns
final mesh; or empty mesh in case of error

Definition at line 213 of file shape_loader.cpp.

◆ getMiddlePoint()

uint ed::models::getMiddlePoint ( geo::Mesh mesh,
uint  i1,
uint  i2,
std::map< unsigned long, uint >  cache,
double  radius 
)

getMiddlePoint Gets the middle point of two points in a mesh of a sphere. Uses a cache to not create double points. The new point is placed on the radius of the sphere.

Parameters
meshMesh of the sphere
i1index of first point
i2index of second point
cachecache of the middle points
radiusradius of teh sphere
Returns
index of the inserted point

Definition at line 924 of file shape_loader.cpp.

◆ getUriPath()

static std::string ed::models::getUriPath ( std::string  type)
static

getUriPath searches GAZEBO_MODEL_PATH and GAZEBO_RESOURCH_PATH for file

Parameters
typesubpath+filename incl. extension
Returns
full path or empty string in case not found

Definition at line 78 of file shape_loader.cpp.

◆ loadModel()

bool ed::models::loadModel ( const LoadType  load_type,
const std::string source,
ed::UpdateRequest req 
)

loadModel loads an ED model from file

Parameters
load_typeindicates whether the provided source is a filename or an identifier of a model in the ED_MODEL_PATH
sourcesource filename or entity type
requpdate request that will be filled with the data from the model
Returns
success

Definition at line 21 of file load_model.cpp.

◆ loadShape()

geo::ShapePtr ed::models::loadShape ( const std::string model_path,
tue::config::Reader  cfg,
std::map< std::string, geo::ShapePtr > &  shape_cache,
std::stringstream error 
)

loadShape load the shape of a model.

Parameters
model_pathpath of the model
cfgreader
shape_cachecache for complex models
errorerrorstream
Returns
final mesh; or empty mesh in case of error

Definition at line 621 of file shape_loader.cpp.

◆ parseURI()

std::string ed::models::parseURI ( const std::string uri,
ModelOrFile uri_type 
)

Definition at line 48 of file shape_loader.cpp.

◆ readPose()

readPose read pose into Pose3D. Both ED yaml and SDF. Also reads pos(position) of SDF.

Parameters
cfgreader
posefilled Pose3D pose
pos_reqposition RequiredOrOptional
rot_reqrotation RequiredOrOptional
Returns
indicates succes

Definition at line 561 of file shape_loader.cpp.

◆ readSDFGeometry()

bool ed::models::readSDFGeometry ( tue::config::Reader  r,
geo::CompositeShapePtr composite,
std::stringstream error,
geo::Pose3D  pose_offset = geo::Pose3D::identity() 
)

Definition at line 29 of file model_loader.cpp.

◆ readVec3()

void ed::models::readVec3 ( tue::config::Reader cfg,
geo::Vec3 v,
tue::config::RequiredOrOptional  pos_req = tue::config::REQUIRED 
)

readVec3 read x, y and z into a vector

Parameters
cfgreader
vfilled Vec3 vector
pos_reqRequiredOrOptional

Definition at line 521 of file shape_loader.cpp.

◆ readVec3Group()

bool ed::models::readVec3Group ( tue::config::Reader cfg,
geo::Vec3 v,
const std::string vector_name,
tue::config::RequiredOrOptional  = tue::config::REQUIRED 
)

readVec3Group read a config group into a Vec3

Parameters
cfgreader
vfilled Vec3 vector
vector_namename of the reader group to be read
pos_reqRequiredOrOptional
Returns
indicates succes

Definition at line 538 of file shape_loader.cpp.

◆ split()

std::vector< std::string > ed::models::split ( const std::string strToSplit,
char  delimeter 
)

split Implementation by using delimiter as a character. Multiple delimeters are removed.

Parameters
strToSplitinput string, which is splitted
delimeterchar on which the string is split
Returns
vector of sub-strings

Definition at line 33 of file shape_loader.cpp.