Parasol Planning Library (PPL)
Environment Class Reference

#include <Environment.h>

Collaboration diagram for Environment:
Collaboration graph
[legend]

Public Types

Local Types
typedef std::unordered_map< std::string, std::vector< Terrain > > TerrainMap
 

Public Member Functions

Construction
 Environment ()
 
 Environment (XMLNode &_node)
 
 Environment (const Environment &_other)
 Copy. More...
 
 Environment (Environment &&_other)
 Move. More...
 
virtual ~Environment ()
 
Assignment
Environmentoperator= (const Environment &_other)
 Copy. More...
 
Environmentoperator= (Environment &&_other)
 Move. More...
 
I/O
const std::string & GetEnvFileName () const noexcept
 Get the environment file name. More...
 
void ReadXMLOptions (XMLNode &_node)
 Parse XML options from the Problem XML node. More...
 
void ReadXML (XMLNode &_node)
 Parse XML environment file. More...
 
void Read (std::string _filename)
 
void Print (std::ostream &_os) const
 
void Write (std::ostream &_os)
 
Resolutions
void ComputeResolution (const std::vector< std::unique_ptr< Robot >> &_robots)
 
double GetPositionRes () const noexcept
 Get the position resolution. More...
 
void SetPositionRes (double _res) noexcept
 Set the position resolution. More...
 
double GetOrientationRes () const noexcept
 Get the orientation resolution. More...
 
void SetOrientationRes (double _res) noexcept
 Set the orientation resolution. More...
 
double GetTimeRes () const noexcept
 Get the time resolution. More...
 
Boundary Functions
BoundaryGetBoundary () const noexcept
 Get the single boundary of the environemnt. More...
 
void SetBoundary (std::unique_ptr< Boundary > &&_b) noexcept
 
Obstacle Functions
size_t NumObstacles () const noexcept
 Get the number of MultiBodies. More...
 
MultiBodyGetObstacle (size_t _index) const
 
MultiBodyGetRandomObstacle () const
 
size_t AddObstacle (const std::string &_dir, const std::string &_filename, const mathtool::Transformation &_t=mathtool::Transformation())
 
void RemoveObstacle (const size_t _position)
 
void RemoveObstacle (MultiBody *const _obst)
 
std::map< mathtool::Vector3d, std::vector< size_t > > ComputeObstacleVertexMap () const
 
bool UsingBoundaryObstacle () const noexcept
 Check if the boundary is also modeled as an obstacle. More...
 
Terrain Functions
const TerrainMapGetTerrains () const noexcept
 Get environment terrains. More...
 

Protected Member Functions

Helpers
void InitializeBoundary (std::string _type, const std::string _where)
 
void CreateBoundaryObstacle ()
 Create an obstacle for the boundary. More...
 

Protected Attributes

File Info
std::string m_filename
 Which file did this environment come from? More...
 
std::string m_modelDataDir
 Directory where environment file is located. More...
 
Resolution Info
double m_positionRes {-1.}
 Positional resolution of movement. More...
 
double m_orientationRes {.05}
 Rotational resolution of movement. More...
 
double m_timeRes {.05}
 Resolution for time. More...
 
Models
std::unique_ptr< Boundarym_boundary
 Workspace boundary. More...
 
std::vector< std::unique_ptr< MultiBody > > m_obstacles
 Obstacle multibodies. More...
 
bool m_boundaryObstacle {false}
 Use the boundary as an obstacle? More...
 
Terrains
TerrainMap m_terrains
 Environment terrains. More...
 
Simulation Properties
mathtool::Transformation m_initialCameraTransform
 Camera starts here. More...
 

Simulation Functions

std::unique_ptr< Boundarym_originalBoundary
 
const mathtool::Transformation & GetInitialCameraTransformation () const noexcept
 Get the initial transformation for the camera. More...
 
bool IsolateTerrain (Cfg start, Cfg goal)
 IROS Hacks. More...
 
bool SameTerrain (Cfg _start, Cfg _goal)
 
void RestoreBoundary ()
 Restores original boundary. More...
 
void SaveBoundary ()
 Saves boundary as original boundary. More...
 

Physical Properties

double m_frictionCoefficient {0}
 The uniform friction coefficient. More...
 
mathtool::Vector3d m_gravity
 The gravity direction and magnitude. More...
 
double GetFrictionCoefficient () const noexcept
 Get the friction coefficient. More...
 
