Joints to the Physics Engine are like Shaders to the Rendering Engine. They are the fundamental building blocks to construct advanced physics models for games including cars, tanks, robots, mechs, powered ragdolls, construction vehicles, monster trucks, heavy weight machinery, ropes, bridges, virtual creatures, …, etc. The default Unity physics engine, PhysX, unfortunately works very poorly with articulated multi-rigid body models consisted of multiple joints. The joints simulated by PhysX are springy and unstable under big mass ratio configuration. And it becomes even worse when the joints are powered by motors under huge torques. Things just go crazy when you stack too many joints in one model with PhysX. The lack of high fidelity articulated physics support often manifest as the following problems:
- Two rigidly joined rigid bodies can be pulled apart under huge force
- Mass ratio between two joined rigid bodies is limited to less than 1:10 in order to maintain joint stability
- Heavy weight at the end of a long rope makes the rope springy, jumpy and unstable
- Motors are soft and cannot deliver enough power to drive multi-level articulated robotics
- Doors, hands, wheels wobble around their joint axis under heavy load
- Simulation step size (time interval) has to be reduced to too small to provide the needed accuracy which kills the performance
I’m working on a brand new APE : Advanced Physics Engine for Robust Joints to solve all these problems from their root - robust joint simulation. Here are a few video clips of early prototype. Sorry for the poor rendering quality and rough edges in the models. I barely had any time polishing the demos yet.
- Motorized Arm - PhysX vs Articulated Physics
All the segments of the arms are assembled with actuated hinge (revolute) joints. The motor max force of the PhysX assembly is set to the maximum. The motor max force of the Articulated Physics assembly is set to 100. The mass ratio between the parts are proportional to their volumes. As we can see PhysX motors couldn’t output enough power and drive the multi joints arm stably while APE drove the motors smoothly with no problem. Under the disturbance of an external spring force exerted by the author interactively PhysX model behaves like a rubber band while APE holds the hinge joints rigidly even under extreme stress.
- Monster Truck - PhysX vs Articulated Physics
All the 3 monster trucks were modeled with identical topology. The right-most truck was simulated by articulated physics with mass ratio of 1: 15: 40 between struct, wheel and torso. The left-most truck was simulated by PhysX of Unity 4.5.2 with mass ratio 1: 15: 40 and it entirely collapsed to the ground even though the springs on the struts were configured to the maximum limit. The middle truck was simulated by PhysX with a reduced mass ratio at 1: 15: 1 to lessen the pressure on the joints at a cost of less torso stability. Also the hinge motors on the middle car were set to the maximum to propel truck onto the stairs. Even so it crawled extremely slow and couldn’t climb up the stairs. The right-most truck simulated by Articulated Physics engine climbed up and down the stairs at ease. There was zero joint wobbling and the motors output tremendous amount of torque with great stability.
- Monster Truck Prototype - Articulated Physics
It is a monster truck chassis prototype of 4 independent suspension structs, decoupled front-wheel steering and 4WD. This is realtime physics simulation of the actual rubber-on-the-ground wheel collision, mechanical suspension and steering. No ray-casting, key-frame animation or special force accumulation scripts were used. Compared to the canned typical raycast vehicle model (aka wheel collider) this simple model simulate the real physics of the interaction of monster truck suspension, wheels and the complex terrain. It’s very hard if not impossible to fake such interaction with a single rigid body plus 4 ray-cast “wheels”.
- Articulated Spider
Besides mechanical machines APE can model and simulate articulated creatures too. The following is a quick demo of an articulated spider simulated by APE.
The spider has 8 ball socket joints at its shoulders and 8 hinge joints at its knees and 2 ball joints at its eye balls and 1 ball joint between the butt and the torso. All together it has 8 * 3 + 8 + 2 + 1 = 35 DOF (degree of freedom). The 24 DOF at the shoulders and knees are powered by APE velocity controlled position motors.
The simulation was fully dynamics and done in Unity editor in real-time. No key frame animations or kinematic motion. Occasionally I dragged the spider around with a dynamic spring force applied between the spider and the mouse cursor to spice things up a little bit.
Currently only a trivial 4-phase walk controller was implemented in C#. We can easily extend the script to teach the spider more gaits such as jump and turn. The topology of the spider needs some work too to balance the butt with the torso better and reduce the yaw during walk. What’s cool about APE editor is that you can generate the physics based motion controller using ID (Inverse Dynamics).
- Multi-Rope Crane
This multi-rope crane model is very challenging to simulate because :
- There are five ropes in the mechanism that form 4 loops in the topology which means error accumulation can go extremely fast if a tiny inaccuracy in the joints surfaces.
- The cargo box is extremely heavy compared to the rope. The mass ratio between the cargo box and a rope segment is 500:1.
- This is a heavily articulated mechanism. The ropes are simulated with 64 rigid bodies in capsule shapes interconnected with 64 ball joints.
It was said it’s impossible to simulate such mechanism with the built-in physics engine.
What do you think ? What’s your experience modeling challenging articulated multi-body mechanisms with the default PhysX engine ? Will APE be of interest to you ?
Thanks
A. P.