The results of physics simulation are affected by many parameters. If these parameters are not set correctly, we may not obtain the desired character motions. Some default values have been set to work in a typical settings and environment. However, user may want to fine tune these parameters when using a different skeleton, different scale unit to obtain best results.

  1. gravity : A typical gravity should be 9.8 m/s^2. In practice, it should be set according to the unit currently used. For example, if your character is created in centimeter (cm), then you should set gravity to 980 instead of 9.8.
    To set the gravity with Python script :
    1. phyEngine = phyManager.getPhysicsEngine(); # get the physics engine currently used
    2. phyEngine.setDoubleAttribute("gravity", valueOfGravity); # set the gravity value. 
  2. dt : The time step taken for each physics update. Physics engine usually requires small time steps for the simulation to be stable. For simple features like rigid body dynamics or ragdoll simulation, the time step can be as large as the screen refresh rate ( 60 Hz ). For more advanced features like pose tracking, the time step needs to be much smaller ( ~ 1000Hz) to maintain a stable simulation. 
    To set the time step :
    1. phyEngine = phyManager.getPhysicsEngine(); # get the physics engine currently used
    2. phyEngine.setDoubleAttribute("dT", value); # set the dt value. It must be positive. 
  3. Ks : This parameter determines how strong is the pose tracking. The higher this parameter is, the more closely the physical simulation will match the kinematic motion. The higher value also gives the character a more "rigid" feeling when there are external forces or collisions. However, setting this parameter too high would cause the physical simulation to become unstable. This will in turn require dt to be decreased to avoid such instability. In general, it should be set to counter the gravity so the character can just stay upright and follow the kinematic motion.
    To set Ks :
    1. phyEngine.setDoubleAttribute("Ks", value); # set the Ks value. It must be positive. 
       
  4. Kd : The damping parameter. This parameter is set to counter some unnatural oscillation body movements when Ks is high. If Kd is high, the resulting motion would be slower and less responsive. Similar to Ks, setting this parameter too high may also cause instability. 
    To set Kd :
    1. phyEngine.setDoubleAttribute("Kd", value); # set the Kd value. It must be positive. 

  5. MaxSimTime  : This parameter sets the maximum allowing time used for physics engine update. By default, the physics simulation will keep updating to match the current system time. This keeps the physics engine to sync up with the kinematic animation. However, if the scene is complicated or if the dt is very small, the physics engine may take a significant chunk of time for updating. This makes it more and more difficult for physics engine to sync up with the system and the performance will be slowed down significantly. By setting this parameter to a proper value ( by default it is 0.01 second ), it prevents the physics simulation from taking too much time and drag down the system performance. Note that when both dt and MaxSimTime are very small, the physics engine may not be able to iterate enough to follow the motion. This could cause the pose tracking to be inaccurate and slower physics response.
    To set MaxSimTime :
    1. phyEngine.setDoubleAttribute("MaxSimTime", value); # set the MaxSimTime value. It must be positive. 
       
  6. KScale : This parameter scale the Ks, Kd for a specific joint. This allows different Ks, Kd setting for each joint. Since each body link may have different mass and different number of descendent body links, it would not be feasible to use a single Ks, Kd for pose tracking. For example, a shoulder may need a larger Ks to generate more torque so the arm can be lifted to match the desired pose, while the wrist will need smaller values. The general guideline for setting this parameter should be according to the effective mass for the joint – the sum of mass from all descendent body links. 
    To set KScale :
    1. phyJoint = phyEngine.getPhysicsJoint("charName","jointName"); # get corresponding physics joint
    2. phyJoint.setDoubleAttribute("KScale", scaleValue); # set the KScale. It must be positive.