const mathtool::Vector3d & GetGravity () const noexcept
 Get the gravity 3-vector. More...
 

Detailed Description

Workspace for the motion planning problem, including a boundary and zero or more obstacles.

Examples
LocalPlanner_UseCase.cpp.

Member Typedef Documentation

◆ TerrainMap

typedef std::unordered_map<std::string, std::vector<Terrain> > Environment::TerrainMap

Constructor & Destructor Documentation

◆ Environment() [1/4]

Environment::Environment ( )
default

◆ Environment() [2/4]

Environment::Environment ( XMLNode _node)
explicit

◆ Environment() [3/4]

Environment::Environment ( const Environment _other)

Copy.

◆ Environment() [4/4]

Environment::Environment ( Environment &&  _other)
default

Move.

◆ ~Environment()

Environment::~Environment ( )
virtualdefault

Member Function Documentation

◆ AddObstacle()

size_t Environment::AddObstacle ( const std::string &  _dir,
const std::string &  _filename,
const mathtool::Transformation &  _t = mathtool::Transformation() 
)

Add an obstacle to the environment.

Parameters
_dirDirectory for geometry file
_filenameGeometry filename
_tTransformation of object
Returns
The index of the newly created obstacle.

◆ ComputeObstacleVertexMap()

std::map< Vector3d, std::vector< size_t > > Environment::ComputeObstacleVertexMap ( ) const

Compute a mapping of the obstacle vertices.

Returns
A map from obstacle points to obstacle indexes.

◆ ComputeResolution()

void Environment::ComputeResolution ( const std::vector< std::unique_ptr< Robot >> &  _robots)

Automatically compute position resolution when not specified.

