RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
WorkCell Class Reference

WorkCell keeps track of devices, obstacles and objects in the scene. More...

#include <WorkCell.hpp>

Public Types

enum  WorkCellEventType { STATE_DATA_ADDED , STATE_DATA_REMOVED , WORKCELL_CHANGED }
 WorkCell Event Types. More...
 
typedef rw::core::Ptr< WorkCellPtr
 Smart pointer type to a WorkCell object.
 
typedef rw::core::Ptr< const WorkCellCPtr
 Smart pointer type to a constant WorkCell object.
 
typedef boost::function< void(int)> WorkCellChangedListener
 Definition of work cell changed listener.
 
typedef rw::core::Event< WorkCellChangedListener, int > WorkCellChangedEvent
 Definition of even for work cell changed.
 

Public Member Functions

 WorkCell (const std::string &name)
 Constructs an empty WorkCell. More...
 
 WorkCell (rw::core::Ptr< rw::kinematics::StateStructure > tree, const std::string &name="", const std::string &filename="")
 Constructs a WorkCell. More...
 
 ~WorkCell ()
 
std::string getName () const
 The name of the workcell or the empty string if no name was provided. More...
 
rw::kinematics::FramegetWorldFrame () const
 Returns pointer to the world frame. More...
 
void addFrame (rw::kinematics::Frame *frame, rw::kinematics::Frame *parent=NULL)
 Adds frame with parent as parent. More...
 
void addFrame (rw::core::Ptr< rw::kinematics::Frame > frame, rw::core::Ptr< rw::kinematics::Frame > parent=NULL)
 Adds frame with parent as parent. More...
 
void addDAF (rw::kinematics::Frame *frame, rw::kinematics::Frame *parent=NULL)
 Adds dynamically attachable frame (DAF) frame with parent as parent. More...
 
void addDAF (rw::core::Ptr< rw::kinematics::Frame > frame, rw::core::Ptr< rw::kinematics::Frame > parent=NULL)
 Adds dynamically attachable frame (DAF) frame with parent as parent. More...
 
void remove (rw::core::Ptr< rw::kinematics::Frame > frame)
 Removes frame from work cell. More...
 
void remove (rw::kinematics::Frame *frame)
 Removes frame from work cell. More...
 
void removeObject (Object *object)
 Removes object from workcell. More...
 
void addDevice (rw::core::Ptr< rw::models::Device > device)
 Adds a Device to the WorkCell. More...
 
const std::vector< rw::core::Ptr< rw::models::Device > > & getDevices () const
 Returns a reference to a vector with pointers to the Device(s) in the WorkCell. More...
 
rw::kinematics::FramefindFrame (const std::string &name) const
 Returns frame with the specified name. More...
 
template<class T >
T * findFrame (const std::string &name) const
 Returns frame with the specified name and type T. More...
 
template<class T >
std::vector< T * > findFrames () const
 Returns all frames of a specific type T. More...
 
std::vector< rw::kinematics::Frame * > getFrames () const
 Returns all frames in workcell. More...
 
rw::core::Ptr< rw::models::DevicefindDevice (const std::string &name) const
 The device named name of the workcell. More...
 
template<class T >
rw::core::Ptr< T > findDevice (const std::string &name) const
 The device named name of the workcell. More...
 
template<class T >
std::vector< rw::core::Ptr< T > > findDevices () const
 Returns a vector with pointers to the Device(s) with a specific type T in the WorkCell. More...
 
rw::kinematics::State getDefaultState () const
 Returns a default State. More...
 
void setDefaultState (const rw::kinematics::State &state)
 set the default state of the WorkCell. if the given state is an older state then states valid in both new and old version will be copied to the default state.
 
rw::core::Ptr< rw::sensor::SensorModelfindSensor (const std::string &name) const
 Returns sensor with the specified name. More...
 
template<class T >
rw::core::Ptr< T > findSensor (const std::string &name) const
 Returns sensor with the specified name and type T. More...
 
template<class T >
std::vector< rw::core::Ptr< T > > findSensors () const
 Returns all frames of a specific type T. More...
 
std::vector< rw::core::Ptr< rw::sensor::SensorModel > > getSensors () const
 Returns all frames in workcell. More...
 
rw::core::Ptr< rw::models::ControllerModelfindController (const std::string &name) const
 Returns controller with the specified name. More...
 
template<class T >
rw::core::Ptr< T > findController (const std::string &name) const
 Returns controller with the specified name and type T. More...
 
