Simox  2.3.49
VirtualRobot::SceneObject Class Reference
Inheritance diagram for VirtualRobot::SceneObject:
VirtualRobot::Obstacle VirtualRobot::Robot VirtualRobot::RobotNode VirtualRobot::Sensor VirtualRobot::ManipulationObject VirtualRobot::LocalRobot VirtualRobot::RobotNodeFixed VirtualRobot::RobotNodePrismatic VirtualRobot::RobotNodeRevolute VirtualRobot::CameraSensor VirtualRobot::ContactSensor VirtualRobot::ForceTorqueSensor VirtualRobot::PositionSensor

Data Structures

struct  Physics
 

Public Types

enum  VisualizationType { Full, Collision, CollisionData }
 

Public Member Functions

 SceneObject (const std::string &name, VisualizationNodePtr visualization=VisualizationNodePtr(), CollisionModelPtr collisionModel=CollisionModelPtr(), const Physics &p=Physics(), CollisionCheckerPtr colChecker=CollisionCheckerPtr())
 
virtual ~SceneObject ()
 
std::string getName () const
 
void setName (const std::string &name)
 
virtual Eigen::Matrix4f getGlobalPose () const
 
virtual void setGlobalPoseNoChecks (const Eigen::Matrix4f &pose)
 
virtual void setGlobalPose (const Eigen::Matrix4f &pose)
 
virtual CollisionModelPtr getCollisionModel ()
 
virtual CollisionCheckerPtr getCollisionChecker ()
 
void setVisualization (VisualizationNodePtr visualization)
 
void setCollisionModel (CollisionModelPtr colModel)
 
virtual VisualizationNodePtr getVisualization (SceneObject::VisualizationType visuType=SceneObject::Full)
 
virtual bool initialize (SceneObjectPtr parent=SceneObjectPtr(), const std::vector< SceneObjectPtr > &children=std::vector< SceneObjectPtr >())
 
virtual void setUpdateVisualization (bool enable)
 
bool getUpdateVisualizationStatus ()
 
virtual void setUpdateCollisionModel (bool enable)
 
bool getUpdateCollisionModelStatus ()
 
virtual void setupVisualization (bool showVisualization, bool showAttachedVisualizations)
 
virtual void showCoordinateSystem (bool enable, float scaling=1.0f, std::string *text=NULL, const std::string &visualizationType="")
 
virtual void showPhysicsInformation (bool enableCoM, bool enableInertial, VisualizationNodePtr comModel=VisualizationNodePtr())
 
virtual bool showCoordinateSystemState ()
 
virtual void showBoundingBox (bool enable, bool wireframe=false)
 
virtual bool ensureVisualization (const std::string &visualizationType="")
 
Eigen::Matrix4f toLocalCoordinateSystem (const Eigen::Matrix4f &poseGlobal) const
 
Eigen::Vector3f toLocalCoordinateSystemVec (const Eigen::Vector3f &positionGlobal) const
 
Eigen::Matrix4f toGlobalCoordinateSystem (const Eigen::Matrix4f &poseLocal) const
 
Eigen::Vector3f toGlobalCoordinateSystemVec (const Eigen::Vector3f &positionLocal) const
 
Eigen::Matrix4f getTransformationTo (const SceneObjectPtr otherObject)
 
Eigen::Matrix4f getTransformationFrom (const SceneObjectPtr otherObject)
 
Eigen::Matrix4f transformTo (const SceneObjectPtr otherObject, const Eigen::Matrix4f &poseInOtherCoordSystem)
 
Eigen::Vector3f transformTo (const SceneObjectPtr otherObject, const Eigen::Vector3f &positionInOtherCoordSystem)
 
virtual int getNumFaces (bool collisionModel=false)
 
virtual Eigen::Vector3f getCoMLocal ()
 
virtual Eigen::Vector3f getCoMGlobal ()
 
float getMass () const
 
void setMass (float m)
 
Physics::SimulationType getSimulationType () const
 
void setSimulationType (Physics::SimulationType s)
 
Eigen::Matrix3f getInertiaMatrix ()
 
void setInertiaMatrix (const Eigen::Matrix3f &im)
 
SceneObject::Physics getPhysics ()
 
