Resources

Topics

RobWorkProject
List of all members | Public Types | Public Member Functions | Protected Member Functions
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 }
 
typedef rw::common::Ptr< WorkCellPtr
 smart pointer type to this class
 
typedef boost::function< void(int)> WorkCellChangedListener
 Definition of work cell changed listener.
 
typedef rw::common::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 (kinematics::StateStructure::Ptr 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.
 
kinematics::FramegetWorldFrame () const
 Returns pointer to the world frame. More...
 
void addFrame (kinematics::Frame *frame, kinematics::Frame *parent=NULL)
 Adds frame with parent as parent. More...
 
void addDAF (kinematics::Frame *frame, kinematics::Frame *parent=NULL)
 Adds dynamically attachable frame (DAF) frame with parent as parent. More...
 
void remove (kinematics::Frame *frame)
 Removes frame from work cell. More...
 
void removeObject (Object *object)
 Removes object from workcell. More...
 
void addDevice (rw::common::Ptr< Device > device)
 Adds a Device to the WorkCell. More...
 
const std::vector< rw::common::Ptr< Device > > & getDevices () const
 Returns a reference to a vector with pointers to the Device(s) in the WorkCell. More...
 
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::common::Ptr< DevicefindDevice (const std::string &name) const
 The device named name of the workcell. More...
 
template<class T >
rw::common::Ptr< T > findDevice (const std::string &name) const
 The device named name of the workcell. More...
 
template<class T >
std::vector< rw::common::Ptr< T > > findDevices () const
 Returns a vector with pointers to the Device(s) with a specific type T in the WorkCell. More...
 
kinematics::State getDefaultState () const
 Returns a default State. More...
 
rw::sensor::SensorModel::Ptr findSensor (const std::string &name) const
 Returns sensor with the specified name. More...
 
template<class T >
rw::common::Ptr< T > findSensor (const std::string &name) const
 Returns sensor with the specified name and type T. More...
 
template<class T >
std::vector< rw::common::Ptr< T > > findSensors () const
 Returns all frames of a specific type T. More...
 
std::vector< rw::sensor::SensorModel::PtrgetSensors () const
 Returns all frames in workcell. More...
 
rw::models::ControllerModel::Ptr findController (const std::string &name) const
 Returns controller with the specified name. More...
 
template<class T >
rw::common::Ptr< T > findController (const std::string &name) const
 Returns controller with the specified name and type T. More...
 
template<class T >
std::vector< rw::common::Ptr< T > > findControllers () const
 Returns all controllers of a specific type T.
 
std::vector< ControllerModel::PtrgetControllers () const
 Returns all frames in workcell. More...
 
std::vector< Object::PtrgetObjects () const
 Returns all object in the work cell. More...
 
rw::common::Ptr< ObjectfindObject (const std::string &name) const
 The object named name of the workcell. More...
 
void add (rw::common::Ptr< Device > device)
 Add device to workcell.
 
void add (rw::common::Ptr< Object > object)
 Add object to workcell.
 
void add (rw::common::Ptr< rw::sensor::SensorModel > sensor)
 Add sensormodel to workcell.
 
void add (rw::common::Ptr< ControllerModel > controller)
 Add controllermodel to workcell.
 
void remove (rw::common::Ptr< Object > object)
 Remove object from workcell.
 
void remove (rw::common::Ptr< Device > device)
 Remove device from workcell.
 
void remove (rw::common::Ptr< rw::sensor::SensorModel > sensor)
 Remove sensormodel from workcell.
 
void remove (rw::common::Ptr< ControllerModel > controller)
 Remove controllermodel from workcell.
 
rw::common::Ptr< rw::kinematics::StateStructuregetStateStructure ()
 gets the complete state structure of the workcell. More...
 
WorkCellChangedEventworkCellChangedEvent ()
 Returns the work cell changed event. More...
 
rw::common::PropertyMapgetPropertyMap ()
 Properties of this workcell.
 
rw::proximity::CollisionSetup getCollisionSetup ()
 Returns collision setup associated to work cell. More...
 
rw::graphics::SceneDescriptor::Ptr getSceneDescriptor ()
 
void setSceneDescriptor (rw::graphics::SceneDescriptor::Ptr scene)
 
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...
 

Protected Member Functions

void stateDataAddedListener (const rw::kinematics::StateData *data)
 
void stateDataRemovedListener (const rw::kinematics::StateData *data)
 

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.

Constructor & Destructor Documentation

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 ( kinematics::StateStructure::Ptr  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 ( )

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

void addDAF ( kinematics::Frame frame,
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
void addDevice ( rw::common::Ptr< Device device)

Adds a Device to the WorkCell.

Ownership of device is taken.

Parameters
device[in] pointer to device.
void addFrame ( kinematics::Frame frame,
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
rw::models::ControllerModel::Ptr 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.
rw::common::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.
rw::common::Ptr<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.
rw::common::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.
std::vector<rw::common::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.
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.
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.
std::vector<T*> findFrames ( ) const
inline

Returns all frames of a specific type T.

Returns
all frames of type T in the workcell
rw::common::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.
rw::sensor::SensorModel::Ptr 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.
rw::common::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.
std::vector<rw::common::Ptr<T> > findSensors ( ) const
inline

Returns all frames of a specific type T.

Returns
all frames of type T in the workcell
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

rw::proximity::CollisionSetup getCollisionSetup ( )

Returns collision setup associated to work cell.

Returns
Collision setup
std::vector<ControllerModel::Ptr> getControllers ( ) const
inline

Returns all frames in workcell.

Returns
List of all frames
kinematics::State getDefaultState ( ) const

Returns a default State.

Returns
default State
const std::vector<rw::common::Ptr<Device> >& getDevices ( ) const

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

Returns
const vector with pointers to Device(s).
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.

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

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

Returns all frames in workcell.

Returns
List of all frames
std::vector<Object::Ptr> getObjects ( ) const
inline

Returns all object in the work cell.

Returns
All object in work cell
std::vector<rw::sensor::SensorModel::Ptr> getSensors ( ) const
inline

Returns all frames in workcell.

Returns
List of all frames
rw::common::Ptr<rw::kinematics::StateStructure> getStateStructure ( )
inline

gets the complete state structure of the workcell.

Returns
the state structure of the workcell.
kinematics::Frame* getWorldFrame ( ) const

Returns pointer to the world frame.

Returns
Pointer to the world frame
void remove ( kinematics::Frame frame)

Removes frame from work cell.

Parameters
frame[in] Frame to remove
void removeObject ( Object object)

Removes object from workcell.

Parameters
object[in] Object to remove
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.
WorkCellChangedEvent& workCellChangedEvent ( )
inline

Returns the work cell changed event.

Returns

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