Privacy
An open-source, flexible 3D physical simulation framework
mars::sim::NodePhysics Class Reference

The class that implements the NodeInterface interface. More...

#include <NodePhysics.h>

Public Member Functions

 NodePhysics (interfaces::PhysicsInterface *world)
 Creates a empty node objekt. More...
 
virtual ~NodePhysics (void)
 Destroys the node in the physical world. More...
 
virtual bool createNode (interfaces::NodeData *node)
 The method creates an ode node, which properties are given by the NodeData param node. More...
 
virtual void getPosition (utils::Vector *pos) const
 The method copies the position of the node at the adress of the pointer pos. More...
 
virtual const utils::Vector setPosition (const utils::Vector &pos, bool move_group)
 The method sets the position of the physical node model to the position of the param. More...
 
virtual void getRotation (utils::Quaternion *q) const
 The method copies the Quaternion of the physically node at the adress of the Quaternion pointer q. More...
 
virtual const utils::Quaternion setRotation (const utils::Quaternion &q, bool move_group)
 This method sets the rotation of the physically node. More...
 
virtual void setWorldObject (interfaces::PhysicsInterface *world)
 This function sets the pointer to the physical world object. More...
 
virtual void getLinearVelocity (utils::Vector *vel) const
 The method copies the linear velocity of the physically node at the adress of the linear_vel pointer vel. More...
 
virtual void getAngularVelocity (utils::Vector *vel) const
 The method copies the angular velocity of the physically node at the adress of the angular_vel pointer vel. More...
 
virtual void getForce (utils::Vector *f) const
 The method copies the force of the physically node at the adress of the force pointer force. More...
 
virtual void getTorque (utils::Vector *t) const
 The method copies the torque of the physically node at the adress of the torque pointer force. More...
 
virtual const utils::Vector rotateAtPoint (const utils::Vector &rotation_point, const utils::Quaternion &rotation, bool move_group)
 executes an rotation at a given point and returns the new position of the node More...
 
virtual bool changeNode (interfaces::NodeData *node)
 This function rebuilds the geom (type, size and mass) of a node. More...
 
virtual void setLinearVelocity (const utils::Vector &velocity)
 Sets the linear velocity of a node. More...
 
virtual void setAngularVelocity (const utils::Vector &velocity)
 Sets the angular velocity of a node. More...
 
virtual void setForce (const utils::Vector &f)
 Sets the force of a node. More...
 
virtual void setTorque (const utils::Vector &t)
 Sets the torque of a node. More...
 
virtual void addForce (const utils::Vector &f, const utils::Vector &p)
 Adds a off-center force to a node. More...
 
virtual void addForce (const utils::Vector &f)
 Adds a force to a node. More...
 
virtual void addTorque (const utils::Vector &t)
 Adds a torque to a node. More...
 
virtual bool getGroundContact (void) const
 
virtual void getContactPoints (std::vector< utils::Vector > *contact_points) const
 
virtual void getContactIDs (std::list< interfaces::NodeId > *ids) const
 
virtual interfaces::sReal getGroundContactForce (void) const
 
virtual void setContactParams (interfaces::contact_params &c_params)
 
virtual void addSensor (interfaces::BaseSensor *sensor)
 This function adds a new sensor to the physical node. More...
 
virtual void removeSensor (interfaces::BaseSensor *sensor)
 
virtual void handleSensorData (bool physics_thread=true)
 This function copies all sensor values to the specific allocated memory. More...
 
virtual void destroyNode (void)
 destroyes a node from the physics More...
 
virtual void getMass (interfaces::sReal *mass, interfaces::sReal *inertia=0) const
 
virtual const utils::Vector getContactForce (void) const
 
virtual interfaces::sReal getCollisionDepth (void) const
 
void addCompositeOffset (dReal x, dReal y, dReal z)
 
dBodyID getBody () const
 return the body; this function is created to make it possible to get the body from joint physics s More...
 
dMass getODEMass (void) const
 returns the ode mass object More...
 
void addMassToCompositeBody (dBodyID theBody, dMass *bodyMass)
 
void getAbsMass (dMass *pMass) const
 
dReal heightCallback (int x, int y)
 
- Public Member Functions inherited from mars::interfaces::NodeInterface
virtual ~NodeInterface ()
 

Protected Member Functions

bool createMesh (interfaces::NodeData *node)
 The method creates an ode mesh representation of the given node. More...
 
bool createBox (interfaces::NodeData *node)
 The method creates an ode box representation of the given node. More...
 
