RobWorkProject
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
ODESimulator Class Reference

an implementation that use the physics engine ODE to implement the Simulator interface of RWSim. All information into the simulator is derived through RWSim classes. More...

#include <ODESimulator.hpp>

Inherits PhysicsEngine.

Classes

struct  ODEStateStuff
 

Public Types

enum  StepMethod { WorldStep, WorldQuickStep, WorldFast1 }
 
enum  SpaceType { Simple, HashTable, QuadTree }
 type of broad phase collision detection to use
 
typedef rw::common::Ptr< ODESimulatorPtr
 smart pointer type
 
- Public Types inherited from PhysicsEngine
typedef rw::common::Ptr< PhysicsEnginePtr
 smart pointer type of PhysicsEngine
 

Public Member Functions

 ODESimulator ()
 empty constructor
 
 ODESimulator (dynamics::DynamicWorkCell::Ptr dwc, rw::common::Ptr< rwsim::contacts::ContactDetector > detector=NULL)
 constructor More...
 
virtual ~ODESimulator ()
 destructor
 
void load (rwsim::dynamics::DynamicWorkCell::Ptr dwc)
 adds dynamic workcell More...
 
bool setContactDetector (rw::common::Ptr< rwsim::contacts::ContactDetector > detector)
 Change the contact detector used by the engine. More...
 
void setStepMethod (StepMethod method)
 sets the ODE step method that should be used for stepping
 
void step (double dt, rw::kinematics::State &state)
 
void resetScene (rw::kinematics::State &state)
 
void initPhysics (rw::kinematics::State &state)
 
void exitPhysics ()
 
double getTime ()
 
void DWCChangedListener (dynamics::DynamicWorkCell::DWCEventType type, boost::any data)
 
void setEnabled (dynamics::Body::Ptr body, bool enabled)
 
void setDynamicsEnabled (dynamics::Body::Ptr body, bool enabled)
 
drawable::SimulatorDebugRender::Ptr createDebugRender ()
 
virtual rw::common::PropertyMapgetPropertyMap ()
 
void emitPropertyChanged ()
 
void addController (rwlibs::simulation::SimulatedController::Ptr controller)
 
bool isInitialized ()
 
void addBody (rwsim::dynamics::Body::Ptr body, rw::kinematics::State &state)
 
void addConstraint (rwsim::dynamics::Constraint::Ptr constraint)
 Add a Constraint between two bodies. More...
 
void addDevice (rwsim::dynamics::DynamicDevice::Ptr device, rw::kinematics::State &state)
 
void addSensor (rwlibs::simulation::SimulatedSensor::Ptr sensor, rw::kinematics::State &state)
 add a simulated sensor to this simulator
 
void removeController (rwlibs::simulation::SimulatedController::Ptr controller)
 
void removeSensor (rwlibs::simulation::SimulatedSensor::Ptr sensor)
 add a simulated sensor to this simulator
 
const rw::kinematics::FramePairMap< std::vector< dynamics::ContactManifold > > & getContactManifoldMap ()
 
std::vector< ODEBody * > & getODEBodies ()
 
dynamics::DynamicWorkCell::Ptr getDynamicWorkCell ()
 
std::vector< rwlibs::simulation::SimulatedSensor::PtrgetSensors ()
 get the list of simulated sensors More...
 
void attach (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2)
 
void detach (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2)
 
void disableCollision (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2)
 
void enableCollision (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2)
 
rw::math::Vector3D getGravity ()
 get current gravity
 
dWorldID getODEWorldId () const
 
void addODEJoint (ODEJoint *odejoint)
 
ODEJointgetODEJoint (rw::models::Joint *joint)
 
void addODEBody (ODEBody *odebody)
 
void addODEBody (dBodyID body)
 
void addODEJoint (dJointID joint)
 
ODEBodygetODEBody (rw::kinematics::Frame *frame)
 
dBodyID getODEBodyId (rw::kinematics::Frame *frame)
 
dBodyID getODEBodyId (rwsim::dynamics::Body *body)
 
std::vector< ODEDevice * > getODEDevices ()
 
void addEmulatedContact (const rw::math::Vector3D<> &pos, const rw::math::Vector3D<> &force, const rw::math::Vector3D<> &normal, dynamics::Body *b)
 
void setContactLoggingEnabled (bool enable)
 Enables logging of the contact points.
 
boost::unordered_map< std::pair< std::string, std::string >, bool > getContactingBodies ()
 Returns a map of contacting body frame names and their contact points.
 
void handleCollisionBetween (dGeomID o0, dGeomID o1)
 Returns a vector of all contact points. More...
 
const std::vector< ODEUtil::TriGeomData * > & getTriMeshs ()
 
std::vector< dynamics::ContactPointgetContacts ()
 
int getContactCnt ()
 
double getMaxSeperatingDistance ()
 
dSpaceID getODESpace ()
 
void addContacts (std::vector< dContact > &contacts, size_t nr_con, ODEBody *dataB1, ODEBody *dataB2)
 
std::vector< ODETactileSensor * > getODESensors (dBodyID odebody)
 
dynamics::MaterialDataMapgetMaterialMap ()
 
dynamics::ContactDataMapgetContactMap ()
 
- Public Member Functions inherited from PhysicsEngine
virtual ~PhysicsEngine ()
 destructor
 
virtual void load (rw::common::Ptr< rwsim::dynamics::DynamicWorkCell > dwc)=0
 adds dynamic workcell
 
virtual void setEnabled (rw::common::Ptr< rwsim::dynamics::Body > body, bool enabled)=0
 
