Klamp't  0.9.0
Public Types | Public Member Functions | Public Attributes | List of all members
Klampt::ODESimulator Class Reference

An interface to the ODE simulator. More...

#include <ODESimulator.h>

Public Types

enum  Status {
  StatusNormal =0, StatusAdaptiveTimeStepping =1, StatusContactUnreliable =2, StatusUnstable =3,
  StatusError =4

Public Member Functions

void SetGravity (const Vector3 &g)
void SetAutoDisable (bool autoDisable=true)
void SetERP (double erp)
void SetCFM (double erp)
ODESimulatorSettingsGetSettings ()
Status GetStatus () const
void GetStatusHistory (vector< Status > &statuses, vector< Real > &statusChangeTimes) const
void AddTerrain (TerrainModel &terr)
void AddRobot (RobotModel &robot)
void AddObject (RigidObjectModel &object)
bool CheckObjectOverlap (vector< pair< ODEObjectID, ODEObjectID > > &overlaps)
void Step (Real dt)
void StepDynamics (Real dt)
bool ReadState (File &f)
bool WriteState (File &f) const
size_t numTerrains () const
size_t numRobots () const
size_t numObjects () const
dWorldID world () const
const TerrainModelterrain (int i) const
ODEGeometryterrainGeom (int i) const
ODERobotrobot (int i) const
ODERigidObjectobject (int i) const
string ObjectName (const ODEObjectID &obj) const
dBodyID ObjectBody (const ODEObjectID &obj) const
dGeomID ObjectGeom (const ODEObjectID &obj) const
void EnableContactFeedback (const ODEObjectID &a, const ODEObjectID &b)
ODEContactListGetContactFeedback (const ODEObjectID &a, const ODEObjectID &b)
void GetContactFeedback (const ODEObjectID &a, vector< ODEContactList * > &contacts)
void ClearContactFeedback ()
bool InContact (const ODEObjectID &a) const
bool InContact (const ODEObjectID &a, const ODEObjectID &b) const
void DisableInstabilityCorrection ()
 Disables instability correction for the next time step. This should be done if you manually set several objects' velocities, for example.
void DisableInstabilityCorrection (const ODEObjectID &obj)
 Disables instability correction for the given object on the next time step. This should be done if you manually set an object's velocities, for example.
ODEJointAddJoint (const ODEObjectID &obj)
 Adds a new joint between obj and the world. The returned ODEJoint must be set up using the MakeHinge, MakeSlider, or MakeFixed functions.
ODEJointAddJoint (const ODEObjectID &a, const ODEObjectID &b)
 Adds a new joint between a and b. The returned ODEJoint must be set up using the MakeHinge, MakeSlider, or MakeFixed functions.
void RemoveJoint (ODEJoint *)
 Removes a single joint.
void RemoveJoints (const ODEObjectID &obj)
 Removes all joints touching obj.
void RemoveJoints (const ODEObjectID &a, const ODEObjectID &b)
 Removes all joints between a and b.
bool ReadState_Internal (File &f)
bool WriteState_Internal (File &f) const
void DetectCollisions ()
void SetupContactResponse ()
void SetupContactResponse (const ODEObjectID &a, const ODEObjectID &b, int feedbackIndex, ODEContactResult &c)
void ClearCollisions ()
bool InstabilityCorrection ()
virtual void GetSurfaceParameters (const ODEObjectID &a, const ODEObjectID &b, dSurfaceParameters &surface) const

Public Attributes

File lastState
Real lastStateTimestep
map< pair< ODEObjectID, ODEObjectID >, double > lastMarginsRemaining
list< ODEJointjoints

Detailed Description

An interface to the ODE simulator.

Step() performs collision detection, sets up contact response, calls StepDynamics(), and computes collision feedback.

StepDynamics() integrates the dynamics without setting up collision detection structures. This probably should not be used externally.

Read/WriteState can be used to serialize state to binary.

To get contact force information from the simulator, use the EnableContactFeedback() function to initialize feedback, and then call GetContactFeedback() to get a pointer to the feedback data structure. Contact forces are updated after Step().

Member Enumeration Documentation

Overall simulation status flag. If a status is:

  • Normal: everything is proceeding as normal.
  • AdaptiveTimeStepping: everything is proceeding as normal, but simulation may be slower than usual because adaptive time stepping needs to be used.
  • ContactUnreliable, then some objects have penetrated beyond the acceptable limits. Contact response artifacts, like penetration or jittering, may occur.
  • Unstable: then some objects have gone unstable. Usually this is due to poorly tuned motor PIDs or external forces/torques. Klamp't will try to force things back into a stable state, but the results are not guaranteed.
  • Error: some unknown error has occurred. All further simulation will stop.

Member Function Documentation

bool Klampt::ODESimulator::CheckObjectOverlap ( vector< pair< ODEObjectID, ODEObjectID > > &  overlaps)

Returns true if the current state is in "reliable" status. Otherwise returns false and populates the list of overlapping object pairs.

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