template<class T >
std::vector< rw::core::Ptr< T > > findControllers () const
 Returns all controllers of a specific type T.
 
std::vector< rw::core::Ptr< ControllerModel > > getControllers () const
 Returns all controllers in workcell. More...
 
std::vector< rw::core::Ptr< Object > > getObjects () const
 Returns all object in the work cell. More...
 
rw::core::Ptr< ObjectfindObject (const std::string &name) const
 The object named name of the workcell. More...
 
void add (rw::core::Ptr< rw::models::Device > device)
 Add device to workcell.
 
void add (rw::core::Ptr< Object > object)
 Add object to workcell.
 
void add (rw::core::Ptr< rw::sensor::SensorModel > sensor)
 Add sensormodel to workcell.
 
void add (rw::core::Ptr< ControllerModel > controller)
 Add controllermodel to workcell.
 
void remove (rw::core::Ptr< Object > object)
 Remove object from workcell.
 
void remove (rw::core::Ptr< rw::models::Device > device)
 Remove device from workcell.
 
void remove (rw::core::Ptr< rw::sensor::SensorModel > sensor)
 Remove sensormodel from workcell.
 
void remove (rw::core::Ptr< ControllerModel > controller)
 Remove controllermodel from workcell.
 
rw::core::Ptr< rw::kinematics::StateStructuregetStateStructure ()
 gets the complete state structure of the workcell. More...
 
WorkCellChangedEventworkCellChangedEvent ()
 Returns the work cell changed event. More...
 
rw::core::PropertyMapgetPropertyMap ()
 Properties of this workcell.
 
const rw::core::PropertyMapgetPropertyMap () const
 Properties of this workcell. More...
 
rw::proximity::CollisionSetup getCollisionSetup ()
 Returns collision setup associated to work cell. More...
 
rw::core::Ptr< rw::graphics::SceneDescriptorgetSceneDescriptor ()
 Get the scene descriptor. More...
 
void setSceneDescriptor (rw::core::Ptr< rw::graphics::SceneDescriptor > scene)
 Set the scene descriptor. More...
 
std::string getFilename () const
 Returns the full path and filename of the workcell. More...
 
std::string getFilePath () const
 Returns the path of where the work cell is located. More...
 
const std::string & getCalibrationFilename () const
 Returns the filename of the calibration associated to the work cell. More...
 
void setCalibrationFilename (const std::string &calibrationFilename)
 Sets the filename of the calibration file. More...
 

Detailed Description

WorkCell keeps track of devices, obstacles and objects in the scene.

WorkCell is a pretty dumb container to which you can add your devices and the frames you your GUI to show as objects or camera views.

WorkCell is responsible for keeping track of everything including all devices, object and obstacles in the environment. WorkCell contains the World Frame, which represents the root and the only frame without a parent.

Member Enumeration Documentation

◆ WorkCellEventType

WorkCell Event Types.

Enumerator
STATE_DATA_ADDED 

StateData was added to state structure.

STATE_DATA_REMOVED 

StateData was removed from state structure.

WORKCELL_CHANGED 

WorkCell changed (such as addition or removal of Device, Frame, Object, SensorModel, or ControllerModel).

Constructor & Destructor Documentation

◆ WorkCell() [1/2]

WorkCell ( const std::string &  name)

Constructs an empty WorkCell.

Parameters
name[in] The name of the workcell. A good name for the workcell would be the (eventual) file that the workcell was loaded from.

◆ WorkCell() [2/2]

WorkCell ( rw::core::Ptr< rw::kinematics::StateStructure tree,
const std::string &  name = "",
const std::string &  filename = "" 
)

Constructs a WorkCell.

Parameters
tree[in] The (initial) tree structure of the WorkCell
name[in] The name of the workcell. A good name for the workcell would be the (eventual) file that the workcell was loaded from.
filename[in] The filename from which the workcell is loaded.

◆ ~WorkCell()

~WorkCell ( )

Destroys a work cell including the devices that have been added.

Management of the frames is done by a tree of which the work cell knows nothing. Therefore if this kinematics tree is still in existence (which it probably is), then the frames that used to be accessible via this work cell will still be valid.

Member Function Documentation

◆ addDAF() [1/2]

void addDAF ( rw::core::Ptr< rw::kinematics::Frame frame,
rw::core::Ptr< rw::kinematics::Frame parent = NULL 
)

