moveit2
The MoveIt Motion Planning Framework for ROS 2.
Classes | Public Types | Public Member Functions | List of all members
collision_detection::World Class Reference

Maintain a representation of the environment. More...

#include <world.h>

Classes

class  Action
 Represents an action that occurred on an object in the world. Several bits may be set indicating several things happened to the object. If the DESTROY bit is set, other bits will not be set. More...
 
struct  Object
 A representation of an object. More...
 
class  ObserverHandle
 

Public Types

enum  ActionBits {
  UNINITIALIZED = 0 , CREATE = 1 , DESTROY = 2 , MOVE_SHAPE = 4 ,
  ADD_SHAPE = 8 , REMOVE_SHAPE = 16
}
 
using const_iterator = std::map< std::string, ObjectPtr >::const_iterator
 
using ObserverCallbackFn = std::function< void(const ObjectConstPtr &, Action)>
 

Public Member Functions

 World ()
 Constructor. More...
 
 World (const World &other)
 A copy constructor. other should not be changed while the copy constructor is running This does copy on write and should be quick. More...
 
virtual ~World ()
 
 MOVEIT_STRUCT_FORWARD (Object)
 
std::vector< std::string > getObjectIds () const
 Get the list of Object ids. More...
 
ObjectConstPtr getObject (const std::string &object_id) const
 Get a particular object. More...
 
const_iterator begin () const
 
const_iterator end () const
 
std::size_t size () const
 
const_iterator find (const std::string &object_id) const
 
bool hasObject (const std::string &object_id) const
 Check if a particular object exists in the collision world. More...
 
bool knowsTransform (const std::string &name) const
 Check if an object or subframe with given name exists in the collision world. A subframe name needs to be prefixed with the object's name separated by a slash. More...
 
const Eigen::Isometry3d & getTransform (const std::string &name) const
 Get the transform to an object or subframe with given name. If name does not exist, a std::runtime_error is thrown. A subframe name needs to be prefixed with the object's name separated by a slash. The transform is global (relative to the world origin). The returned transform is guaranteed to be a valid isometry. More...
 
const Eigen::Isometry3d & getTransform (const std::string &name, bool &frame_found) const
 Get the transform to an object or subframe with given name. If name does not exist, returns an identity transform and sets frame_found to false. A subframe name needs to be prefixed with the object's name separated by a slash. The transform is global (relative to the world origin). The returned transform is guaranteed to be a valid isometry. More...
 
const Eigen::Isometry3d & getGlobalShapeTransform (const std::string &object_id, int shape_index) const
 Get the global transform to a shape of an object with multiple shapes. shape_index is the index of the object (counting from 0) and needs to be valid. This function is used to construct the collision environment. More...
 
const EigenSTL::vector_Isometry3d & getGlobalShapeTransforms (const std::string &object_id) const
 Get the global transforms to the shapes of an object. This function is used to construct the collision environment. More...
 
void addToObject (const std::string &object_id, const Eigen::Isometry3d &pose, const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Isometry3d &shape_poses)
 Add a pose and shapes to an object in the map. This function makes repeated calls to addToObjectInternal() to add the shapes one by one. More...
 
void addToObject (const std::string &object_id, const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Isometry3d &shape_poses)
 Add shapes to an object in the map. This function makes repeated calls to addToObjectInternal() to add the shapes one by one. More...
 
void addToObject (const std::string &object_id, const Eigen::Isometry3d &pose, const shapes::ShapeConstPtr &shape, const Eigen::Isometry3d &shape_pose)
 Add a pose and shape to an object. If the object already exists, this call will add the shape to the object at the specified pose. Otherwise, the object is created and the specified shape is added. This calls addToObjectInternal(). shape_pose is defined relative to the object's pose, not to the world frame. More...
 