bool createSphere (interfaces::NodeData *node)
 The method creates an ode shpere representation of the given node. More...
 
bool createCapsule (interfaces::NodeData *node)
 The method creates an ode capsule representation of the given node. More...
 
bool createCylinder (interfaces::NodeData *node)
 The method creates an ode cylinder representation of the given node. More...
 
bool createPlane (interfaces::NodeData *node)
 The method creates an ode plane. More...
 
bool createHeightfield (interfaces::NodeData *node)
 
void setProperties (interfaces::NodeData *node)
 This method sets some properties for the node. More...
 
void setInertiaMass (interfaces::NodeData *node)
 

Protected Attributes

WorldPhysicstheWorld
 
dBodyID nBody
 
dGeomID nGeom
 
dMass nMass
 
dVector3 * myVertices
 
dTriIndexmyIndices
 
dTriMeshDataID myTriMeshData
 
bool composite
 
geom_data node_data
 
interfaces::terrainStructterrain
 
dReal * height_data
 
std::vector< sensor_list_elementsensor_list
 

Detailed Description

The class that implements the NodeInterface interface.

Definition at line 91 of file NodePhysics.h.

Constructor & Destructor Documentation

◆ NodePhysics()

mars::sim::NodePhysics::NodePhysics ( interfaces::PhysicsInterface world)

Creates a empty node objekt.

Precondition
  • the pointer to the physics Interface should be correct. This implementation can be a bad trap. The class that implements the physics interface, have to inherit from the interface at first, otherwise this implementation will cause bad error while pointing an incorrect adresses.
Postcondition
  • the class should have saved the pointer to the physics implementation
  • the body and geom should be initialized to 0

Definition at line 70 of file NodePhysics.cpp.

◆ ~NodePhysics()

mars::sim::NodePhysics::~NodePhysics ( void  )
virtual

Destroys the node in the physical world.

pre:

  • theWorld is the correct world object

post:

  • all physical representation of the node should be cleared

are the geom and the body realy all thing to take care of?

Definition at line 96 of file NodePhysics.cpp.

Member Function Documentation

◆ addCompositeOffset()

void mars::sim::NodePhysics::addCompositeOffset ( dReal  x,
dReal  y,
dReal  z 
)

Definition at line 1293 of file NodePhysics.cpp.

◆ addForce() [1/2]

void mars::sim::NodePhysics::addForce ( const utils::Vector f,
const utils::Vector p 
)
virtual

Adds a off-center force to a node.

pre:

  • the node should have a body

post:

  • the force should be added to the body

Implements mars::interfaces::NodeInterface.

Definition at line 1184 of file NodePhysics.cpp.

◆ addForce() [2/2]

void mars::sim::NodePhysics::addForce ( const utils::Vector f)
virtual

Adds a force to a node.

pre:

  • the node should have a body

post:

  • the force should be added to the body

Implements mars::interfaces::NodeInterface.

Definition at line 1201 of file NodePhysics.cpp.

◆ addMassToCompositeBody()

void mars::sim::NodePhysics::addMassToCompositeBody ( dBodyID  theBody,
dMass *  bodyMass 
)

Definition at line 1301 of file NodePhysics.cpp.

◆ addSensor()

void mars::sim::NodePhysics::addSensor ( interfaces::BaseSensor sensor)
virtual

This function adds a new sensor to the physical node.

Sensors that are implemented are a "ray sensor" and a "multi ray sensor"

pre:

  • the BaseSensor should contain a complete and correct configuration
  • the world have to exists because geoms have to be created
  • this Node should have an existing geom

post:

  • every new sensor has to be added to a list
  • the memory for the sensor data has to be allocated
  • the physical elements for the sensor had to be created

Implements mars::interfaces::NodeInterface.

Definition at line 1366 of file NodePhysics.cpp.

◆ addTorque()

void mars::sim::NodePhysics::addTorque ( const utils::Vector t)
virtual

Adds a torque to a node.

pre:

  • the node should have a body

post:

  • the torque should be added to the body

Implements mars::interfaces::NodeInterface.

Definition at line 1217 of file NodePhysics.cpp.

◆ changeNode()

bool mars::sim::NodePhysics::changeNode ( interfaces::NodeData node)
virtual

This function rebuilds the geom (type, size and mass) of a node.

pre:

  • the world should be exist
  • a geom should be exist

post:

  • the geom should be rebuild with the new properties

Implements mars::interfaces::NodeInterface.

