Genesis icon indicating copy to clipboard operation
Genesis copied to clipboard

[Bug Report] [Deprecated Code] NotImplementedError: `interp2d` has been removed in SciPy 1.14.0.

Open CloudRipple opened this issue 1 year ago • 0 comments

当我运行 Genesis/examples/rigid/terrain_subterrain.py 这个文件的时候,出现了一个报错: When I was running Genesis/examples/rigid/terrain_subterrain.py , an error was raised:

Traceback (most recent call last):
  File "/home/cloud/Genesis/examples/rigid/terrain_subterrain.py", line 70, in <module>
    main()
  File "/home/cloud/Genesis/examples/rigid/terrain_subterrain.py", line 39, in main
    terrain = scene.add_entity(
              ^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/utils/misc.py", line 38, in wrapper
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/engine/scene.py", line 359, in add_entity
    entity = self._sim._add_entity(morph, material, surface, visualize_contact)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/engine/simulator.py", line 134, in _add_entity
    entity = self.rigid_solver.add_entity(self.n_entities, material, morph, surface, visualize_contact)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/engine/solvers/rigid/rigid_solver_decomp.py", line 64, in add_entity
    entity = entity_class(
             ^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/engine/entities/rigid_entity/rigid_entity.py", line 68, in __init__
    self._load_model()
  File "/home/cloud/Genesis/genesis/engine/entities/rigid_entity/rigid_entity.py", line 90, in _load_model
    self._load_terrain(self._morph, self._surface)
  File "/home/cloud/Genesis/genesis/engine/entities/rigid_entity/rigid_entity.py", line 301, in _load_terrain
    vmesh, mesh, self.terrain_hf = tu.parse_terrain(morph, surface)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/utils/terrain.py", line 60, in parse_terrain
    subterrain_height_field = isaacgym_terrain_utils.random_uniform_terrain(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/Genesis/genesis/ext/isaacgym/terrain_utils.py", line 80, in random_uniform_terrain
    f = interpolate.interp2d(y, x, height_field_downsampled, kind="linear")
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cloud/miniforge3/envs/genesis/lib/python3.11/site-packages/scipy/interpolate/_interpolate.py", line 129, in __init__
    raise NotImplementedError(err_mesg)
NotImplementedError: `interp2d` has been removed in SciPy 1.14.0.

For legacy code, nearly bug-for-bug compatible replacements are
`RectBivariateSpline` on regular grids, and `bisplrep`/`bisplev` for
scattered 2D data.

In new code, for regular grids use `RegularGridInterpolator` instead.
For scattered data, prefer `LinearNDInterpolator` or
`CloughTocher2DInterpolator`.

For more details see
https://scipy.github.io/devdocs/tutorial/interpolate/interp_transition_guide.html

然后我尝试把 SciPy 的版本降到 1.13.1 ,问题就解决了,也没有产生其他的兼容性问题。 所以能否在pyproject.toml或任何地方限制SciPy的版本以保证兼容性,或者将interpolate.interp2d修改为适应新版本SciPy的方法。

Subsequently, I attempted to downgrade the version of the SciPy package to 1.13.1, and then, the error vanished. Therefore, I was wondering if you could either limit the version of the SciPy package within the pyproject.toml file to ensure compatibility, or make the necessary adjustments to the code so that it can adapt to the forthcoming versions of SciPy. This way, we can avoid similar issues in the future and keep the project running smoothly.

我尝试修改了Genesis/genesis/ext/isaacgym/terrain_utils.py对应部分的代码(从line 80开始),并在SciPy==1.13.1和SciPy==1.14.1都运行了刚才的terrain_subterrain.py,看起来运行没有问题。 代码修改如下,注释部分为原代码:

# f = interpolate.interp2d(y, x, height_field_downsampled, kind="linear")
f = interpolate.RegularGridInterpolator((y, x), height_field_downsampled, method="linear")

x_upsampled = np.linspace(0, terrain.width * terrain.horizontal_scale, terrain.width)
y_upsampled = np.linspace(0, terrain.length * terrain.horizontal_scale, terrain.length)
# z_upsampled = np.rint(f(y_upsampled, x_upsampled))
z_upsampled = np.rint(f((y_upsampled, x_upsampled)))

CloudRipple avatar Jan 08 '25 10:01 CloudRipple