void addToObject (const std::string &object_id, const shapes::ShapeConstPtr &shape, const Eigen::Isometry3d &shape_pose)
 Add a shape to an object. If the object already exists, this call will add the shape to the object at the specified pose. Otherwise, the object is created and the specified shape is added. This calls addToObjectInternal(). shape_pose is defined relative to the object's pose, not to the world frame. More...
 
bool moveShapeInObject (const std::string &object_id, const shapes::ShapeConstPtr &shape, const Eigen::Isometry3d &shape_pose)
 Update the pose of a shape in an object. Shape equality is verified by comparing pointers. Returns true on success. More...
 
bool moveObject (const std::string &object_id, const Eigen::Isometry3d &transform)
 Move the object pose (thus moving all shapes and subframes in the object) according to the given transform specified in world frame. The transform is relative to and changes the object pose. It does not replace it. More...
 
bool setObjectPose (const std::string &object_id, const Eigen::Isometry3d &pose)
 Set the pose of an object. The pose is specified in the world frame. More...
 
bool removeShapeFromObject (const std::string &object_id, const shapes::ShapeConstPtr &shape)
 Remove shape from object. Shape equality is verified by comparing pointers. Ownership of the object is renounced (i.e. object is deleted if no external references exist) if this was the last shape in the object. Returns true on success and false if the object did not exist or did not contain the shape. More...
 
bool removeObject (const std::string &object_id)
 Remove a particular object. If there are no external pointers to the corresponding instance of Object, the memory is freed. Returns true on success and false if no such object was found. More...
 
bool setSubframesOfObject (const std::string &object_id, const moveit::core::FixedTransformsMap &subframe_poses)
 Set subframes on an object. The frames are relative to the object pose. More...
 
void clearObjects ()
 Clear all objects. If there are no other pointers to corresponding instances of Objects, the memory is freed. More...
 
ObserverHandle addObserver (const ObserverCallbackFn &callback)
 register a callback function for notification of changes. callback will be called right after any change occurs to any Object. observer is the object which is requesting the changes. It is only used for identifying the callback in removeObserver(). More...
 
void removeObserver (const ObserverHandle observer_handle)
 remove a notifier callback More...
 
void notifyObserverAllObjects (const ObserverHandle observer_handle, Action action) const
 

Detailed Description

Maintain a representation of the environment.

Definition at line 58 of file world.h.

Member Typedef Documentation

◆ const_iterator

using collision_detection::World::const_iterator = std::map<std::string, ObjectPtr>::const_iterator

iterator over the objects in the world.

Definition at line 126 of file world.h.

◆ ObserverCallbackFn

using collision_detection::World::ObserverCallbackFn = std::function<void(const ObjectConstPtr&, Action)>

Definition at line 301 of file world.h.

Member Enumeration Documentation

◆ ActionBits

Enumerator
UNINITIALIZED 
CREATE 
DESTROY 

object was created

MOVE_SHAPE 

object was destroyed

ADD_SHAPE 

one or more shapes in object were moved

REMOVE_SHAPE 

shape(s) were added to object

Definition at line 251 of file world.h.

Constructor & Destructor Documentation

◆ World() [1/2]

collision_detection::World::World ( )

Constructor.

Definition at line 47 of file world.cpp.

◆ World() [2/2]

collision_detection::World::World ( const World other)

A copy constructor. other should not be changed while the copy constructor is running This does copy on write and should be quick.

Definition at line 51 of file world.cpp.

◆ ~World()

collision_detection::World::~World ( )
virtual

Definition at line 56 of file world.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ addObserver()

World::ObserverHandle collision_detection::World::addObserver ( const ObserverCallbackFn callback)

register a callback function for notification of changes. callback will be called right after any change occurs to any Object. observer is the object which is requesting the changes. It is only used for identifying the callback in removeObserver().

Definition at line 364 of file world.cpp.

Here is the caller graph for this function:

◆ addToObject() [1/4]

