Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
Interface class for primitives represented in the physical and graphical world. More...
#include <primitive.h>
Public Types | |
enum | Modes { Body =1, Geom =2, Draw =4, Density =8, _Child =16, _Transform =32 } |
Body means that it is a dynamic object with a body. More... | |
enum | Category { Dyn =1, Stat =2 } |
Public Member Functions | |
Primitive () | |
virtual | ~Primitive () |
virtual void | init (const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)=0 |
registers primitive in ODE and OSG. More... | |
virtual void | update ()=0 |
Updates the OSG nodes with ODE coordinates. More... | |
virtual OSGPrimitive * | getOSGPrimitive ()=0 |
returns the assoziated osg primitive if there or 0 More... | |
virtual void | setColor (const Color &color) |
sets the color for the underlaying osgprimitive More... | |
virtual void | setColor (const std::string &color) |
sets the color using the colorschema of osgHandle More... | |
virtual void | setTexture (const std::string &filename) |
assigns a texture to the primitive More... | |
virtual void | setTexture (const TextureDescr &texture) |
assigns a texture to the primitive, you can choose if the texture should be repeated More... | |
virtual void | setTexture (int surface, const TextureDescr &texture) |
assigns a texture to the x-th surface of the primitive. More... | |
virtual void | setTextures (const std::vector< TextureDescr > &textures) |
assign a set of texture to the surfaces of the primitive More... | |
virtual void | setPosition (const Pos &pos) |
set the position of the primitive (orientation is preserved) More... | |
virtual void | setPose (const Pose &pose) |
set the pose of the primitive More... | |
virtual Pos | getPosition () const |
returns the position More... | |
virtual Pose | getPose () const |
returns the pose More... | |
virtual Pos | getVel () const |
returns the velocity More... | |
virtual Pos | getAngularVel () const |
returns the angular velocity More... | |
virtual bool | applyForce (osg::Vec3 force) |
apply a force (in world coordinates) to the primitive and returns true if it was possible More... | |
virtual bool | applyForce (double x, double y, double z) |
virtual bool | applyTorque (osg::Vec3 torque) |
apply a torque (in world coordinates) to the primitive and returns true if it was possible More... | |
virtual bool | applyTorque (double x, double y, double z) |
virtual void | setMass (double mass, bool density=false)=0 |
sets the mass of the body (uniform) if density==true then mass is interpreted as a density More... | |
void | setMass (double mass, double cgx, double cgy, double cgz, double I11, double I22, double I33, double I12, double I13, double I23) |
sets full mass specification More... | |
dGeomID | getGeom () const |
returns ODE geomID if there More... | |
dBodyID | getBody () const |
returns ODE bodyID if there More... | |
bool | limitLinearVel (double maxVel) |
checks whether the object has higher velocity than maxVel and limits it in case More... | |
bool | limitAngularVel (double maxVel) |
checks whether the object has higher velocity than maxVel and limits it in case More... | |
void | decellerate (double factorLin, double factorAng) |
applies a force to the body to decellerate its linear and angular velocity with the given factors. More... | |
osg::Vec3 | toLocal (const osg::Vec3 &pos) const |
return the given point transformed to local coordinates of the primitive More... | |
osg::Vec4 | toLocal (const osg::Vec4 &axis) const |
return the given vector or axis transformed to local coordinates of the primitive (translation depends on the 4th coordinate) More... | |
osg::Vec3 | toGlobal (const osg::Vec3 &pos) const |
transforms the given point in local corrds of the primitive to global coordinates More... | |
osg::Vec4 | toGlobal (const osg::Vec4 &axis) const |
transforms the given vector or axis in local corrds of the primitive to global coordinates (translation depends on the 4th coordinate) More... | |
int | getNumVelocityViolations () |
void | setSubstance (const Substance &substance) |
virtual bool | store (FILE *f) const |
stores the object to the given file stream (ASCII preferred). More... | |
virtual bool | restore (FILE *f) |
loads the object from the given file stream (ASCII preferred). More... | |
Public Member Functions inherited from Storeable | |
virtual | ~Storeable () |
bool | storeToFile (const char *filename) const |
Provided for convenience. More... | |
bool | restoreFromFile (const char *filename) |
Provided for convenience. More... | |
Static Public Member Functions | |
static void | setDestroyGeomFlag (bool _destroyGeom) |
20091023; guettler: hack for tasked simulations; there are some problems if running in parallel mode, if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too) More... | |
Public Attributes | |
Substance | substance |
Protected Member Functions | |
virtual void | attachGeomAndSetColliderFlags () |
attaches geom to body (if any) and sets the category bits and collision bitfields. More... | |
Protected Attributes | |
dGeomID | geom |
dBodyID | body |
char | mode |
bool | substanceManuallySet |
int | numVelocityViolations |
number of times the maximal velocity was exceeded More... | |
Static Protected Attributes | |
static bool | destroyGeom = true |
Interface class for primitives represented in the physical and graphical world.
This is intended to bring OSG and ODE together and hide most implementation details.
enum Category |
enum Modes |
Body means that it is a dynamic object with a body.
Geom means it has a geometrical represenation used for collision detection. Draw means the primitive is drawn. Density means that the mass is interpreted as a density _Child and _Transform are only used internally and used for transformed geoms.
Enumerator | |
---|---|
Body | |
Geom | |
Draw | |
Density | |
_Child | |
_Transform |
Primitive | ( | ) |
|
virtual |
|
virtual |
apply a force (in world coordinates) to the primitive and returns true if it was possible
|
virtual |
|
virtual |
apply a torque (in world coordinates) to the primitive and returns true if it was possible
|
virtual |
|
protectedvirtual |
attaches geom to body (if any) and sets the category bits and collision bitfields.
assumes: mode & Geom != 0
void decellerate | ( | double | factorLin, |
double | factorAng | ||
) |
applies a force to the body to decellerate its linear and angular velocity with the given factors.
(depends on stepwidth!)
|
virtual |
returns the angular velocity
|
inline |
returns ODE bodyID if there
|
inline |
returns ODE geomID if there
|
inline |
|
pure virtual |
returns the assoziated osg primitive if there or 0
Implemented in DummyPrimitive, Transform, Mesh, Ray, Cylinder, Capsule, Sphere, Box, Plane, and HeightField.
|
virtual |
returns the pose
|
virtual |
returns the position
Reimplemented in DummyPrimitive.
|
virtual |
returns the velocity
Reimplemented in DummyPrimitive.
|
pure virtual |
registers primitive in ODE and OSG.
osgHandle | scruct with ODE variables inside (to specify space, world...) |
mass | Mass of the object in ODE (if withBody = true) |
osgHandle | scruct with OSG variables inside (scene node, color ...) |
mode | is a conjuction of Modes. |
Implemented in DummyPrimitive, Transform, Mesh, Ray, Cylinder, Capsule, Sphere, Box, Plane, and HeightField.
bool limitAngularVel | ( | double | maxVel | ) |
checks whether the object has higher velocity than maxVel and limits it in case
bool limitLinearVel | ( | double | maxVel | ) |
checks whether the object has higher velocity than maxVel and limits it in case
|
virtual |
loads the object from the given file stream (ASCII preferred).
Implements Storeable.
|
virtual |
sets the color for the underlaying osgprimitive
|
virtual |
sets the color using the colorschema of osgHandle
|
inlinestatic |
20091023; guettler: hack for tasked simulations; there are some problems if running in parallel mode, if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too)
_destroyGeom | set this to false if geoms must not be destroyed if the primitive is destroyed |
|
pure virtual |
sets the mass of the body (uniform) if density==true then mass is interpreted as a density
Implemented in DummyPrimitive, Transform, Mesh, Ray, Cylinder, Capsule, Sphere, Box, Plane, and HeightField.
void setMass | ( | double | mass, |
double | cgx, | ||
double | cgy, | ||
double | cgz, | ||
double | I11, | ||
double | I22, | ||
double | I33, | ||
double | I12, | ||
double | I13, | ||
double | I23 | ||
) |
sets full mass specification
sets full mass specification.
cg | center of gravity vector |
I | 3x3 interia tensor |
cg is center of gravity vector I are parts of the 3x3 interia tensor
|
virtual |
set the pose of the primitive
Reimplemented in Transform, Mesh, and HeightField.
|
virtual |
set the position of the primitive (orientation is preserved)
void setSubstance | ( | const Substance & | substance | ) |
|
virtual |
assigns a texture to the primitive
|
virtual |
assigns a texture to the primitive, you can choose if the texture should be repeated
|
virtual |
assigns a texture to the x-th surface of the primitive.
You can choose how often to repeat negative values of repeat correspond to length units. E.g. assume a rectangle of size 5 in x direction: with repeatOnX = 2 the texture would be two times rereated. With repeatOnX = -2 the texture would be 2.5 times repeated because the texture is made to have the size 2
|
virtual |
assign a set of texture to the surfaces of the primitive
|
virtual |
stores the object to the given file stream (ASCII preferred).
Implements Storeable.
transforms the given point in local corrds of the primitive to global coordinates
transforms the given vector or axis in local corrds of the primitive to global coordinates (translation depends on the 4th coordinate)
return the given point transformed to local coordinates of the primitive
return the given vector or axis transformed to local coordinates of the primitive (translation depends on the 4th coordinate)
|
pure virtual |
Updates the OSG nodes with ODE coordinates.
This function must be overloaded (usually calls setMatrix of OsgPrimitives)
Implemented in DummyPrimitive, Transform, Mesh, Ray, Cylinder, Capsule, Sphere, Box, Plane, and HeightField.
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
number of times the maximal velocity was exceeded
Substance substance |
|
protected |