A group of pysical objects (and the joints among them) on which it is possible to act as if they were a single WObject. More...
Public Types | |
typedef int | ChainIDType |
The type for chain IDs. | |
typedef int | ElementIDType |
The type for objects and joints IDs (inside chains) | |
Public Member Functions | |
PhyObjectsGroup (PhyObject *headObject, World *world, QString name="unamed") | |
Constructor. | |
~PhyObjectsGroup () | |
Destructor. | |
ElementIDType | addJointDOF (PhyJoint *joint, unsigned int dofID, ChainIDType chainID=ChainIDType()) |
Adds a DOF to the group. | |
ElementIDType | addObject (PhyObject *obj, ChainIDType chainID=ChainIDType()) |
Adds an object to the group. | |
void | enableJoints (bool b) |
Enables/Disables all joints in the group. | |
PhyObject * | getHeadObject () const |
Returns a pointer to the head object. | |
virtual void | postUpdate () |
The function called after updating the world. | |
virtual void | preUpdate () |
The function called before updating the world. | |
void | resetObjectPositions () |
Resets all objects and joints to their stored relative position. | |
void | setDOFPosition (real pos, ChainIDType chainID, ElementIDType dof) |
Moves a joint DOF to the desidered position by updating objects positions. | |
void | setKinematic (bool b) |
Changes between kinematic/dynamic behaviour for all objects of the group. | |
void | setStatic (bool b) |
Makes all objects static or not. | |
void | updateFromDOF () |
This updates all kinematic chains so to respect DOFs status. | |
void | updateRelativePositions () |
Updates the relative position of objects in the group. | |
Public Member Functions inherited from WObject | |
WObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity(), bool addToWorld=true) | |
create the object and automatically put this into the world | |
virtual | ~WObject () |
destroy the Object and drop it from the world | |
QColor | color () const |
return the color of this object | |
bool | isInvisible () |
return if it is invisible | |
const wMatrix & | matrix () const |
return a reference to the transformation matrix | |
QString | name () const |
Return the name of this object. | |
void | setAlpha (int alpha) |
set the value of alpha channel (the transparency) | |
void | setColor (QColor c) |
Set the color to use on rendering. | |
void | setInvisible (bool b) |
set invisibility | |
void | setMatrix (const wMatrix &newm) |
set a new matrix | |
void | setPosition (const wVector &newpos) |
set the position specified in global coordinate frame | |
void | setPosition (real x, real y, real z) |
set the position specified in global coordinate frame | |
void | setTexture (QString textureName) |
Set the texture to use for this WObject when rendered. | |
void | setUseColorTextureOfOwner (bool b) |
set if the object will be rendered with the color and texture of our owner (if we have one) | |
QString | texture () const |
Return the texture name. | |
bool | useColorTextureOfOwner () const |
if true, we will use color and texture of our owner (if we have one) | |
World * | world () |
Return the world. | |
const World * | world () const |
Return the world (const version) | |
Public Member Functions inherited from Ownable | |
Ownable () | |
Constructor. | |
virtual | ~Ownable () |
Destructor. | |
const QList< Owned > & | owned () const |
Returns the list of objects owned by this one. | |
Ownable * | owner () const |
Returns the owner of this object. | |
void | setOwner (Ownable *owner, bool destroy=true) |
Sets the owner of this object. | |
Additional Inherited Members | |
Protected Attributes inherited from WObject | |
QColor | colorv |
Color, it contains also alpha channel. | |
bool | invisible |
if TRUE it will not renderized | |
QString | namev |
Name of the WObject. | |
QString | texturev |
Texture name. | |
wMatrix | tm |
Trasformation matrix. | |
bool | usecolortextureofowner |
if true, we will use color and texture of our owner (if we have one). | |
World * | worldv |
World. | |
Detailed Description
A group of pysical objects (and the joints among them) on which it is possible to act as if they were a single WObject.
- Note
- This is NOT a PhyObject, it is a WObject This is used mainly for the hands in kinematic simulations. This is in fact set as the last object of the kinematic chain of arms. One object is chosen as the "head" of the group. The relative position of all objects with respect to the "head" is memorized when this object is created; when this object is moved (its matrix is changed), first the "head" of the group is moved and then all the other objects keeping their relative position/orientation. Each object/DOF in this group belongs to a chain. A chain is identified by a number. When an object/DOF is added to the group, it is appended to a chain. The setDOFPosition function can be used to move objects in a chain so that the joint reaches the specified position (this only works for rotational joints, for the moment). The order in the chain is important: when the joint i-th is moved, all objects with id greater or equal to i are moved (which means that their relative position matrix is changed). All chains start with the head object.
- Chains only affect the behaviour of the setDOFPosition functions, if you plan not to use that function, you can safely place all objects in the same chain.
- We have no responsability over objects in this group (e.g. we do not delete them when destroyed)
Definition at line 229 of file phyicubhelpers.h.
Member Typedef Documentation
typedef int ChainIDType |
The type for chain IDs.
Definition at line 237 of file phyicubhelpers.h.
typedef int ElementIDType |
The type for objects and joints IDs (inside chains)
The object with the same ID of a joint, is the child object of the joint
Definition at line 245 of file phyicubhelpers.h.
Constructor & Destructor Documentation
PhyObjectsGroup | ( | PhyObject * | headObject, |
World * | world, | ||
QString | name = "unamed" |
||
) |
Constructor.
- Parameters
-
headObject the head object (see class description) world the world to which this object belongs name the name for this object
Definition at line 196 of file phyicubhelpers.cpp.
References WObject::matrix(), and WObject::tm.
~PhyObjectsGroup | ( | ) |
Destructor.
Definition at line 206 of file phyicubhelpers.cpp.
Member Function Documentation
PhyObjectsGroup::ElementIDType addJointDOF | ( | PhyJoint * | joint, |
unsigned int | dofID, | ||
PhyObjectsGroup::ChainIDType | chainID = ChainIDType() |
||
) |
Adds a DOF to the group.
You should add all dofs of all joints between objects in the group
- Parameters
-
joint the joint to add dofID the id of the dof in the joint to add chainID the id of the chain to which this joint will be appended
Definition at line 225 of file phyicubhelpers.cpp.
References PhyJoint::dofs(), and PhyJoint::numDofs().
Referenced by PhyiCub::PhyiCub().
PhyObjectsGroup::ElementIDType addObject | ( | PhyObject * | obj, |
PhyObjectsGroup::ChainIDType | chainID = ChainIDType() |
||
) |
Adds an object to the group.
- Parameters
-
obj the object to add chainID the id of the chain to which this object will be appended
- Returns
- the ID of the object in the chain
Definition at line 216 of file phyicubhelpers.cpp.
References wMatrix::inverse(), and WObject::matrix().
Referenced by PhyiCub::PhyiCub().
void enableJoints | ( | bool | b | ) |
Enables/Disables all joints in the group.
See the description of the enable() method of the PhyJoint class for more information
- Parameters
-
b if true enables joints, if false disables them
Definition at line 255 of file phyicubhelpers.cpp.
|
inline |
Returns a pointer to the head object.
- Returns
- a pointer to the head object
Definition at line 384 of file phyicubhelpers.h.
Referenced by KinematicLimb< iCub::iKin::iCubArm >::createJoint().
|
virtual |
The function called after updating the world.
This does nothing
Reimplemented from WObject.
Definition at line 324 of file phyicubhelpers.cpp.
|
virtual |
The function called before updating the world.
This does nothing
Reimplemented from WObject.
Definition at line 320 of file phyicubhelpers.cpp.
|
inline |
Resets all objects and joints to their stored relative position.
Definition at line 324 of file phyicubhelpers.h.
Referenced by PhyiCub::changedMatrix(), PhyiCub::configurePosture(), and PhyiCub::preUpdate().
void setDOFPosition | ( | real | pos, |
PhyObjectsGroup::ChainIDType | chainID, | ||
PhyObjectsGroup::ElementIDType | dof | ||
) |
Moves a joint DOF to the desidered position by updating objects positions.
This changes the relative positions matrices, and also moves objects and updates joints.
- Parameters
-
pos the new position for the joint. This must be an angle in radiants for rotational joints or a position for linear joints. chainID the id of the chain dof the dof of the chain whose position has to be changed
- Note
- For the moment this only works for rotational joints
- Warning
- Before calling this make sure all elements are in their correct relative position (e.g. by calling resetObjectPositions()), otherwise objects are not correctly repositioned.
- The rotation is done around the inverted DOF axis. This is this way because when building the iCub the parent and child objects of joints are inverted in respect to kinematic chains considered here (e.g. in the first joint of each finger the child object is the hand palm, while the chain is from the palm to the finger). As this class is only used within the icub class, we haven't tried to generalize this.
Definition at line 276 of file phyicubhelpers.cpp.
References PhyDOF::axis(), PhyDOF::centre(), PhyJoint::dofs(), wMatrix::inverse(), PhyDOF::joint(), WObject::matrix(), PhyDOF::position(), and wMatrix::rotateAround().
Referenced by PhyiCub::configurePosture(), and PhyObjectsGroup::updateFromDOF().
void setKinematic | ( | bool | b | ) |
Changes between kinematic/dynamic behaviour for all objects of the group.
See the description of the setKinematic() method of the PhyObject class for more information
- Parameters
-
b if true objects are set to kinematic behaviour
Definition at line 233 of file phyicubhelpers.cpp.
References PhyObject::setKinematic().
void setStatic | ( | bool | b | ) |
Makes all objects static or not.
See the description of the setStatic() method of the PhyObject class for more information
- Parameters
-
b if true objects are static
Definition at line 244 of file phyicubhelpers.cpp.
References PhyObject::setStatic().
void updateFromDOF | ( | ) |
This updates all kinematic chains so to respect DOFs status.
This uses setDOFPosition, so the same warnings apply here
Definition at line 305 of file phyicubhelpers.cpp.
References PhyObjectsGroup::setDOFPosition().
Referenced by PhyiCub::preUpdate().
void updateRelativePositions | ( | ) |
Updates the relative position of objects in the group.
This changes all the matrix of objects relative to the root> object so they reflect the current state.
Definition at line 265 of file phyicubhelpers.cpp.
References wMatrix::inverse(), and WObject::matrix().
Referenced by PhyiCub::configurePosture().
The documentation for this class was generated from the following files:
- worldsim/include/phyicubhelpers.h
- worldsim/src/phyicubhelpers.cpp