Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An example fails #1364

Closed
pauljurczak opened this issue Sep 30, 2021 · 3 comments
Closed

An example fails #1364

pauljurczak opened this issue Sep 30, 2021 · 3 comments

Comments

@pauljurczak
Copy link
Contributor

I'm trying to run an example from https://trimsh.org/examples/ray.html. I'm using Python 3.7.3 on Raspberry Pi 4 with the newest RPi OS. This snippet:

import numpy as np
import trimesh

mesh = trimesh.creation.icosphere()
ray_origins = np.array([[0, 0, -3], [2, 2, -3]])
ray_directions = np.array([[0, 0, 1], [0, 0, 1]])

locations, index_ray, index_tri = mesh.ray.intersects_location(
        ray_origins=ray_origins,
        ray_directions=ray_directions)
print('The rays hit the mesh at coordinates:\n', locations)

produces:

Traceback (most recent call last):
  File "/home/pi/pick/old/test-trimesh.py", line 10, in <module>
    ray_directions=ray_directions)
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/ray/ray_triangle.py", line 107, in intersects_location
    **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/ray/ray_triangle.py", line 64, in intersects_id
    tree=self.mesh.triangles_tree,
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/caching.py", line 109, in get_cached
    value = function(*args, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/base.py", line 823, in triangles_tree
    tree = triangles.bounds_tree(self.triangles)
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/triangles.py", line 344, in bounds_tree
    tree = util.bounds_tree(triangle_bounds)
  File "/home/pi/.local/lib/python3.7/site-packages/trimesh/util.py", line 1756, in bounds_tree
    import rtree
  File "/home/pi/.local/lib/python3.7/site-packages/rtree/__init__.py", line 9, in <module>
    from .index import Rtree, Index  # noqa
  File "/home/pi/.local/lib/python3.7/site-packages/rtree/index.py", line 6, in <module>
    from . import core
  File "/home/pi/.local/lib/python3.7/site-packages/rtree/core.py", line 77, in <module>
    rt.Error_GetLastErrorNum.restype = ctypes.c_int
  File "/usr/lib/python3.7/ctypes/__init__.py", line 369, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 374, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/bin/python3: undefined symbol: Error_GetLastErrorNum

What is wrong?

@pauljurczak
Copy link
Contributor Author

I tried this example on Ubuntu 20.04, and it works just fine. I vaguely recall that one of the dependencies of trimesh could not be satisfied on 32-bit Raspberry Pi OS. Perhaps this is the source of this error.

@mikedh
Copy link
Owner

mikedh commented Sep 30, 2021

No worries, yeah this error is in rtree which is what trimesh's slow built-in ray checks (i.e. vs embree) use for broad-phase checking. It looks like this error is related to a) no rtree wheels bundling libspatialindex are built for ARM and b) no libspatialindex installed. If it exists on a Rasberry Pi you might try an apt-get install libspatialindex-dev.

@pauljurczak
Copy link
Contributor Author

Installing libspatialindex-dev fixes the problem. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants