bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.66k stars 2.88k forks source link

Compute reaction forces for joints (mobilizers) in btMultiBody #406

Closed erwincoumans closed 3 years ago

erwincoumans commented 9 years ago

At the moment, the joint reaction forces is not available for btMultiBody joints.

It would be good to compute them and make them available, similar to the btJointFeedback in btTypedConstraints.

We would need to cache some information during the forward dynamics computation (in btMultiBody::stepVelocitiesMultiDof) , as described nicely by Michael Sherman in the SimBody engine here: https://github.com/simbody/simbody/blob/master/Simbody/src/SimbodyMatterSubsystemRep.cpp#L5551

erwincoumans commented 9 years ago

A first implementation is in my fork, but some more work needs to be done for 'mobilizer' motor and limits (explicitly computing the required forces, rather than updating the acceleration immediately). https://github.com/erwincoumans/bullet3/commit/89edc40d61b7b9d36233094393ed07ff5470376f

kingchurch commented 9 years ago

Will the constraint (motor/limits) induced forces be separate from the joint reaction force ? The former is the forces along the axis of mobilizers while the latter are the reaction forces perpendicular to the mobilizer axis. Is the former the same as "appliedImpulse" on constraints ? Since appliedImpulse is already throttled by "maxImpulse" on motors/limits, the existing implementation may suffice in many cases. The latter is currently lacking to implement "break-able" mobilizer joints for example.

erwincoumans commented 9 years ago

All constraints (contacts, mobilizer motors and mobilizer limits, other pair-wise constraints between btMultiBody and other btMultiBody or btRigidBody) will induce joint reaction forces. The way I implement it now is that after solving all constraints, the force output (impulse/dt) of the MLCP solver will be applied as 'external' forces to the btMultiBody. Then all those forces will be propagated in the articulated body algorithm and generate force/torque feedback for each mobilizer (btMultiBody internal joint). Does that work for you?

erwincoumans commented 9 years ago

A new commit to support measuring the joint force/torque feedback for the motor/limits of the btMultiBody mobilizers (applying a force along the axis), and a pull request: https://github.com/bulletphysics/bullet3/pull/410 Still needs some testing, but mechanisms seems to work.

erwincoumans commented 9 years ago

a first comparison between joint force/torque feedback using rigid body versus multi body looks promising, results are fairly similar. Note that the joint feedback of btMultiBody is in local link space by default. A temporary global variable can switch it to world space (as used in the example, for comparison with constraint feedback, which is always in world space). use 'extern bool gJointFeedbackInWorldSpace; gJointFeedbackInWorldSpace = true; to enable world space feedback.

push request is here: https://github.com/bulletphysics/bullet3/pull/411 More testing and review is needed for the btMultiBody joint feedback

erwincoumans commented 9 years ago

The feature has been implemented. See examples/MultiBody/TestJointTorqueSetup how to use it. Separately, there is also feedback for a multibody constraint, such as a hinge motor. See examples/MultiBody/MultiBodyConstraintFeedback.cpp