virtual void setDynamicsEnabled (rw::common::Ptr< rwsim::dynamics::Body > body, bool enabled)=0
 disables the dynamics of a body. More...
 
virtual void addController (rw::common::Ptr< rwlibs::simulation::SimulatedController > controller)=0
 add a simulated controller to this simulator
 
virtual void removeController (rw::common::Ptr< rwlibs::simulation::SimulatedController > controller)=0
 removes a simulated controller from this simulator More...
 
virtual void addBody (rw::common::Ptr< rwsim::dynamics::Body > body, rw::kinematics::State &state)=0
 add a body to the physics engine More...
 
virtual void addDevice (rw::common::Ptr< rwsim::dynamics::DynamicDevice > dev, rw::kinematics::State &state)=0
 add a dynamic device to the physics engine More...
 
virtual void attach (rw::common::Ptr< rwsim::dynamics::Body > b1, rw::common::Ptr< rwsim::dynamics::Body > b2)=0
 creates a 6dof dynamic constraint between the two bodies b1 and b2 More...
 
virtual void detach (rw::common::Ptr< rwsim::dynamics::Body > b1, rw::common::Ptr< rwsim::dynamics::Body > b2)=0
 removes the 6dof constraint between bodies b1 and b2 if there is any More...
 
virtual void setSimulatorLog (rw::common::Ptr< rwsim::log::SimulatorLogScope > log)
 Store internal info during simulation. More...
 

Protected Member Functions

void detectCollisionsContactDetector (const rw::kinematics::State &state)
 
bool detectCollisionsRW (rw::kinematics::State &state, bool onlyTestPenetration=false)
 

Detailed Description

an implementation that use the physics engine ODE to implement the Simulator interface of RWSim. All information into the simulator is derived through RWSim classes.

Supported objects types include Rigid, Kinematic and fixed Supported device types include Rigid and Kinematic

The simulation step looks like this

1 updateControllers() 2 updateDevices() // sets the target velocity of devices 3 performContactDetection() 4 performConstraintSolving() 5 updateSensorStates() 6 updateDeviceStates() 7 updateBodyStates()

The ODE physics engine support several engine specific properties. These can be tweaked to obtain higher performance or robustness. ODE specific options:

Only used when RobWork contact generation is used (its the default). MaxSepDistance - float - All triangles within a distance MaxSepDistance is used in the contact generation.

object specific:

SoftLayer - float -

example:

* <Property name="StepMethod">WorldStep</Property>
* <Property name="WorldCFM" type="float">0.000001</Property>
* <Property name="WorldERP" type="float">0.2</Property>
* <Property name="MaxIterations" type="int">100</Property>
* <Property name="ContactSurfaceLayer" type="float">0.001</Property>
*
* <Property name="MaxSepDistance" type="float">0.01</Property>
* <Property name="MaxCorrectingVelocity" type="float">0.1</Property>
* 

Member Enumeration Documentation

◆ StepMethod

enum StepMethod

type of step method, worldStep is direct solver, worldquickstep is faster iterative solver. When dynamically simulating robot arms use worldstep, else simulate chains as kinematic bodies.

Constructor & Destructor Documentation

◆ ODESimulator()

constructor

Parameters
dwc[in] the dynamic workcell for which the simulator should work
detector[in] the contact detector to use

Member Function Documentation

◆ addConstraint()

void addConstraint ( rwsim::dynamics::Constraint::Ptr  constraint)

Add a Constraint between two bodies.

Parameters
constraint[in] a pointer to the RobWork constraint.

◆ createDebugRender()

drawable::SimulatorDebugRender::Ptr createDebugRender ( )
virtual

Implements PhysicsEngine.

◆ emitPropertyChanged()

void emitPropertyChanged ( )
virtual

Implements PhysicsEngine.

◆ exitPhysics()

void exitPhysics ( )
virtual

Implements PhysicsEngine.

◆ getPropertyMap()

virtual rw::common::PropertyMap& getPropertyMap ( )
inlinevirtual

Implements PhysicsEngine.

◆ getSensors()

std::vector<rwlibs::simulation::SimulatedSensor::Ptr> getSensors ( )
inlinevirtual

get the list of simulated sensors

Returns

Implements PhysicsEngine.

◆ getTime()

double getTime ( )
inlinevirtual

Implements PhysicsEngine.

◆ handleCollisionBetween()

void handleCollisionBetween ( dGeomID  o0,
dGeomID  o1 
)

Returns a vector of all contact points.

Returns
vector of tuples (name1, name2, contact point)

◆ initPhysics()

void initPhysics ( rw::kinematics::State state)
virtual

Implements PhysicsEngine.

◆ load()

adds dynamic workcell

◆ resetScene()

void resetScene ( rw::kinematics::State state)
virtual

Implements PhysicsEngine.

◆ setContactDetector()

bool setContactDetector ( rw::common::Ptr< rwsim::contacts::ContactDetector detector)
virtual

Change the contact detector used by the engine.

Parameters
detector[in] the contact detector to use (NULL for default contact detection)
Returns
true if engine supports using a ContactDetector and the detector was set successfully.

Implements PhysicsEngine.

◆ setDynamicsEnabled()

void setDynamicsEnabled ( dynamics::Body::Ptr  body,
bool  enabled 
)

◆ setEnabled()

void setEnabled ( dynamics::Body::Ptr  body,
bool  enabled 
)

◆ step()

void step ( double  dt,
rw::kinematics::State state 
)
virtual

Implements PhysicsEngine.


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