leggedrobotics / raisimLib

RAISIM, A PHYSICS ENGINE FOR ROBOTICS AND AI RESEARCH
http://www.raisim.com
327 stars 50 forks source link

Is getImpulse() the only way to get contact force? #64

Open ZQX323 opened 3 years ago

ZQX323 commented 3 years ago

Hi Jemin,

I want to get the contact force of the contact point. Seems like there is only a method getImpulse() to calculate contact impulse. To calculate the contact force, I have to calculate the derivative of force with respect to time. But how can I get dP/dt? Or is there a method to direct get the force?

A similar problem is the acceleration of the body. It seems no direct way to get acceleration. Should I use the integral of velocity?

Best, Qingxu

jhwangbo commented 3 years ago

In RaiSim, the contact impulse is applied during a time step. If you want to get force, you have to just divide it by the time step. This will give you an average force applied over that time step.

You can compute the acceleration by a finite-difference. Almost all simulators that you will see are velocity-based and do not provide acceleration directly