dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.8k stars 237 forks source link

Hard real-time dynamics #293

Open lieskjur opened 2 years ago

lieskjur commented 2 years ago

Hi, I've developed some methods for modelling and controlling cable driven robots which I would like to implement in a library that can run in real-time. I have two questions

  1. Is there a resource that captures well the implementation of dynamics in rapier? (personally I am familiar with Rigid Body Dynamics Algorithms by Roy Featherstone)
  2. Is rapier and rust in general suitable for hard real-time applications?
sebcrozet commented 2 years ago

Hi! Rapier uses a symplectic Euler integration scheme. For multibodies (based on reduced-coordinates joints) we derived the equations of motions manually taking the reduced coordinates into account, and construct a full NxN (where N is the number of degrees of freedoms) mass matrix that we invert at each timestep. So the external and inertial forces applied to multibodies are integrated in a linearly-implicit way. For contacts and impulse-based joints, the constraints solver is based on PGS with Baumgarte stabilization (using implicit springs for stabilization).

Regarding hard-real-time applications, it depends on your workload and the efficiency of your device. I personally never tried Rapier in a performance-constrained environment, so benchmarking is the best way to figure out if it’s suitable to your use-case. Rust in general is very suitable for hard real-time application (it is as suitable as any other native languages like C/C++).

lieskjur commented 2 years ago

So I would imagine that for each "reduced-coordinate joint" you have a 6xn matrix and len 6 vector (lets say S and c) where the acceleration of the body succeeding the joint is a = S*\ddot{q} + c ?

sebcrozet commented 2 years ago

This is correct.

d-bucur commented 11 months ago

@sebcrozet Would it be possible to provide other, higher order integration methods (like Verlet or Forest Ruth) or maybe even a custom integrator? It would be useful in some high fidelity simulations (like orbital simulations, in which symplectic Euler is very inaccurate)