Definition at line 992 of file NodePhysics.cpp.

◆ createBox()

bool mars::sim::NodePhysics::createBox ( interfaces::NodeData node)
protected

The method creates an ode box representation of the given node.

Definition at line 660 of file NodePhysics.cpp.

◆ createCapsule()

bool mars::sim::NodePhysics::createCapsule ( interfaces::NodeData node)
protected

The method creates an ode capsule representation of the given node.

Definition at line 724 of file NodePhysics.cpp.

◆ createCylinder()

bool mars::sim::NodePhysics::createCylinder ( interfaces::NodeData node)
protected

The method creates an ode cylinder representation of the given node.

Definition at line 757 of file NodePhysics.cpp.

◆ createHeightfield()

bool mars::sim::NodePhysics::createHeightfield ( interfaces::NodeData node)
protected

Definition at line 797 of file NodePhysics.cpp.

◆ createMesh()

bool mars::sim::NodePhysics::createMesh ( interfaces::NodeData node)
protected

The method creates an ode mesh representation of the given node.

Definition at line 606 of file NodePhysics.cpp.

◆ createNode()

bool mars::sim::NodePhysics::createNode ( interfaces::NodeData node)
virtual

The method creates an ode node, which properties are given by the NodeData param node.

pre:

  • Node sturct should point to a correct object
  • we should have a pointer to the physics implementation
  • a physically world should have been created to insert a node

post:

  • a physical node should be created in the world
  • the node properties should be set

Implements mars::interfaces::NodeInterface.

Definition at line 137 of file NodePhysics.cpp.

◆ createPlane()

bool mars::sim::NodePhysics::createPlane ( interfaces::NodeData node)
protected

The method creates an ode plane.

Definition at line 790 of file NodePhysics.cpp.

◆ createSphere()

bool mars::sim::NodePhysics::createSphere ( interfaces::NodeData node)
protected

The method creates an ode shpere representation of the given node.

Definition at line 695 of file NodePhysics.cpp.

◆ destroyNode()

void mars::sim::NodePhysics::destroyNode ( void  )
virtual

destroyes a node from the physics

pre:

post:

Implements mars::interfaces::NodeInterface.

Definition at line 1692 of file NodePhysics.cpp.

◆ getAbsMass()

void mars::sim::NodePhysics::getAbsMass ( dMass *  pMass) const

Definition at line 1327 of file NodePhysics.cpp.

◆ getAngularVelocity()

void mars::sim::NodePhysics::getAngularVelocity ( utils::Vector vel) const
virtual

The method copies the angular velocity of the physically node at the adress of the angular_vel pointer vel.

pre:

  • there should be a physical representation of the node
  • the node should be movable
  • the vel param should point to a correct angular_vel struct

post:

  • if there is a physical representation and the node is movable the angular_vel struct should be filled with the physical angular velocity of the node
  • otherwise a standard return of zero velocity should be set

Implements mars::interfaces::NodeInterface.

Definition at line 420 of file NodePhysics.cpp.

◆ getBody()

dBodyID mars::sim::NodePhysics::getBody ( ) const

return the body; this function is created to make it possible to get the body from joint physics s

return the body; this function is created to make it possible to get the body from joint physics TO DO : test if the Node has a body

Definition at line 597 of file NodePhysics.cpp.

◆ getCollisionDepth()

sReal mars::sim::NodePhysics::getCollisionDepth ( void  ) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1748 of file NodePhysics.cpp.

◆ getContactForce()

const Vector mars::sim::NodePhysics::getContactForce ( void  ) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1271 of file NodePhysics.cpp.

◆ getContactIDs()

void mars::sim::NodePhysics::getContactIDs ( std::list< interfaces::NodeId > *  ids) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1241 of file NodePhysics.cpp.

◆ getContactPoints()

void mars::sim::NodePhysics::getContactPoints ( std::vector< utils::Vector > *  contact_points) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1229 of file NodePhysics.cpp.

◆ getForce()

void mars::sim::NodePhysics::getForce ( utils::Vector f) const
virtual

The method copies the force of the physically node at the adress of the force pointer force.

pre:

  • there should be a physical representation of the node
  • the node should be movable
  • the f param should point to a correct force struct

post:

  • if there is a physical representation and the node is movable the force struct should be filled with the physical force of the node
  • otherwise a standard return of zero force should be set

Implements mars::interfaces::NodeInterface.

Definition at line 452 of file NodePhysics.cpp.

◆ getGroundContact()