Adds dynamically attachable frame (DAF) frame with parent as parent.

If parent == NULL, then world is used as parent

Parameters
frame[in] Frame to add
parent[in] Parent frame - uses World is parent == NULL

◆ addDAF() [2/2]

void addDAF ( rw::kinematics::Frame frame,
rw::kinematics::Frame parent = NULL 
)

Adds dynamically attachable frame (DAF) frame with parent as parent.

If parent == NULL, then world is used as parent

Parameters
frame[in] Frame to add
parent[in] Parent frame - uses World is parent == NULL
Deprecated:
Since January 2018. Please use the addDAF method using smart pointers instead.

◆ addDevice()

void addDevice ( rw::core::Ptr< rw::models::Device device)

Adds a Device to the WorkCell.

Ownership of device is taken.

Parameters
device[in] pointer to device.

◆ addFrame() [1/2]

void addFrame ( rw::core::Ptr< rw::kinematics::Frame frame,
rw::core::Ptr< rw::kinematics::Frame parent = NULL 
)

Adds frame with parent as parent.

If parent == NULL, then world is used as parent

Parameters
frame[in] Frame to add
parent[in] Parent frame - uses World is parent == NULL

◆ addFrame() [2/2]

void addFrame ( rw::kinematics::Frame frame,
rw::kinematics::Frame parent = NULL 
)

Adds frame with parent as parent.

If parent == NULL, then world is used as parent

Parameters
frame[in] Frame to add
parent[in] Parent frame - uses World is parent == NULL
Deprecated:
Since January 2018. Please use the addFrame method using smart pointers instead.

◆ findController() [1/2]

rw::core::Ptr<rw::models::ControllerModel> findController ( const std::string &  name) const

Returns controller with the specified name.

If multiple controlelrs has the same name, the first controller encountered will be returned. If no controller is found, the method returns NULL.

Parameters
name[in] name of controller.
Returns
The controller with name name or NULL if no such controller.

◆ findController() [2/2]

rw::core::Ptr<T> findController ( const std::string &  name) const
inline

Returns controller with the specified name and type T.

Parameters
name[in] name of controller.
Returns
The sensor with name name or NULL if no such sensor or the sensor is not of type T.

◆ findDevice() [1/2]

rw::core::Ptr<rw::models::Device> findDevice ( const std::string &  name) const

The device named name of the workcell.

NULL is returned if there is no such device.

Parameters
name[in] The device name
Returns
The device named name or NULL if no such device.

◆ findDevice() [2/2]

rw::core::Ptr<T> findDevice ( const std::string &  name) const
inline

The device named name of the workcell.

NULL is returned if there is no such device or if the device is not of type T.

Parameters
name[in] The workcell name
Returns
The device named name or NULL if no such device is found or if the device is not of type T.

◆ findDevices()

std::vector<rw::core::Ptr<T> > findDevices ( ) const
inline

Returns a vector with pointers to the Device(s) with a specific type T in the WorkCell.

Returns
vector with pointers to Device(s) of type T.

◆ findFrame() [1/2]

rw::kinematics::Frame* findFrame ( const std::string &  name) const

Returns frame with the specified name.

If multiple frames has the same name, the first frame encountered will be returned. If no frame is found, the method returns NULL.

Parameters
name[in] name of Frame.
Returns
The frame with name name or NULL if no such frame.

◆ findFrame() [2/2]

T* findFrame ( const std::string &  name) const
inline

Returns frame with the specified name and type T.

If multiple frames has the same name, the first frame encountered will be returned. If no frame is found, the method returns NULL. if a frame is found and it is nt of type T then NULL is returned.

Parameters
name[in] name of Frame.
Returns
The frame with name name or NULL if no such frame or the frame is not of type T.

◆ findFrames()

std::vector<T*> findFrames ( ) const
inline

Returns all frames of a specific type T.

Returns
all frames of type T in the workcell

◆ findObject()

rw::core::Ptr<Object> findObject ( const std::string &  name) const

The object named name of the workcell.

NULL is returned if there is no such object.

Parameters
name[in] The object name
Returns
The object named name or NULL if no such object.

◆ findSensor() [1/2]

rw::core::Ptr<rw::sensor::SensorModel> findSensor ( const std::string &  name) const

Returns sensor with the specified name.

If multiple sensors has the same name, the first sensor encountered will be returned. If no sensor is found, the method returns NULL.

Parameters
name[in] name of sensor.
Returns
The sensor with name name or NULL if no such sensor.

