In Unity 2020.1 we have a new Physics component: ArticulationBody. Articulations make it easier than ever to simulate robotic arms and kinematic chains with realistic physics and movement. Along with other improvements from PhysX 4.1, Unity is more capable than ever of simulation for industrial applications.

## Unity 2020.1: delivering better physics

With Unity 2019.3 we upgraded our physics library from PhysX 3.4 to PhysX 4.1. While previous builds of that library delivered an excellent performance for a wide variety of game types, modeling reality for non-gaming applications was more difficult to accomplish. Modeling kinematic chains, like the type you’d see in a rag doll, robotic arm, or mechanism with several concurrent hinges, would result in stuttery, and unrealistic motion. Not only would these joints look peculiar, but they would also be impossible to use for simulating a real device, impeding efforts to model or prototype industrial designs.

One of the major culprits of these real-world shortcomings was the selection of joint components that connected rigid bodies together. These joints, coupled with a physics solver optimized for game performance over fidelity, resulted in kinematics that failed to simulate realistically.

Learn more about the overall improvements brought by PhysX 4.1 here.

### Modeling motion using joints

Certain applications require constraining the motion of some rigid bodies relative to each other. To visualize this, imagine connecting the skeleton bones of a rag doll, a multi-jointed robotic arm, or having a door rotating on its hinge. This has traditionally been made possible by the means of the joint components such as the FixedJoint or the ConfigurableJoint that connect two Rigidbody objects together.

Behind the scenes, each joint will be decomposed into a few primitive constraints, such as a linear constraint to keep the bodies at some specific distance or an angular constraint to keep the bodies oriented in a specific way around a particular axis. Those same constraints are used to keep the bodies from overlapping each other by maintaining the same distance apart. All of the constraints combined will be plugged into an iterative solver that aims at converging to a set of impulses to apply to each of the connected pairs of objects in world space that will position them to satisfy all of the constraints, if possible.

### Problems with using the old joints

The first problem is the sheer number of conflicting factors that can create convergence issues for the solver. Iteration count, the relative masses of connected bodies, and the total complexity of the set of the constraints in a scene can create an unsolvable scenario. In cases like this, the partial solution is used, so certain constraints are left unsatisfied.

The second problem is that the magnitude of the impulse applied depends on the joint error — a value that shows how badly a constraint is violated at a given time. Because of this error compensation behavior, there will always be at least some springy effect, exactly as if the bodies were connected by a set of damped springs, especially when joints are chained together.

### Bringing articulations to Unity – a better way to model realistic motion

Our solution to the above kinematics problem is the new concept of articulation: a set of bodies organized in a logical tree, where a parent-child relation expresses the idea of mutually constrained motion. There is always a single root body, and there can be no loops. We use Unity’s transform hierarchy to express articulations.

Now, users can easily model an existing robot like the Universal Robots UR3e below and simulate a task that more accurately reflects what that movement would look like in the real world. This allows roboticists to visualize a particular movement sequence, test new code, or even validate new designs in a synthetic environment.

Articulations help roboticists and other industrial developers in two major ways: they move in a more similar fashion to their real-world counterparts, and they can be constructed faster than the old RigidBody+Joint, saving development time.

We anticipate that one of the main use cases for articulations will be in the field of robotics. Robotic arms often have six or more joints linked serially in a row, which means that small errors in each relative joint pose can have a potentially large effect on the pose of the end effector; errors are propagated up the kinematic chain which creates unrealistic movements and an end effector position that has drifted off target.

Simulation can help roboticists accelerate their development time by modeling many deployment scenarios and unit tests virtually, and then execute them at scale rather than trying to run those same suites of tests on a real robot in real-time. We hope that the ArticulationBody component, as well as the improvements to PhysX, can help roboticists use Unity for their simulation efforts.

The amount of degrees of freedom in a given parent-child relationship depends on the actual joint type used. Currently, we support:

**Fixed**: has zero degrees of freedom and is used to lock the bodies relative to each other**Prismatic**: has one degree of freedom, which is a linear offset along a particular axis relative to the parent**Revolute**: has one degree of freedom, a rotational analog of the Prismatic**Spherical**: has up to three degrees of freedom, and is a ball-in-socket joint that only allows relative rotations but no linear motion

In order to further increase the realism of these joints, a new solver based on Featherstone’s algorithm is used. This technique computes the effects of forces applied to a structure of joints, links, and solid bodies using reduced coordinates- that is, space where each body has as many coordinates relative to its parent as there are degrees of freedom. Previously, we relied on maximal coordinates that were more performant for general use cases but made sacrifices to accuracy and precision to gain that performance.

### Forward Dynamics and Articulation

Forward dynamics and articulations in a reduced coordinate space help satisfy the high requirements for precision and accuracy that robotic arms need. Along with other improvements provided by PhysX 4.1 such as the TGS solver, articulations make reliable robotic arm simulations possible in Unity for the first time. Modeling a robot using the iterative joint solver required precise tuning and shortcuts that would still fail to match the movement of a real robot.

We use the forward dynamics algorithm to simulate articulations in the reduced coordinate space (that is a space where each body has as many coordinates relative to its parent as there are degrees of freedom). It scales linearly with the total amount of degrees of freedom in an articulation, and can be faster than using the traditional iterative solver that scales with the number of constraints instead while computing a more accurate result.

### ArticulationBody- The new physical component in Unity

To support articulations in Unity, we added one new component: the ArticulationBody. Drawing an analogy with regular physics, ArticulationBody is like Rigidbody and ConfigurableJoint in one component. In an articulation, all bodies except the root one have a joint connecting them to their parent, that’s why they were not separated into individual components.

The shape of the bodies is described by using the regular Collider component, just like with Rigidbodies.

Once created, the bodies in an articulation cannot be moved by the means of the Transform component, because it can break the limits set by the reduced space coordinates. The only exception is the root body, that can be moved using the ArticulationBody.TeleportRoot function. ArticulationBody won’t respond to the changes in the Transform component by design.

That said, there are several possible ways of interacting with an articulation. Firstly, forces and torques can be applied to each body in an articulation. Secondly, each joint has a linear drive per each degree of freedom that can be controlled by setting linear and angular targets. Finally, it’s possible to alter the poses of bodies in the reduced coordinate space directly.

### Comparing articulation to the fixed or configurable joint

One particular advantage of articulations is that the quality of simulation doesn’t directly depend on the mass ratio of connected bodies. With rigid bodies and fixed joints, simulation started to look unrealistic with mass ratios higher than 10:1 between connected bodies. In the following example, however, you can see a dimensional grid of articulation bodies connected with fixed joints can still be simulated precisely, even with the red spheres being 1000 times heavier than the black ones.

Now, users can easily model an existing robot like the Universal Robotics UR3e below and simulate a task that more accurately reflects what that movement would look like in the real world. This allows roboticists to visualize a particular movement sequence, test new code, or even validate new designs in a synthetic environment.

Simulation can help roboticists accelerate their development time by modeling many deployment scenarios and unit tests virtually, and then execute them at scale rather than trying to run those same suites of tests on a real robot in real-time. We hope that the ArticulationBody component, as well as the improvements to PhysX, can help roboticists use Unity for their simulation efforts.

## Want to try it out for yourself?

To see how a serial link robot arm can be constructed with articulation joints, check out our robotics demo project.

Download Unity 2020.1, now in beta, to try your hand at using ArticulationBody.

Source: Unity Technologies Blog