std::vector< std::string > getIgnoredCollisionModels ()
 
virtual void print (bool printChildren=false, bool printDecoration=true) const
 
template<typename T >
boost::shared_ptr< T > getVisualization (SceneObject::VisualizationType visuType=SceneObject::Full)
 
void highlight (VisualizationPtr visualization, bool enable)
 
SceneObjectPtr clone (const std::string &name, CollisionCheckerPtr colChecker=CollisionCheckerPtr(), float scaling=1.0f) const
 
virtual bool attachChild (SceneObjectPtr child)
 
virtual void detachChild (SceneObjectPtr child)
 
virtual bool hasChild (SceneObjectPtr child, bool recursive=false) const
 
virtual bool hasChild (const std::string &childName, bool recursive=false) const
 
virtual bool hasParent ()
 
virtual SceneObjectPtr getParent () const
 
virtual std::vector< SceneObjectPtrgetChildren () const
 
virtual void updatePose (bool updateChildren=true)
 Compute the global pose of this object. More...
 
virtual bool saveModelFiles (const std::string &modelPath, bool replaceFilenames)
 

Protected Member Functions

virtual SceneObject_clone (const std::string &name, CollisionCheckerPtr colChecker=CollisionCheckerPtr(), float scaling=1.0f) const
 
virtual void detachedFromParent ()
 Parent detached this object. More...
 
virtual void attached (SceneObjectPtr parent)
 Parent attached this object. More...
 
virtual void updatePose (const Eigen::Matrix4f &parentPose, bool updateChildren=true)
 
std::string getFilenameReplacementVisuModel (const std::string standardExtension=".wrl")
 
std::string getFilenameReplacementColModel (const std::string standardExtension=".wrl")
 
 SceneObject ()
 
std::string getSceneObjectXMLString (const std::string &basePath, int tabs)
 basic data, used by Obstacle and ManipulationObject More...
 
virtual bool initializePhysics ()
 

Protected Attributes

std::string name
 
bool initialized
 
Eigen::Matrix4f globalPose
 
std::vector< SceneObjectPtrchildren
 
SceneObjectWeakPtr parent
 
CollisionModelPtr collisionModel
 
VisualizationNodePtr visualizationModel
 
bool updateVisualization
 
bool updateCollisionModel
 
Physics physics
 
CollisionCheckerPtr collisionChecker
 

Friends

class RobotFactory
 

Member Enumeration Documentation

Enumerator
Full 

the full model

Collision 

the collision model

CollisionData 

a visualization of the collision model data that is internally used (this mode is only for debug purposes, the model is static, i.e. updates/movements/rotations are not visualized!)

Constructor & Destructor Documentation

VirtualRobot::SceneObject::SceneObject ( const std::string &  name,
VisualizationNodePtr  visualization = VisualizationNodePtr(),
CollisionModelPtr  collisionModel = CollisionModelPtr(),
const Physics p = Physics(),
CollisionCheckerPtr  colChecker = CollisionCheckerPtr() 
)
VirtualRobot::SceneObject::~SceneObject ( )
virtual
VirtualRobot::SceneObject::SceneObject ( )
inlineprotected

Member Function Documentation

SceneObject * VirtualRobot::SceneObject::_clone ( const std::string &  name,
CollisionCheckerPtr  colChecker = CollisionCheckerPtr(),
float  scaling = 1.0f 
) const
protectedvirtual
bool VirtualRobot::SceneObject::attachChild ( SceneObjectPtr  child)
virtual

Attach a connected object. The connected object is linked to this SceneObject and moves accordingly. Any call to the child's setGlobalPose is forbidden and will fail.

Parameters
childThe child to attach
void VirtualRobot::SceneObject::attached ( SceneObjectPtr  parent)
protectedvirtual

Parent attached this object.

SceneObjectPtr VirtualRobot::SceneObject::clone ( const std::string &  name,
CollisionCheckerPtr  colChecker = CollisionCheckerPtr(),
float  scaling = 1.0f 
) const

Clones this object. If no col checker is given, the one of the original object is used.

void VirtualRobot::SceneObject::detachChild ( SceneObjectPtr  child)
virtual

Removes the child from children list.

void VirtualRobot::SceneObject::detachedFromParent ( )
protectedvirtual

