The Dynamic Balance Matrix or DBM is used to check the stability of surface contacts. Surface contact is considered to be stable when there is no sliding nor separation between the bodies is contact. The contact is stable if and only if folowing equation holds:

DBM constraint

where Z is the DBM,  FP is the contact force and MP is the contact the contact torque calculated for the referent point P on the surface. The proposed approach has wide applicability, since it can be used to check the stability of different kinds of contacts (including point, line and surface) with arbitrary perimeter shapes.

The following demo is used to calculate the DBM. In order to derive the DBM, the friction cone is aproximated by the friction pyramid. The number of sides in the pyramid is design parameter and pyramid with larger number of sides produces better aproximation, but increases the number of rows in DBM. Also, the friction coefficient can be selected as well as the initial angle.

After selecting friction cone parameters, points which define the shape of the surface should be defined. By default, the contact surface is rectangular, resembling the usual shape of the robotic feet, but additional points can be added in order to define arbitrary shape. The diagram of the surface (red area) with the approximation of the friction cone (gray area) is shown below.

Once the DBM is calculated its values are shown in code compatible with Matlab, Python and C/C++. For this demo the referent point P is the origin (x=0, y=0). The results can be copied and pasted directly to the programing language of your choice.

More details about the DBM can be found in following publication:

Nikolić, Milutin, Branislav Borovac, and Mirko Raković. "Dynamic balance preservation and prevention of sliding for humanoid robots in the presence of multiple spatial contacts." Multibody System Dynamics (2017): 1-22.

Number of sides:
Friction coeff:
Initial angle[deg]:


Matlab code:

Python code:

C/C++ code: