moveit / moveit_calibration

Hand-eye calibration tools for robot arms.
BSD 3-Clause "New" or "Revised" License
132 stars 76 forks source link

baldor makes the package fails #133

Open hassan-tht opened 1 year ago

hassan-tht commented 1 year ago

Hi

I got the following error when I try to do the hand-eye calibration:

[ERROR] [1681225883.511651768]: Failed to load python module: handeye.calibrator
Traceback (most recent call last):
  File "/opt/ros/noetic/lib/python3/dist-packages/handeye/__init__.py", line 2, in <module>
    from .calibrator import HandEyeCalibrator, Setup
  File "/opt/ros/noetic/lib/python3/dist-packages/handeye/calibrator.py", line 5, in <module>
    import baldor as br
  File "/opt/ros/noetic/lib/python3/dist-packages/baldor/__init__.py", line 13, in <module>
    _MAX_FLOAT = np.maximum_sctype(np.float)
  File "/home/tht/.local/lib/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'

I'm using Noetic and my Numpy version is 1.24 which explains the error as np.float has been depreciated. A quick fix for me was to change the corresponding lines in opt/ros/noetic/lib/python3/dist-packages/baldor/__init__.py that have the np.float to just float

bmegli commented 1 year ago

Looks like it was fixed in baldor code

Looking at commits package with the fixes has not been released yet

Other ad-hoc fix options are probably:

bmegli commented 1 year ago

@hassan-tht

The likely reason why this happens is you have pip installed numpy at version >= 1.24

ROS depends on system package version which is overridden by pip version

To check pip version

pip show numpy

To check system version

apt-cache policy python3-numpy

I am experiencing similar problems on some of my development machines (likely pip installed packages that pulled numpy as dependency)

On production machines that have clean focal + noetic I don't face those problems.


One way to workaround is downgrading numpy to latest pre 1.24 version

# check installed version
pip show numpy

If numpy >= 1.24 downgrade to latest pre 1.24

# install at 1.23.5
pip install --force-reinstall numpy==1.23.5
hassan-tht commented 1 year ago

Thanks for the note regarding development/production machines. Downgrading is of course a valid option, but we have other related software stack that might complain if we downgrade