Parent detached this object.

bool VirtualRobot::SceneObject::ensureVisualization ( const std::string &  visualizationType = "")
virtual

Builds a dummy visualization if necessary.

Parameters
visualizationTypeIf given the visualization is forced to be this type. If not set, the first registered visualization from VisualizationFactory is used.
std::vector< SceneObjectPtr > VirtualRobot::SceneObject::getChildren ( ) const
virtual
VirtualRobot::CollisionCheckerPtr VirtualRobot::SceneObject::getCollisionChecker ( )
virtual

Reimplemented in VirtualRobot::Robot.

VirtualRobot::CollisionModelPtr VirtualRobot::SceneObject::getCollisionModel ( )
virtual
Eigen::Vector3f VirtualRobot::SceneObject::getCoMGlobal ( )
virtual

Return Center of Mass in global coordinates. This method does not consider children.

Reimplemented in VirtualRobot::Robot.

Eigen::Vector3f VirtualRobot::SceneObject::getCoMLocal ( )
virtual

Return Center of Mass in local coordinate frame. This method does not consider children.

Reimplemented in VirtualRobot::Robot.

std::string VirtualRobot::SceneObject::getFilenameReplacementColModel ( const std::string  standardExtension = ".wrl")
protected
std::string VirtualRobot::SceneObject::getFilenameReplacementVisuModel ( const std::string  standardExtension = ".wrl")
protected
Eigen::Matrix4f VirtualRobot::SceneObject::getGlobalPose ( ) const
virtual

The global pose defines the position of the object in the world. For non-joint objects it is identical with the visualization frame.

Reimplemented in VirtualRobot::LocalRobot, and VirtualRobot::RobotNode.

std::vector< std::string > VirtualRobot::SceneObject::getIgnoredCollisionModels ( )

Collisions with these models are ignored by physics engine (only considered within the SimDynamics package!).

Eigen::Matrix3f VirtualRobot::SceneObject::getInertiaMatrix ( )
float VirtualRobot::SceneObject::getMass ( ) const

Mass in Kg

std::string VirtualRobot::SceneObject::getName ( ) const
int VirtualRobot::SceneObject::getNumFaces ( bool  collisionModel = false)
virtual

get number of faces (i.e. triangles) of this object collisionModel Indicates weather the faces of the collision model or the full model should be returned.

Reimplemented in VirtualRobot::Robot.

VirtualRobot::SceneObjectPtr VirtualRobot::SceneObject::getParent ( ) const
virtual
Returns
If this object is attached, the parent is returned. Otherwise an empty object is returned.
SceneObject::Physics VirtualRobot::SceneObject::getPhysics ( )
std::string VirtualRobot::SceneObject::getSceneObjectXMLString ( const std::string &  basePath,
int  tabs 
)
protected

basic data, used by Obstacle and ManipulationObject

SceneObject::Physics::SimulationType VirtualRobot::SceneObject::getSimulationType ( ) const

The simulation type is of interest in SimDynamics.

Eigen::Matrix4f VirtualRobot::SceneObject::getTransformationFrom ( const SceneObjectPtr  otherObject)

Returns the transformation matrix from otherObject to this object

Eigen::Matrix4f VirtualRobot::SceneObject::getTransformationTo ( const SceneObjectPtr  otherObject)

Returns the transformation matrix from this object to otherObject

bool VirtualRobot::SceneObject::getUpdateCollisionModelStatus ( )
bool VirtualRobot::SceneObject::getUpdateVisualizationStatus ( )
VirtualRobot::VisualizationNodePtr VirtualRobot::SceneObject::getVisualization ( SceneObject::VisualizationType  visuType = SceneObject::Full)
virtual

Return visualization object.

Parameters
visuTypeSet the type of visualization.
template<typename T >
boost::shared_ptr< T > VirtualRobot::SceneObject::getVisualization ( SceneObject::VisualizationType  visuType = SceneObject::Full)

Retrieve a visualization in the given format. Example usage: boost::shared_ptr<VirtualRobot::CoinVisualization> visualization = robot->getVisualization<CoinVisualization>(); SoNode* visualisationNode = NULL; if (visualization) visualisationNode = visualization->getCoinVisualization();

