Situation: Nan, Inf or huge value in QACC at DOF xx. The simulation is unstable. Time = xxx

[Example] http://www.mujoco.org/forum/index.php?threads/warning-nan-inf-or-huge-value-in-qacc-at-dof-1.3540/

  • Question1:

Hello,

I am simulating a 7-DoF robotic arm, and wanna assign the position of one joint like following (before 'mj_step(m, d);', in the main loop):

int id4 = mj_name2id(m, mjOBJ_JOINT, "robot_joint_4");

d->qpos[m->jnt_qposadr[id4]] = 0.5;

However, I got the following error during simulation:

WARNING: Nan, Inf or huge value in QACC at DOF 1. The simulation is unstable. Time = 3.3100.

While the remaining joints work well. The simulated robot behaves as it has been reseted to its original position at this error time point.

Could you please give me any hints about this problem? Thanks.

Answer 1:

The change you are making is somehow causing the simulation to become unstable. When that happens, you get a warning and the state is automatically reset.

So you should find a way to avoid the instability. My guess is that the position you are setting is causing a large contact penetration, or some other large constraint violation.

 

  • [Analysis] Uesless.

 

  • Question 2:

<option timestep="0.002" solver="CG" tolerance="1e-6"/>
<size nconmax="700" njmax="3000" nstack="1000000"/>
<worldbody>
<body name="B3_5" pos="-0.05 0 1">
<freejoint/>
<composite type="cloth" count="9 9 1" spacing="0.05" flatinertia="0.01">
<skin material="matcarpet" texcoord="true" inflate="0.005" subgrid="2"/>
<joint kind="main" damping="0.001"/>
<joint kind="twist" damping="0.001"/>
<geom type="capsule" friction="0.1 0.005 0.0001" size="0.015 0.01" rgba=".8 .2 .1 1"/>
</composite>
</body>
</worldbody>

When I apply somewhat high forces in simulate.cpp for this model, or use this model along with a fetch robot. I got the Inf error above. Do I have to simulate at even lesser time resolutions if I want to avoid this error? Are there other alternatives?

 

Answer 2:

It is better to use the Newton solver, since it has much higher accuracy. If the simulation is going unstable, you can reduce the time step or increase joint damping.

Note that grids are generally better behaved than cloth, even though they are more limited in what can be modeled.

 

  • [Analysis]

According to this answer, we know simulation stability is related to time step, It can be adjusted in xml file. As the answer mentioned, if we increase the value of “timestep”, the simulator crashed situation becomes more frequent.

We found the official statement:

Simulation time step in seconds. This is the single most important parameter affecting the speed-accuracy trade-off which is inherent in every physics simulation. Smaller values result in better accuracy and stability. To achieve real-time performance, the time step must be larger than the CPU time per step (or 4 times larger when using the RK4 integrator). The CPU time is measured with internal timers. It should be monitored when adjusting the time step. MuJoCo can simulate most robotic systems a lot faster than real-time, however models with many floating objects (resulting in many contacts) are more demanding computationally. Keep in mind that stability is determined not only by the time step but also by the Solver parameters; in particular softer constraints can be simulated with larger time steps. When fine-tuning a challenging model, it is recommended to experiment with both settings jointly. In optimization-related applications, real-time is no longer good enough and instead it is desirable to run the simulation as fast as possible. In that case the time step should be made as large as possible.

According to above, we decreased the value of timestep in xml file from “timestep=0.001”to “timestep=0.0008”. It seems the simulator stability improved.

The solver includes [PGS, CG, Newton]. The default is "Newton", relation of stability of this parameter need to be tested.

official statement:

This attribute selects one of the constraint solver algorithms described in the Computation chapter. Guidelines for solver selection and parameter tuning are available in the Algorithms section above.

For parameter damping cited in the above answer, it seem it need to be decrased. 

damping : real, "0"

Damping applied to all degrees of freedom created by this joint. Unlike friction loss which is computed by the constraint solver, damping is simply a force linear in velocity. It is included in the passive forces. Despite this simplicity, larger damping values can make numerical integrators unstable, which is why our Euler integrator handles damping implicitly. See Integration in the Computation chapter.

 

  • Question 3:

I am developing a version of the OpenAI ant model which uses tendons (I will move to muscles in the near future). I am running 1.5 for the time being.

During training runs that use this model I have encountered each of the following:

MuJoCo Warning: Nan, Inf or huge value in QPOS at DOF 0. The simulation is unstable. Time = 5.8700

MuJoCo Warning: Nan, Inf or huge value in QVEL at DOF 0. The simulation is unstable. Time = 31.5900

MuJoCo Warning: Nan, Inf or huge value in QACC at DOF 0

I have been unable to reliably replicate this crash making it difficult to debug. I have tried recording and replaying ctrl inputs to the model just prior to the crash but this didn't reproduce the error.

The model already uses the RK4 solver and I've seen the crash with timesteps down to 0.002. (Though I usually run with a larger timestep).

I would appreciate help with two things:

1. What exactly does DOF 0 refer to? How is the DOF numbering mapped to the model?

2. What is the best way to isolate the immediate cause of the above errors?

While I could guess and check with various parameters and hope it goes away I'd like to understand where the instability arises to be able to prevent future occurences.

Thank you for any time you spend on this.

 

Answer 3:

DOF 0 is the first DOF of the first joint defined in the model. If the model has a root joint, that would be the X-translation of the root. Note that the software only complains about the first DOF with suspicious values. It is possible that the other DOFs have the same problem.

RK4 is not always more stable than Euler. If there is damping in the joints, Euler with smaller time step is better.It is difficult to isolate the "immediate cause" of instability, because everything is interacting with everything else.

Try to reduce time steps, increase armature inertias, avoid very small masses and inertias in the model.Also, does this happen in contact behaviors or even without contact? You can disable contacts and gravity and see if the model is stable when you perturb it (and make it fly around).

 

  • [Analysis]

Official statement about integrator:

integrator : [Euler, RK4], "Euler"

This attribute selects the numerical integrator to be used. Currently the available integrators are the semi-implicit Euler method and the fixed-step 4-th order Runge Kutta method.

This parameter also need to be further tested.

 

  • Question 4:

<option timestep="0.002" solver="CG" tolerance="1e-6"/>

<size nconmax="700" njmax="3000" nstack="1000000"/>

<worldbody>

<body name="B3_5" pos="-0.05 0 1">

<freejoint/>

<composite type="cloth" count="9 9 1" spacing="0.05" flatinertia="0.01">

<skin material="matcarpet" texcoord="true" inflate="0.005" subgrid="2"/>

<joint kind="main" damping="0.001"/>

<joint kind="twist" damping="0.001"/>

<geom type="capsule" friction="0.1 0.005 0.0001" size="0.015 0.01" rgba=".8 .2 .1 1"/>

</composite>

</body>

</worldbody>

When I apply somewhat high forces in simulate.cpp for this model, or use this model along with a fetch robot. I got the Inf error above. Do I have to simulate at even lesser time resolutions if I want to avoid this error? Are there other alternatives?

 

Answer 4:

It is better to use the Newton solver, since it has much higher accuracy. If the simulation is going unstable, you can reduce the time step or increase joint damping.

Note that grids are generally better behaved than cloth, even though they are more limited in what can be modeled.

  • [Analysis]

According to this answer, we know another paramers-damping which is related to stability of simulator. And we know where should we place these parameters such as solver and integrator. But stability need to be tested.

To be continued ...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值