|
14 | 14 | # ============================================================================== |
15 | 15 |
|
16 | 16 | import dataclasses |
| 17 | +import warnings |
17 | 18 | from typing import Any, Optional, Sequence, Union |
18 | 19 |
|
19 | 20 | import mujoco |
@@ -153,6 +154,21 @@ def not_implemented(objtype, objid, geomtype): |
153 | 154 | if not_implemented(objtype, objid, types.GeomType.BOX) and not_implemented(reftype, refid, types.GeomType.BOX): |
154 | 155 | raise NotImplementedError(f"Collision sensors with box-box collisions are not implemented.") |
155 | 156 |
|
| 157 | + def _check_friction(name: str, id_: int, condim: int, friction, checks): |
| 158 | + for min_condim, indices in checks: |
| 159 | + if condim >= min_condim: |
| 160 | + for idx in indices: |
| 161 | + if friction[idx] < types.MJ_MINMU: |
| 162 | + warnings.warn( |
| 163 | + f"{name} {id_}: friction[{idx}] ({friction[idx]}) < MJ_MINMU ({types.MJ_MINMU}) with condim={condim} may cause NaN" |
| 164 | + ) |
| 165 | + |
| 166 | + for geomid in range(mjm.ngeom): |
| 167 | + _check_friction("geom", geomid, mjm.geom_condim[geomid], mjm.geom_friction[geomid], [(3, [0]), (4, [1]), (6, [2])]) |
| 168 | + |
| 169 | + for pairid in range(mjm.npair): |
| 170 | + _check_friction("pair", pairid, mjm.pair_dim[pairid], mjm.pair_friction[pairid], [(3, [0]), (4, [1, 2]), (6, [3, 4])]) |
| 171 | + |
156 | 172 | # create opt |
157 | 173 | opt_kwargs = {f.name: getattr(mjm.opt, f.name, None) for f in dataclasses.fields(types.Option)} |
158 | 174 | if hasattr(mjm.opt, "impratio"): |
|
0 commit comments