Solving for static balance

Static balance is solved with the other subtask of the balance task, moments balancing, which repositions the centre of mass of the figure such that the sum of all moments acting on the figure is zero. The user should specify forces acting on certain bones to provide input to this subtask. In the absence of external forces, the figure will be rotationally balanced about the origin by placing the CoG directly above it.

The direction of the global "up axis" should be passed as first argument to


so that the gravity force is applied to the figure in the correct direction (possible values are 0, 1 or 2 for global x, y, or z).

To enable/disable one or the other balance subtask subsequently, use

 IKBalanceTask::enableCGPosition(true|false) and 

Both subtasks can exist at the same time, for example, if the CoG is to be restricted to lie at a certain height while cancelling external moments from vertical forces. It is possible to enable only some of the CoG task degrees of freedom by calling

 IKTask::setDofs(bool x, bool y, bool z). 

In the above example, setting the global axis as the only degree of freedom of the CoG subtask should be sufficient.

For efficiency reasons, external forces are added to IKPositionTasks, to reuse computation. In most cases, the bone that has a force applied to it will also have a position target. To enable/disable force input, call

 IKPositionTask::enableForce(true|false, support_site=false),

to set the force -

 IKPositionTask::setForce(Real x, Real y, Real z). 

The force should be in global skeleton space and in the direction in which the world acts on the figure, for example, in the "up" direction for support forces on the ground. Forces should be on the same scale as figure mass*10, i.e. approximately in Newtons, otherwise the response might be too weak or too strong.

It is also possible to have a IKPositionTask without a position target, by calling


In this case, task weight, precision and priority will not apply but task length (the number of joints towards the root that is to be affected) will.

 Priority and weight for the moments subtask are set with 
 IKBalanceTask::setMomentsPriority(Real), and 

respectively. They apply to all 3 degrees of freedom of the moments subtask.

For static balance, the sum of all forces acting on the figure, including the gravity force, should be zero. The user can ensure this by setting appropriate forces, or the forces can be obtained from a physics environment. Alternatively, some forces can be defined as reaction forces at "support sites", by using

 IKPositionTask::enableForce(true, true). 

Normally, this would imply that there is also a position target for the bone in question. One of the support sites thus defined will be chosen by the solver to act as a zero momentum point (ZMP). Note that all global positions in the FIK skeleton will be with respect to this point. Hence any global position obtained from the segments, for example, with


will have to be added with the vector obtained with

 Vector& IKSolver::getZMP() 

when there is a balance task.


should be used to define the fraction of the total reaction force that each support site is carrying. The sum of all support ratios should therefore be 1. One application could be to make the figure lean onto one leg more than the other. It is not necessary to set the force on a IKPositionTask defined as a support site, as that force will be calculated by the solver.