void collision_detection::World::addToObject ( const std::string &  object_id,
const Eigen::Isometry3d &  pose,
const shapes::ShapeConstPtr &  shape,
const Eigen::Isometry3d &  shape_pose 
)
inline

Add a pose and shape to an object. If the object already exists, this call will add the shape to the object at the specified pose. Otherwise, the object is created and the specified shape is added. This calls addToObjectInternal(). shape_pose is defined relative to the object's pose, not to the world frame.

Definition at line 198 of file world.h.

Here is the call graph for this function:

◆ addToObject() [2/4]

void collision_detection::World::addToObject ( const std::string &  object_id,
const Eigen::Isometry3d &  pose,
const std::vector< shapes::ShapeConstPtr > &  shapes,
const EigenSTL::vector_Isometry3d &  shape_poses 
)

Add a pose and shapes to an object in the map. This function makes repeated calls to addToObjectInternal() to add the shapes one by one.

Definition at line 71 of file world.cpp.

Here is the caller graph for this function:

◆ addToObject() [3/4]

void collision_detection::World::addToObject ( const std::string &  object_id,
const shapes::ShapeConstPtr &  shape,
const Eigen::Isometry3d &  shape_pose 
)
inline

Add a shape to an object. If the object already exists, this call will add the shape to the object at the specified pose. Otherwise, the object is created and the specified shape is added. This calls addToObjectInternal(). shape_pose is defined relative to the object's pose, not to the world frame.

Definition at line 209 of file world.h.

Here is the call graph for this function:

◆ addToObject() [4/4]

void collision_detection::World::addToObject ( const std::string &  object_id,
const std::vector< shapes::ShapeConstPtr > &  shapes,
const EigenSTL::vector_Isometry3d &  shape_poses 
)
inline

Add shapes to an object in the map. This function makes repeated calls to addToObjectInternal() to add the shapes one by one.

Definition at line 187 of file world.h.

Here is the call graph for this function:

◆ begin()

const_iterator collision_detection::World::begin ( ) const
inline

iterator pointing to first change

Definition at line 128 of file world.h.

◆ clearObjects()

void collision_detection::World::clearObjects ( )

Clear all objects. If there are no other pointers to corresponding instances of Objects, the memory is freed.

Definition at line 322 of file world.cpp.

Here is the caller graph for this function:

◆ end()

const_iterator collision_detection::World::end ( ) const
inline

iterator pointing to end of changes

Definition at line 133 of file world.h.

◆ find()

const_iterator collision_detection::World::find ( const std::string &  object_id) const
inline

find changes for a named object

Definition at line 143 of file world.h.

◆ getGlobalShapeTransform()

const Eigen::Isometry3d & collision_detection::World::getGlobalShapeTransform ( const std::string &  object_id,
int  shape_index 
) const

Get the global transform to a shape of an object with multiple shapes. shape_index is the index of the object (counting from 0) and needs to be valid. This function is used to construct the collision environment.

Definition at line 195 of file world.cpp.

◆ getGlobalShapeTransforms()

const EigenSTL::vector_Isometry3d & collision_detection::World::getGlobalShapeTransforms ( const std::string &  object_id) const

Get the global transforms to the shapes of an object. This function is used to construct the collision environment.

Definition at line 210 of file world.cpp.

◆ getObject()

World::ObjectConstPtr collision_detection::World::getObject ( const std::string &  object_id) const

Get a particular object.

Definition at line 111 of file world.cpp.

Here is the caller graph for this function:

◆ getObjectIds()

std::vector< std::string > collision_detection::World::getObjectIds ( ) const

Get the list of Object ids.

Definition at line 103 of file world.cpp.

◆ getTransform() [1/2]

const Eigen::Isometry3d & collision_detection::World::getTransform ( const std::string &  name) const

Get the transform to an object or subframe with given name. If name does not exist, a std::runtime_error is thrown. A subframe name needs to be prefixed with the object's name separated by a slash. The transform is global (relative to the world origin). The returned transform is guaranteed to be a valid isometry.