See also
CoinVisualizationFactory::getCoinVisualization() for convenient access!

This method creates a new Visualization subclass which is given by the template parameter T. T must be a subclass of VirtualRobot::Visualization. A compile time error is thrown if a different class type is used as template argument.

bool VirtualRobot::SceneObject::hasChild ( SceneObjectPtr  child,
bool  recursive = false 
) const
virtual
Returns
true, if child is attached
bool VirtualRobot::SceneObject::hasChild ( const std::string &  childName,
bool  recursive = false 
) const
virtual
Returns
true, if child is attached
bool VirtualRobot::SceneObject::hasParent ( )
virtual
Returns
true, if this object is attached to another object.
VisualizationNode VirtualRobot::SceneObject::highlight ( VisualizationPtr  visualization,
bool  enable 
)

Convenient method for highlighting the visualization of this object. It is automatically checked whether the collision model or the full model is part of the visualization.

See also
Parameters
visualizationThe visualization for which the highlighting should be performed.
enableSet or unset highlighting.
bool VirtualRobot::SceneObject::initialize ( SceneObjectPtr  parent = SceneObjectPtr(),
const std::vector< SceneObjectPtr > &  children = std::vector<SceneObjectPtr>() 
)
virtual

Initialize this object. Optionally the parents and children can be specified.

Reimplemented in VirtualRobot::RobotNode, VirtualRobot::Sensor, VirtualRobot::RobotNodeRevolute, VirtualRobot::RobotNodePrismatic, and VirtualRobot::RobotNodeFixed.

bool VirtualRobot::SceneObject::initializePhysics ( )
protectedvirtual
bool VirtualRobot::SceneObject::saveModelFiles ( const std::string &  modelPath,
bool  replaceFilenames 
)
virtual

Saves model files (visu and col model, if present) to model path.

Parameters
modelPathThe path where the model files should be stored.
replsceFilenamesIf set, the filenames will be replaced with 'name_visu' and 'name_col'. Otherwise the original filename is used without any preceding paths.
void VirtualRobot::SceneObject::setCollisionModel ( CollisionModelPtr  colModel)
void VirtualRobot::SceneObject::setGlobalPose ( const Eigen::Matrix4f &  pose)
virtual

Update the pose of this object. The visualization and collision models are updated accordingly.

Parameters
poseThe new pose of this object

Reimplemented in VirtualRobot::LocalRobot, VirtualRobot::Robot, VirtualRobot::RobotNode, and VirtualRobot::Sensor.

void VirtualRobot::SceneObject::setGlobalPoseNoChecks ( const Eigen::Matrix4f &  pose)
virtual

Usually it is checked weather the object is linked to a parent. This check can be omitted (be careful, just do this if you know the effects)

Parameters
poseThe new pose of this object
void VirtualRobot::SceneObject::setInertiaMatrix ( const Eigen::Matrix3f &  im)
void VirtualRobot::SceneObject::setMass ( float  m)
void VirtualRobot::SceneObject::setName ( const std::string &  name)

Rename this object

void VirtualRobot::SceneObject::setSimulationType ( Physics::SimulationType  s)
void VirtualRobot::SceneObject::setUpdateCollisionModel ( bool  enable)
virtual

Reimplemented in VirtualRobot::Robot.

void VirtualRobot::SceneObject::setUpdateVisualization ( bool  enable)
virtual

Enables/Disables the visualization updates of collision model and visualization model.

Reimplemented in VirtualRobot::Robot.

void VirtualRobot::SceneObject::setupVisualization ( bool  showVisualization,
bool  showAttachedVisualizations 
)
virtual

Setup the visualization of this object.

Parameters
showVisualizationIf false, the visualization is disabled.
showAttachedVisualizationsIf false, the visualization of any attached optional visualizations is disabled.

Reimplemented in VirtualRobot::Robot.

void VirtualRobot::SceneObject::setVisualization ( VisualizationNodePtr  visualization)

Sets the main visualization of this object.

void VirtualRobot::SceneObject::showBoundingBox ( bool  enable,
bool  wireframe = false 
)
virtual

