Flatland
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
flatland_server::Layer Class Reference

#include <layer.h>

Inheritance diagram for flatland_server::Layer:
Inheritance graph
[legend]
Collaboration diagram for flatland_server::Layer:
Collaboration graph
[legend]

Public Member Functions

 Layer (b2World *physics_world, CollisionFilterRegistry *cfr, const std::vector< std::string > &names, const Color &color, const Pose &origin, const cv::Mat &bitmap, double occupied_thresh, double resolution, const YAML::Node &properties)
 Constructor for the Layer class for initialization using a image map file. More...
 
 Layer (b2World *physics_world, CollisionFilterRegistry *cfr, const std::vector< std::string > &names, const Color &color, const Pose &origin, const std::vector< LineSegment > &line_segments, double scale, const YAML::Node &properties)
 Constructor for the Layer class for initialization using line segments. More...
 
 Layer (b2World *physics_world, CollisionFilterRegistry *cfr, const std::vector< std::string > &names, const Color &color, const YAML::Node &properties)
 Constructor for the Layer class for initialization with no static map in it. More...
 
 ~Layer ()
 Destructor for the layer class.
 
const std::vector< std::string > & GetNames () const
 
const CollisionFilterRegistryGetCfr () const
 
BodyGetBody ()
 
EntityType Type () const
 Return the type of entity. More...
 
void LoadFromBitmap (const cv::Mat &bitmap, double occupied_thresh, double resolution)
 Load the map by extracting edges from images. More...
 
void DebugVisualize () const override
 Visualize layer for debugging purposes.
 
void DebugOutput () const override
 log debug messages for the layer
 
- Public Member Functions inherited from flatland_server::Entity
 Entity (b2World *physics_world, const std::string &name)
 Constructor for the entity. More...
 
const std::string & GetName () const
 
b2World * GetPhysicsWorld ()
 Get Box2D physics world. More...
 
 Entity (const Entity &)=delete
 
Entityoperator= (const Entity &)=delete
 

Static Public Member Functions

static void ReadLineSegmentsFile (const std::string &file_path, std::vector< LineSegment > &line_segments)
 Read line segments from a file, each line of a file represents a line segment in the form of x1 y1 x2 y2. More...
 
static LayerMakeLayer (b2World *physics_world, CollisionFilterRegistry *cfr, const std::string &map_path, const std::vector< std::string > &names, const Color &color, const YAML::Node &properties)
 Factory method to instantiate a layer, throws exceptions upon failure. More...
 

Public Attributes

std::vector< std::string > names_
 list of layer names
 
Bodybody_ = nullptr
 
CollisionFilterRegistrycfr_
 collision filter registry
 
std::string viz_name_
 for visualization
 
- Public Attributes inherited from flatland_server::Entity
b2World * physics_world_
 Box2D physics world.
 
std::string name_
 name of the entity
 

Additional Inherited Members

- Public Types inherited from flatland_server::Entity
enum  EntityType { LAYER, MODEL }
 Defines the type of entity.
 

Detailed Description

This class defines a layer in the simulation world which simulates the environment in the world

Constructor & Destructor Documentation

flatland_server::Layer::Layer ( b2World *  physics_world,
CollisionFilterRegistry cfr,
const std::vector< std::string > &  names,
const Color color,
const Pose origin,
const cv::Mat &  bitmap,
double  occupied_thresh,
double  resolution,
const YAML::Node &  properties 
)

Constructor for the Layer class for initialization using a image map file.

Parameters
[in]physics_worldPointer to the box2d physics world
[in]cfrCollision filter registry
[in]namesA list of names for the layer, the first name is used for the name of the body
[in]colorColor in the form of r, g, b, a, used for visualization
[in]originCoordinate of the lower left corner of the image, in the form of x, y, theta
[in]occupied_threshThreshold indicating obstacle if above
[in]bitmapMatrix containing the map image
[in]resolutionResolution of the map image in meters per pixel
[in]propertiesA YAML node containing properties for plugins to use
flatland_server::Layer::Layer ( b2World *  physics_world,
CollisionFilterRegistry cfr,
const std::vector< std::string > &  names,
const Color color,
const Pose origin,
const std::vector< LineSegment > &  line_segments,
double  scale,
const YAML::Node &  properties 
)

Constructor for the Layer class for initialization using line segments.

Parameters
[in]physics_worldPointer to the box2d physics world
[in]cfrCollision filter registry
[in]namesA list of names for the layer, the first name is used for the name of the body
[in]colorColor in the form of r, g, b, a, used for visualization
[in]originCoordinate of the lower left corner of the image, in the form of x, y, theta
[in]line_segmentsList of line segments
[in]scaleScale to apply to the line segment end points, works in the same way as resolution
[in]propertiesA YAML node containing properties for plugins to use
flatland_server::Layer::Layer ( b2World *  physics_world,
CollisionFilterRegistry cfr,
const std::vector< std::string > &  names,
const Color color,
const YAML::Node &  properties 
)

Constructor for the Layer class for initialization with no static map in it.

Parameters
[in]physics_worldPointer to the box2d physics world
[in]cfrCollision filter registry
[in]namesA list of names for the layer, the first name is used for the name of the body
[in]propertiesA YAML node containing properties for plugins to use

Member Function Documentation

const CollisionFilterRegistry * flatland_server::Layer::GetCfr ( ) const
Returns
The collision filter registrar
const std::vector< std::string > & flatland_server::Layer::GetNames ( ) const
Returns
The list of names the layer has
void flatland_server::Layer::LoadFromBitmap ( const cv::Mat &  bitmap,
double  occupied_thresh,
double  resolution 
)

Load the map by extracting edges from images.

Parameters
[in]bitmapOpenCV Image
[in]occupied_threshThreshold indicating obstacle if above
[in]resolutionResolution of the map image in meters per pixel
Layer * flatland_server::Layer::MakeLayer ( b2World *  physics_world,
CollisionFilterRegistry cfr,
const std::string &  map_path,
const std::vector< std::string > &  names,
const Color color,
const YAML::Node &  properties 
)
static

Factory method to instantiate a layer, throws exceptions upon failure.

Parameters
[in]physics_worldPointer to the box2d physics world
[in]cfrCollision filter registry
[in]map_pathPath to the file containing layer data
[in]namesA list of names for the layer, the first name is used for the name of the body. All names are registered in the CFR. Multiple names allow the physics body to be used as if there are multiple layers
[in]colorColor of the layer file, this is used to calculate the path to the layermap yaml file
[in]propertiesA YAML node containing properties for plugins to use
Returns
A new layer
void flatland_server::Layer::ReadLineSegmentsFile ( const std::string &  file_path,
std::vector< LineSegment > &  line_segments 
)
static

Read line segments from a file, each line of a file represents a line segment in the form of x1 y1 x2 y2.

Parameters
[in]file_pathPath to the file
[out]line_segmentsLine segments obtained from the file
EntityType flatland_server::Layer::Type ( ) const
inlinevirtual

Return the type of entity.

Returns
type indicating it is a layer

Implements flatland_server::Entity.


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