Definition at line 153 of file world.cpp.

◆ getTransform() [2/2]

const Eigen::Isometry3d & collision_detection::World::getTransform ( const std::string &  name,
bool &  frame_found 
) const

Get the transform to an object or subframe with given name. If name does not exist, returns an identity transform and sets frame_found to false. A subframe name needs to be prefixed with the object's name separated by a slash. The transform is global (relative to the world origin). The returned transform is guaranteed to be a valid isometry.

Definition at line 162 of file world.cpp.

◆ hasObject()

bool collision_detection::World::hasObject ( const std::string &  object_id) const

Check if a particular object exists in the collision world.

Definition at line 126 of file world.cpp.

Here is the caller graph for this function:

◆ knowsTransform()

bool collision_detection::World::knowsTransform ( const std::string &  name) const

Check if an object or subframe with given name exists in the collision world. A subframe name needs to be prefixed with the object's name separated by a slash.

Definition at line 131 of file world.cpp.

◆ MOVEIT_STRUCT_FORWARD()

collision_detection::World::MOVEIT_STRUCT_FORWARD ( Object  )

◆ moveObject()

bool collision_detection::World::moveObject ( const std::string &  object_id,
const Eigen::Isometry3d &  transform 
)

Move the object pose (thus moving all shapes and subframes in the object) according to the given transform specified in world frame. The transform is relative to and changes the object pose. It does not replace it.

Definition at line 247 of file world.cpp.

Here is the call graph for this function:

◆ moveShapeInObject()

bool collision_detection::World::moveShapeInObject ( const std::string &  object_id,
const shapes::ShapeConstPtr &  shape,
const Eigen::Isometry3d &  shape_pose 
)

Update the pose of a shape in an object. Shape equality is verified by comparing pointers. Returns true on success.

Definition at line 225 of file world.cpp.

Here is the caller graph for this function:

◆ notifyObserverAllObjects()

void collision_detection::World::notifyObserverAllObjects ( const ObserverHandle  observer_handle,
Action  action 
) const

send notification of change to all objects to a particular observer. Used which switching from one world to another.

Definition at line 396 of file world.cpp.

◆ removeObject()

bool collision_detection::World::removeObject ( const std::string &  object_id)

Remove a particular object. If there are no external pointers to the corresponding instance of Object, the memory is freed. Returns true on success and false if no such object was found.

Definition at line 310 of file world.cpp.

Here is the caller graph for this function:

◆ removeObserver()

void collision_detection::World::removeObserver ( const ObserverHandle  observer_handle)

remove a notifier callback

Definition at line 371 of file world.cpp.

Here is the caller graph for this function:

◆ removeShapeFromObject()

bool collision_detection::World::removeShapeFromObject ( const std::string &  object_id,
const shapes::ShapeConstPtr &  shape 
)

Remove shape from object. Shape equality is verified by comparing pointers. Ownership of the object is renounced (i.e. object is deleted if no external references exist) if this was the last shape in the object. Returns true on success and false if the object did not exist or did not contain the shape.

Definition at line 281 of file world.cpp.

Here is the caller graph for this function:

◆ setObjectPose()

bool collision_detection::World::setObjectPose ( const std::string &  object_id,
const Eigen::Isometry3d &  pose 
)

Set the pose of an object. The pose is specified in the world frame.

Definition at line 259 of file world.cpp.

Here is the caller graph for this function:

◆ setSubframesOfObject()

bool collision_detection::World::setSubframesOfObject ( const std::string &  object_id,
const moveit::core::FixedTransformsMap subframe_poses 
)

Set subframes on an object. The frames are relative to the object pose.

Definition at line 328 of file world.cpp.

◆ size()

std::size_t collision_detection::World::size ( ) const
inline

number of changes stored

Definition at line 138 of file world.h.

Here is the caller graph for this function:

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