# Which equations are solved by the PGS or TGS?

Discussion in 'Physics' started by HA1N, May 11, 2021.

1. ### HA1N

Joined:
Feb 17, 2021
Posts:
6
Hello Development Team,

I'm currently working on a robot simulation in Unity3D using the articulation body feature.
For my research it is important to understand the methods and algorithms the program uses to do a in depth comparison with Matlab/Simulink.

It is known that the iterative Featherstone Algorithm is used to get the all the velocities/forces/accelerations of each component of the articulation body. Using an unknown approach the equations of motion (EOM) are defined and the constraints are used to get a linear complementarity problem (LCP) or mixed linear complementarity problem (MLCP). This LCP/MLCP is then solved by the Projected Gauss-Seidel or Temporal Gauss-Seidel solver using a fixed timestep. (see https://www.researchgate.net/profil...04585159aa4cb43d8/Physics-Based-Animation.pdf)

My question aims to get a better understanding of how the LCP or MLCP is derived in PhysX. The temporal Gauss-Seidel solver is explained in the following paper: https://matthias-research.github.io/pages/publications/smallsteps.pdf. There a position based approach is used but I have found no sources that explain this approach for rigid bodies in detail.

In summary, I'm interested in how the EOM are derived and then converted to a LCP/MLCP that is solved by the mentioned solvers. Is there any bibliography of literature PhysX is based on or a brief documentation of the implemented algorithms/methods and where they originated from?

Kind regards,
Niklas

2. ### arfish

Joined:
Jan 28, 2017
Posts:
777
Hi,

I think this applies for most game engines, including Unity:

"...Unfortunately gaming engines are known for sacrificing physical accuracy to gain stability – by introducing artificial damping, or even more drastic measuressuch as ignoring Coriolis forces as in Havok and PhysX..."

Erez, Tom. et al. 2015. Simulation Tools for Model-Based Robotics: Comparison of Bullet, Havok, MuJoCo, ODE and PhysX. IEEE International Conference on Robotics and Automation (ICRA)

Edy likes this.
3. ### HA1N

Joined:
Feb 17, 2021
Posts:
6
Thank you for your reply! I have seen this paper already and it would definitley help to know the approach and simplifications used in the program. The documentation of PhysX 4.1 states that for an Articulation "velocity clamps or damping may be required to ensure stability of the simulation at large angular velocities", which is in accordance to the paper.

### Unity Technologies

Joined:
Jul 24, 2013
Posts:
574
Just wanted to say that the paper mentioned talks about PhysX from back in 2015, which was pre PhysX 4.1, and didn't have the reduced space articulations that we have now.

Sab_Rango, HA1N and arfish like this.
5. ### KarimGharbi

Joined:
Nov 29, 2022
Posts:
1
Why it is written in the internet that Unity 2021.1 is using a built in physic engine, which is somehow a version of PhysX 4.1.1, but the solver that the user has as an option in the project settings are only Projected Gauss Seidel and Temporal Gauss Seidel solvers and not the built in solver of PhysX like PBD, PD, acticulation solver, Featherstone solver and cloth solver? Can someone explain me what is the difference between the built in Unity solvers and the PhysX solvers?

Joined:
Sep 20, 2012
Posts:
1,503
7. ### leebissessar5

Joined:
Nov 15, 2022
Posts:
44
Didn't know it ignored Coriolis forces. My controllers still work assuming the dynamic model had Coriolis, so I guess the effect is negligible.

Guess I need to change some things in my documentation.

8. ### Edy

Joined:
Jun 3, 2010
Posts:
2,364
I don't know if ArticulationBodies are different, but in PhysX 3.x and 4.x standard Rigidbodies doesn't even integrate the Euler equations:
https://forums.developer.nvidia.com...pxrigiddynamic-in-pxscene-simulate-dt/27677/5

This means that the physics simulation of rigidbodies with non-uniform inertia (almost anything not being a primitive) is plainly faked and unrealistic. For example, these objects won't exhibit any precession when rotating freely: their angular velocity vector remains constant.

9. ### leebissessar5

Joined:
Nov 15, 2022
Posts:
44
That makes sense. Unity is a game engine first and foremost, but things might change in the future given how a lot of research papers now are discussing using Unity to create digital twins (which my project was based on).

There's a lot of areas I think could improve. I kind of wish PhysX allowed for double-precision Vector3s so I could actually have a decent rocket simulation in Unity. Another is more accurate fluid dynamics such as drag being a tensor. People will implement their own solutions either way, including myself.

10. ### leebissessar5

Joined:
Nov 15, 2022
Posts:
44
One thing I'm really curious about though is the interaction between connected Articulation and Rigid Bodies. How does it solve loop joints, etc.