bool mars::sim::NodePhysics::getGroundContact ( void  ) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1222 of file NodePhysics.cpp.

◆ getGroundContactForce()

sReal mars::sim::NodePhysics::getGroundContactForce ( void  ) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1249 of file NodePhysics.cpp.

◆ getLinearVelocity()

void mars::sim::NodePhysics::getLinearVelocity ( utils::Vector vel) const
virtual

The method copies the linear velocity of the physically node at the adress of the linear_vel pointer vel.

pre:

  • there should be a physical representation of the node
  • the node should be movable
  • the vel param should point to a correct linear_vel struct

post:

  • if there is a physical representation and the node is movable the linear_vel struct should be filled with the physical linar velocity of the node
  • otherwise a standard return of zero velocity should be set

Implements mars::interfaces::NodeInterface.

Definition at line 388 of file NodePhysics.cpp.

◆ getMass()

void mars::sim::NodePhysics::getMass ( interfaces::sReal mass,
interfaces::sReal inertia = 0 
) const
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1733 of file NodePhysics.cpp.

◆ getODEMass()

dMass mars::sim::NodePhysics::getODEMass ( void  ) const

returns the ode mass object

pre:

post:

Definition at line 1111 of file NodePhysics.cpp.

◆ getPosition()

void mars::sim::NodePhysics::getPosition ( utils::Vector pos) const
virtual

The method copies the position of the node at the adress of the pointer pos.

pre:

  • the physical representation of the node should be availbe
  • the node should have an body (should be movable)
  • the position pointer param should point to a correct position struct

post:

  • if the node is physically availbe and is set to be movable the struct of the position pointer should be filled with the physical position of the node
  • otherwise the position should be set to zero

Implements mars::interfaces::NodeInterface.

Definition at line 226 of file NodePhysics.cpp.

◆ getRotation()

void mars::sim::NodePhysics::getRotation ( utils::Quaternion q) const
virtual

The method copies the Quaternion of the physically node at the adress of the Quaternion pointer q.

pre:

  • there should be a physical representation of the node
  • the node should be movable
  • the q param should point to a correct Quaternion struct

post:

  • if there is a physical representation and the node is movable the Quaternion struct should be filled with the physical rotation of the node
  • otherwise a standard return of zero rotation should be set

Implements mars::interfaces::NodeInterface.

Definition at line 354 of file NodePhysics.cpp.

◆ getTorque()

void mars::sim::NodePhysics::getTorque ( utils::Vector t) const
virtual

The method copies the torque of the physically node at the adress of the torque pointer force.

pre:

  • there should be a physical representation of the node
  • the node should be movable
  • the t param should point to a correct torque struct

post:

  • if there is a physical representation and the node is movable the torque struct should be filled with the physical torque of the node
  • otherwise a standard return of zero torque should be set

Implements mars::interfaces::NodeInterface.

Definition at line 484 of file NodePhysics.cpp.

◆ handleSensorData()

void mars::sim::NodePhysics::handleSensorData ( bool  physics_thread = true)
virtual

This function copies all sensor values to the specific allocated memory.

pre:

post:

Implements mars::interfaces::NodeInterface.

Definition at line 1565 of file NodePhysics.cpp.

◆ heightCallback()

dReal mars::sim::NodePhysics::heightCallback ( int  x,
int  y 
)

Definition at line 1337 of file NodePhysics.cpp.

◆ removeSensor()

void mars::sim::NodePhysics::removeSensor ( interfaces::BaseSensor sensor)
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1544 of file NodePhysics.cpp.

◆ rotateAtPoint()

const Vector mars::sim::NodePhysics::rotateAtPoint ( const utils::Vector rotation_point,
const utils::Quaternion rotation,
bool  move_group 
)
virtual

executes an rotation at a given point and returns the new position of the node

pre:

post:

Implements mars::interfaces::NodeInterface.

Definition at line 897 of file NodePhysics.cpp.

◆ setAngularVelocity()

void mars::sim::NodePhysics::setAngularVelocity ( const utils::Vector velocity)
virtual

Sets the angular velocity of a node.

pre:

  • the node should have a body

post:

  • the angular velocity of the body should be set

Implements mars::interfaces::NodeInterface.

Definition at line 1139 of file NodePhysics.cpp.

◆ setContactParams()

void mars::sim::NodePhysics::setContactParams ( interfaces::contact_params c_params)
virtual

Implements mars::interfaces::NodeInterface.

Definition at line 1342 of file NodePhysics.cpp.

◆ setForce()