◆ findSensor() [2/2]

rw::core::Ptr<T> findSensor ( const std::string &  name) const
inline

Returns sensor with the specified name and type T.

If multiple sensors has the same name, the first sensor encountered will be returned. If no sensor is found, the method returns NULL. if a sensor is found and it is nt of type T then NULL is returned.

Parameters
name[in] name of sensor.
Returns
The sensor with name name or NULL if no such sensor or the sensor is not of type T.

◆ findSensors()

std::vector<rw::core::Ptr<T> > findSensors ( ) const
inline

Returns all frames of a specific type T.

Returns
all frames of type T in the workcell

◆ getCalibrationFilename()

const std::string& getCalibrationFilename ( ) const

Returns the filename of the calibration associated to the work cell.

Returns an empty string in case no calibration is associated.

To load the file use the getFilePath()+getCalibrationFilename() to get the absolute location

◆ getCollisionSetup()

rw::proximity::CollisionSetup getCollisionSetup ( )

Returns collision setup associated to work cell.

Returns
Collision setup

◆ getControllers()

std::vector<rw::core::Ptr<ControllerModel> > getControllers ( ) const

Returns all controllers in workcell.

Returns
List of all controllers

◆ getDefaultState()

rw::kinematics::State getDefaultState ( ) const

Returns a default State.

Returns
default State

◆ getDevices()

const std::vector<rw::core::Ptr<rw::models::Device> >& getDevices ( ) const

Returns a reference to a vector with pointers to the Device(s) in the WorkCell.

Returns
const vector with pointers to rw::models::Device(s).

◆ getFilename()

std::string getFilename ( ) const

Returns the full path and filename of the workcell.

If the workcell is loaded from file, then this method returns the full filename. Otherwise it returns an empty string.

◆ getFilePath()

std::string getFilePath ( ) const

Returns the path of where the work cell is located.

If the workcell is not loaded from file, it returns an empty string

◆ getFrames()

std::vector<rw::kinematics::Frame*> getFrames ( ) const

Returns all frames in workcell.

Returns
List of all frames

◆ getName()

std::string getName ( ) const
inline

The name of the workcell or the empty string if no name was provided.

Returns
the name of the workcell

◆ getObjects()

std::vector<rw::core::Ptr<Object> > getObjects ( ) const
inline

Returns all object in the work cell.

Returns
All object in work cell

◆ getPropertyMap()

const rw::core::PropertyMap& getPropertyMap ( ) const

Properties of this workcell.

Returns
the property map including the properties of this workcell

◆ getSceneDescriptor()

rw::core::Ptr<rw::graphics::SceneDescriptor> getSceneDescriptor ( )
inline

Get the scene descriptor.

Returns
the scene descriptor.

◆ getSensors()

std::vector<rw::core::Ptr<rw::sensor::SensorModel> > getSensors ( ) const

Returns all frames in workcell.

Returns
List of all frames

◆ getStateStructure()

rw::core::Ptr<rw::kinematics::StateStructure> getStateStructure ( )
inline

gets the complete state structure of the workcell.

Returns
the state structure of the workcell.

◆ getWorldFrame()

rw::kinematics::Frame* getWorldFrame ( ) const

Returns pointer to the world frame.

Returns
Pointer to the world frame

◆ remove() [1/2]

void remove ( rw::core::Ptr< rw::kinematics::Frame frame)

Removes frame from work cell.

Parameters
frame[in] Frame to remove
Deprecated:
Since January 2018. Please use remove(rw::core::Ptr<rw::kinematics::Frame>) instead.

◆ remove() [2/2]

void remove ( rw::kinematics::Frame frame)

Removes frame from work cell.

Parameters
frame[in] Frame to remove

◆ removeObject()

void removeObject ( Object object)

Removes object from workcell.

Parameters
object[in] Object to remove

◆ setCalibrationFilename()

void setCalibrationFilename ( const std::string &  calibrationFilename)

Sets the filename of the calibration file.

Parameters
calibrationFilename[in] Filename of calibration file with path relative to the work cell path.

◆ setSceneDescriptor()

void setSceneDescriptor ( rw::core::Ptr< rw::graphics::SceneDescriptor scene)
inline

Set the scene descriptor.

Parameters
scene[in] the scene descriptor.

◆ workCellChangedEvent()

WorkCellChangedEvent& workCellChangedEvent ( )
inline

Returns the work cell changed event.

Returns

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