Display the bounding box of this object's collisionModel. The bbox is not updated when you move the object, so you have to call this method again after touching the scene in order to ensure a correct visualization. If the object does not own a visualization yet, the VisualizationFactory is queried to get the first registered VisualizationType in order to build a valid visualization. enable Show or hide bounding box wireframe Wireframe or solid visualization.

void VirtualRobot::SceneObject::showCoordinateSystem ( bool  enable,
float  scaling = 1.0f,
std::string *  text = NULL,
const std::string &  visualizationType = "" 
)
virtual

Display the coordinate system of this object. If the object does not own a visualization yet, the VisualizationFactory is queried to get the first registered VisualizationType in order to build a valid visualization. enable Show or hide coordinate system scaling Size of coordinate system text Text to display at coordinate system. If not given, the name of this robot node will be displayed.

Reimplemented in VirtualRobot::RobotNode.

bool VirtualRobot::SceneObject::showCoordinateSystemState ( )
virtual

Returns true when the coordinate system is currently shown.

void VirtualRobot::SceneObject::showPhysicsInformation ( bool  enableCoM,
bool  enableInertial,
VisualizationNodePtr  comModel = VisualizationNodePtr() 
)
virtual

Display some physics debugging information. enableCoM If true, the center of mass is shown (if given). If a comModel is given it is used for visualization, otherwise a standrad marker is shown. enableInertial If true, a visualization of the inertial matrix is shown (if given). comModel If set, this visualization is used to display the CoM location. If not set, a standard marker is used.

Reimplemented in VirtualRobot::Robot.

Eigen::Matrix4f VirtualRobot::SceneObject::toGlobalCoordinateSystem ( const Eigen::Matrix4f &  poseLocal) const

Transforms the pose, given in local coordinate system, to the global coordinate system.

Parameters
poseLocalThe pose, given in local coordinate system of this joint, that should be transformed to the global coordinate system.
Returns
The transformed pose.
Eigen::Vector3f VirtualRobot::SceneObject::toGlobalCoordinateSystemVec ( const Eigen::Vector3f &  positionLocal) const
Eigen::Matrix4f VirtualRobot::SceneObject::toLocalCoordinateSystem ( const Eigen::Matrix4f &  poseGlobal) const

Transforms the pose, given in global coordinate system, to the local coordinate system of this object.

Parameters
poseGlobalThe pose, given in global coordinate system, that should be transformed to the local coordinate system of this joint.
Returns
The transformed pose.
Eigen::Vector3f VirtualRobot::SceneObject::toLocalCoordinateSystemVec ( const Eigen::Vector3f &  positionGlobal) const
Eigen::Matrix4f VirtualRobot::SceneObject::transformTo ( const SceneObjectPtr  otherObject,
const Eigen::Matrix4f &  poseInOtherCoordSystem 
)

Transform pose to local coordinate system of this object

Eigen::Vector3f VirtualRobot::SceneObject::transformTo ( const SceneObjectPtr  otherObject,
const Eigen::Vector3f &  positionInOtherCoordSystem 
)

Transform position to local coordinate system of this object

void VirtualRobot::SceneObject::updatePose ( bool  updateChildren = true)
virtual

Compute the global pose of this object.

Reimplemented in VirtualRobot::RobotNode, and VirtualRobot::Sensor.

void VirtualRobot::SceneObject::updatePose ( const Eigen::Matrix4f &  parentPose,
bool  updateChildren = true 
)
protectedvirtual

Friends And Related Function Documentation

friend class RobotFactory
friend

Field Documentation

std::vector<SceneObjectPtr> VirtualRobot::SceneObject::children
protected
CollisionCheckerPtr VirtualRobot::SceneObject::collisionChecker
protected
CollisionModelPtr VirtualRobot::SceneObject::collisionModel
protected
Eigen::Matrix4f VirtualRobot::SceneObject::globalPose
protected
bool VirtualRobot::SceneObject::initialized
protected
std::string VirtualRobot::SceneObject::name
protected
SceneObjectWeakPtr VirtualRobot::SceneObject::parent
protected
Physics VirtualRobot::SceneObject::physics
protected
bool VirtualRobot::SceneObject::updateCollisionModel
protected
bool VirtualRobot::SceneObject::updateVisualization
protected
VisualizationNodePtr VirtualRobot::SceneObject::visualizationModel
protected