void mars::sim::NodePhysics::setForce ( const utils::Vector f)
virtual

Sets the force of a node.

pre:

  • the node should have a body

post:

  • the force of the body should be set

Implements mars::interfaces::NodeInterface.

Definition at line 1154 of file NodePhysics.cpp.

◆ setInertiaMass()

void mars::sim::NodePhysics::setInertiaMass ( interfaces::NodeData node)
protected

Definition at line 1713 of file NodePhysics.cpp.

◆ setLinearVelocity()

void mars::sim::NodePhysics::setLinearVelocity ( const utils::Vector velocity)
virtual

Sets the linear velocity of a node.

pre:

  • the node should have a body

post:

  • the linear velocity of the body should be set

Implements mars::interfaces::NodeInterface.

Definition at line 1124 of file NodePhysics.cpp.

◆ setPosition()

const Vector mars::sim::NodePhysics::setPosition ( const utils::Vector pos,
bool  move_group 
)
virtual

The method sets the position of the physical node model to the position of the param.

If move_group is set, all nodes of a composite group will be moved, otherwise only this node will be moved. A vector from the old position to the new will be returned.

I don't know if we should use this function in a way like it is implemented now. The pre and post conditions could loke like this:

pre:

  • there should be a physical representation of the node
  • the pos param should point to a correct position struct

post:

  • if there is a physically representation and the node is movable set the position of the corresponding body to the given parameter
  • otherwise, we have to do nothing

Implements mars::interfaces::NodeInterface.

Definition at line 272 of file NodePhysics.cpp.

◆ setProperties()

void mars::sim::NodePhysics::setProperties ( interfaces::NodeData node)
protected

This method sets some properties for the node.

The properties includes the posistion, the rotation, the movability and the coposite group number

Definition at line 836 of file NodePhysics.cpp.

◆ setRotation()

const Quaternion mars::sim::NodePhysics::setRotation ( const utils::Quaternion q,
bool  move_group 
)
virtual

This method sets the rotation of the physically node.

I don't if and how to use this function yet. ^-^ If we need it, the pre and post conditions are like them in the set position method.

Implements mars::interfaces::NodeInterface.

Definition at line 509 of file NodePhysics.cpp.

◆ setTorque()

void mars::sim::NodePhysics::setTorque ( const utils::Vector t)
virtual

Sets the torque of a node.

pre:

  • the node should have a body

post:

  • the torque of the body should be set

Implements mars::interfaces::NodeInterface.

Definition at line 1169 of file NodePhysics.cpp.

◆ setWorldObject()

void mars::sim::NodePhysics::setWorldObject ( interfaces::PhysicsInterface world)
virtual

This function sets the pointer to the physical world object.

I don't think that we need this function.

Implements mars::interfaces::NodeInterface.

Definition at line 587 of file NodePhysics.cpp.

Member Data Documentation

◆ composite

bool mars::sim::NodePhysics::composite
protected

Definition at line 145 of file NodePhysics.h.

◆ height_data

dReal* mars::sim::NodePhysics::height_data
protected

Definition at line 148 of file NodePhysics.h.

◆ myIndices

dTriIndex* mars::sim::NodePhysics::myIndices
protected

Definition at line 143 of file NodePhysics.h.

◆ myTriMeshData

dTriMeshDataID mars::sim::NodePhysics::myTriMeshData
protected

Definition at line 144 of file NodePhysics.h.

◆ myVertices

dVector3* mars::sim::NodePhysics::myVertices
protected

Definition at line 142 of file NodePhysics.h.

◆ nBody

dBodyID mars::sim::NodePhysics::nBody
protected

Definition at line 139 of file NodePhysics.h.

◆ nGeom

dGeomID mars::sim::NodePhysics::nGeom
protected

Definition at line 140 of file NodePhysics.h.

◆ nMass

dMass mars::sim::NodePhysics::nMass
protected

Definition at line 141 of file NodePhysics.h.

◆ node_data

geom_data mars::sim::NodePhysics::node_data
protected

Definition at line 146 of file NodePhysics.h.

◆ sensor_list

std::vector<sensor_list_element> mars::sim::NodePhysics::sensor_list
protected

Definition at line 149 of file NodePhysics.h.

◆ terrain

interfaces::terrainStruct* mars::sim::NodePhysics::terrain
protected

Definition at line 147 of file NodePhysics.h.

◆ theWorld

WorldPhysics* mars::sim::NodePhysics::theWorld
protected

Definition at line 138 of file NodePhysics.h.


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