Parameters
_robotsRobots to consider when determining resolution
Todo:
Add an automatic computation of the orientation resolution here. This should be done so that rotating the robot base by one orientation resolution makes a point on the bounding sphere move by one position resolution. If possible we should also separate the resolutions for joint angles and base orientations since this gets really, really small with manipulators having several links (probably we'll need to manage this in the local planner to make maximum use of the available resolution).

◆ CreateBoundaryObstacle()

void Environment::CreateBoundaryObstacle ( )
protected

Create an obstacle for the boundary.

◆ GetBoundary()

Boundary * Environment::GetBoundary ( ) const
noexcept

Get the single boundary of the environemnt.

◆ GetEnvFileName()

const std::string & Environment::GetEnvFileName ( ) const
noexcept

Get the environment file name.

◆ GetFrictionCoefficient()

double Environment::GetFrictionCoefficient ( ) const
noexcept

Get the friction coefficient.

◆ GetGravity()

const Vector3d & Environment::GetGravity ( ) const
noexcept

Get the gravity 3-vector.

◆ GetInitialCameraTransformation()

const mathtool::Transformation & Environment::GetInitialCameraTransformation ( ) const
noexcept

Get the initial transformation for the camera.

◆ GetObstacle()

MultiBody * Environment::GetObstacle ( size_t  _index) const

Get requested obstacle

Parameters
_indexRequested multibody
Returns
Pointer to static multibody

◆ GetOrientationRes()

double Environment::GetOrientationRes ( ) const
noexcept

Get the orientation resolution.

Examples
LocalPlanner_UseCase.cpp.

◆ GetPositionRes()

double Environment::GetPositionRes ( ) const
noexcept

Get the position resolution.

Examples
LocalPlanner_UseCase.cpp.

◆ GetRandomObstacle()

MultiBody * Environment::GetRandomObstacle ( ) const

Get random multiboy

Returns
Pointer to random static multibody

◆ GetTerrains()

const Environment::TerrainMap & Environment::GetTerrains ( ) const
noexcept

Get environment terrains.

◆ GetTimeRes()

double Environment::GetTimeRes ( ) const
noexcept

Get the time resolution.

◆ InitializeBoundary()

void Environment::InitializeBoundary ( std::string  _type,
const std::string  _where 
)
protected

Initialize a boundary object of the appropriate type.

Parameters
_typeType of boundary object (box, box2d, sphere, or sphere2d)
_whereString for parse exception

◆ IsolateTerrain()

bool Environment::IsolateTerrain ( Cfg  start,
Cfg  goal 
)

IROS Hacks.

Determine if two configurations are in the same boundary of a terrain and, if so, sets mutual terrain as new boundary

Parameters
_startFirst configuration
_endSecond configuration
Returns
True if _start and _cfg in same terrain boundary,

◆ NumObstacles()

size_t Environment::NumObstacles ( ) const
noexcept

Get the number of MultiBodies.

◆ operator=() [1/2]

Environment & Environment::operator= ( const Environment _other)

Copy.

Note
We deliberately duplicate the data to make sure the copies are entirely independent. We may wish to revisit this decision at a later time since it is probably safe to share data on static obstacles. I am leaving it this way for now to minimize surprises.

◆ operator=() [2/2]

Environment & Environment::operator= ( Environment &&  _other)
default

Move.

◆ Print()

void Environment::Print ( std::ostream &  _os) const

Print environment resolutions and boundary information.

Parameters
_osThe output stream to print to.

◆ Read()

void Environment::Read ( std::string  _filename)

Parse an old-style environment file.

Parameters
_filenameThe name of the file to read.
Note
This is provided only for supporting old environments. Do not make any modifications here - if you need to add features, you must upgrade your env file to the newer XML format.
Todo:
Add support for dynamic obstacles

◆ ReadXML()

void Environment::ReadXML ( XMLNode _node)

Parse XML environment file.

Todo:
Add support for dynamic obstacles

◆ ReadXMLOptions()

void Environment::ReadXMLOptions ( XMLNode _node)

Parse XML options from the Problem XML node.

◆ RemoveObstacle() [1/2]

void Environment::RemoveObstacle ( const size_t  _position)

Remove an obstacle from the environment.

Parameters
_positionIndex in m_obstacleBodies to be removed

◆ RemoveObstacle() [2/2]

void Environment::RemoveObstacle ( MultiBody *const  _obst)

Remove obstacle from environment

Parameters
_obstObstacle to be removed

◆ RestoreBoundary()

void Environment::RestoreBoundary ( )

Restores original boundary.

◆ SameTerrain()

bool Environment::SameTerrain ( Cfg  _start,
Cfg  _goal 
)

Determine if two configurations are in the same terrain

Parameters
_startFirst configuration
_endSecond configuration
Returns
True if _start and _cfg in same terrain

◆ SaveBoundary()

void Environment::SaveBoundary ( )

Saves boundary as original boundary.

◆ SetBoundary()

void Environment::SetBoundary ( std::unique_ptr< Boundary > &&  _b)
noexcept

Get the single boundary of the environemnt

Parameters
_bThe new boundary

◆ SetOrientationRes()

void Environment::SetOrientationRes ( double  _res)
noexcept

Set the orientation resolution.

◆ SetPositionRes()

void Environment::SetPositionRes ( double  _res)
noexcept

Set the position resolution.

◆ UsingBoundaryObstacle()

bool Environment::UsingBoundaryObstacle ( ) const
noexcept

Check if the boundary is also modeled as an obstacle.

◆ Write()

void Environment::Write ( std::ostream &  _os)

Output environment to .env file format.

Parameters
_osThe output stream to write to.

Field Documentation

◆ m_boundary

std::unique_ptr<Boundary> Environment::m_boundary
protected

Workspace boundary.

◆ m_boundaryObstacle

bool Environment::m_boundaryObstacle {false}
protected

Use the boundary as an obstacle?

◆ m_filename

std::string Environment::m_filename
protected

Which file did this environment come from?

◆ m_frictionCoefficient

double Environment::m_frictionCoefficient {0}
protected

The uniform friction coefficient.

◆ m_gravity

mathtool::Vector3d Environment::m_gravity
protected

The gravity direction and magnitude.

◆ m_initialCameraTransform

mathtool::Transformation Environment::m_initialCameraTransform
protected

Camera starts here.

◆ m_modelDataDir

std::string Environment::m_modelDataDir
protected

Directory where environment file is located.

◆ m_obstacles

std::vector<std::unique_ptr<MultiBody> > Environment::m_obstacles
protected

Obstacle multibodies.

◆ m_orientationRes

double Environment::m_orientationRes {.05}
protected

Rotational resolution of movement.

◆ m_originalBoundary

std::unique_ptr<Boundary> Environment::m_originalBoundary

◆ m_positionRes

double Environment::m_positionRes {-1.}
protected

Positional resolution of movement.

◆ m_terrains

TerrainMap Environment::m_terrains
protected

Environment terrains.

◆ m_timeRes

double Environment::m_timeRes {.05}
protected

Resolution for time.


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