ODE implementation details

From H3D.org

Jump to: navigation, search

Contents

General

The X3D specification seems to have been written as a direct mapping to ODE, so implementation is very straightforward since a function exists for almost every field.

BallJoint

CollidableOffset

CollidableShape

  • metadata
  • bboxCenter
  • bboxSize
  • enabled - dGeomEnable/dGeomDisable
  • rotation - dGeomSetRotation
  • translation - dGeomSetTranslation
  • shape - Box, Sphere and Cylinder go directly to its ODE equivalents. All other geometry nodes will be build using a ODE TriMesh. However this seems to be unstable for many models. Also not that Cylinder-Cylinder intersection is not implemented in ODE so cylinders will not interact with each other.

CollisionCollection

Collisions are handled in a callback function to the dSpaceCollide function(nearCallback). In this function we find the contact and set the contact paramaters according to the fields in the node.

  • metadata
  • collidables
  • enabled - if false, dSpaceCollide will not be called and hence no collisions will happen
  • appliedParameters
  • bounce - c.surface.bounce
  • frictionCoefficients - c.surface.mu, c.surface.mu2
  • minBounceSpeed - c.surface.bounce_vel
  • slipFactors - c.surface.slip1, c.surface.slip2
  • softnessConstantForceMix - c.surface.soft_cfm
  • softnessErrorCorrection - c.surface.soft_erp
  • surfaceSpeed - c.surface.motion1, c.surface.motion2

CollisionSensor

  • metadata
  • collider
  • enabled
  • contacts
  • isActive

Unimplemented fields

  • intersections - don't know exactly what the output should be. Checked xj3d code but seems they don't set it either.

CollisionSpace

Contact

Each contact made in collision detection in ODE is saved and parameters extracted. Each contact has an assiciated dContact object(called c below) and the fields are set as follows:

  • metadata
  • appliedParameters - c.surface.mode is checked to see what modes are active. All modes that are active will be added to appliedParamters. The mapping between the strings and modes in the contact object is straightforward.
  • body1
  • body2
  • bounce - c.surface.bounce
  • contactNormal - c.geom.normal
  • depth - c.geom.depth
  • frictionCoefficients - c.surface.mu, c.surface.mu2
  • frictionDirection - c.fdir1
  • geometry1
  • geometry2
  • minbounceSpeed - c.surface.bounce_vel
  • position - c.geom.pos
  • slipCoefficients - c.surface.slip1, c.surface.slip2
  • softnessConstantForceMix - c.surface.soft_cfm
  • softnessErrorCorrection - c.surface.soft_erp
  • surfaceSpeed - c.surface.motion1, c.surface.motion2

DoubleAxisHingeJoint

  • maxTorque1 and maxTorque2 fields - ODE specifies the corresponding param, dParamFMax to be >= 0. X3D spec allows for all real values.
  • hinge1Angle and hinge2Angle - ODE has only once get function for returned angle (dJointGetHinge2Angle1). hingeXAngle outputs relative angle between the two bodies.

MotorJoint

Issue 1

autoCalc is used to turn manual settings of of angles on/off. If it is off, engine will do auto calculation of axis angles. ODE says that when in auto mode, then the axes have to be set according to certain rules i.e

   * Only axes 0 and 2 need to be set. Axis 1 will be determined automatically at each time step.
   * Axes 0 and 2 must be perpendicular to each other.
   * Axis 0 must be anchored to the first body, axis 2 must be anchored to the second body. 

X3D spec says nothing of all these. In fact all the spec says is that axis 1 is anchored to global frame, axis 2 to first body, axis 3 to second body. This will not be right for auto mode in ODE.

Current implementation does no checks for this.


RigidBody

  • metadata
  • geometry
  • autoDamp
  • angularDampingFactor - a damping torque equal to angularVelocity * -angularDampingFactor is added
  • linearDampingFactor - a damping force equal to linearVelocity * -linearDampingFactor is added
  • autoDisable - dBodySetAutoDisableFlag
  • disableAngularSpeed - dBodySetAutoDisableAngularThreshold
  • disableLinearSpeed - dBodySetAutoDisableLinearThreshold
  • fixed - if fixed, attach the geometry to 0 instead of the rigid body. dGeomSetBody( ( dGeomID )params->shape_id, 0 );
  • forces - dBodyAddForceAtPos, dBodyAddRelForceAtRelPos
  • torques - dBodyAddTorque
  • orientation - dBodySetRotation/ dBodyGetRotation
  • position - dBodySetPosition/dBodyGetPosition
  • angularVelocity - dBodySetAngularVel/ dBodyGetAngularVel
  • linearVelocity - dBodySetLinearVel/dBodyGetLinearVel
  • mass - dBodySetMass with inertia parameters set from other fields.
  • massDensityModel - Box, Sphere, Cylinder working. dMassSetBoxTotal, dMassSetSphereTotal, dMassSetCylinderTotal.
  • centerOfMass, inertia -
dMassSetParameters( &ode_mass,
                     mass
                     center_of_mass.x, center_of_mass.y, center_of_mass.z,
                     inertia[0][0], inertia[1][1], inertia[2][2],
                     inertia[0][1], inertia[0][2], inertia[1][2] );
  • enabled - dMassSetParametersdBodyEnable/dBodyDisable
  • disableTime - dWorldSetAutoDisableTime
  • finiteRotationAxis - dBodySetFiniteRotationAxis
  • useFiniteRotation - dBodySetFiniteRotationMode
  • useGlobalGravity - dBodySetGravityMode

RigidBodyCollection

  • bodies
  • joints
  • metadata
  • collider
  • enabled - if not enabled we do not step the simulation
  • iterations - dWorldSetQuickStepNumIterations, so only has impact when preferAccuracy is false.
  • gravity - dWorldSetGravity
  • autoDisable - dWorldSetAutoDisableFlag
  • disableAngularSpeed - dWorldSetAutoDisableAngularThreshold
  • disableLinearSpeed - dWorldSetAutoDisableLinearThreshold
  • constantForceMix - dWorldSetCFM
  • contactSurfaceThickness - dWorldSetContactSurfaceLayer
  • disableTime - dWorldSetAutoDisableTime
  • errorCorrection - dWorldSetERP
  • maxCorrectionSpeed - dWorldSetContactMaxCorrectingVel
  • preferAccuracy - dStepWorld if true, dQuickStepWorld if false.

Unimplemented fields

  • set_contacts - don't know what it is supposed to do

SingleAxisHingeJoint

Using dJointCreateHinge to create joint. If either of body1 or body2 is NULL the other part of the joint will be attached to the world(dJointAttach with one argument set to 0).

  • metadata
  • body1
  • body2
  • forceOutput
  • anchorPoint - dJointSetHingeAnchor
  • axis - dJointSetHingeAxis
  • maxAngle - dJointSetHingeParam with dParamHiStop
  • minAngle - dJointSetHingeParam with dParamLoStop
  • stopBounce - dJointSetHingeParam with dParamBounce
  • stopErrorCorrection - dJointSetHingeParam with dParamStopERP
  • angle - dJointGetHingeAngle
  • angleRate - dJointGetHingeAngleRate
  • body1AnchorPoint - dJointGetHingeAnchor
  • body2AnchorPoint - dJointGetHingeAnchor2

SliderJoint

UniversalJoint

Personal tools
go to