BerkeleyAutomation / autolab_core

Core utilities for Berkeley AutoLab.
https://berkeleyautomation.github.io/autolab_core
Apache License 2.0
80 stars 39 forks source link

__div__ python3 compatibility problem #25

Closed rickstaa closed 4 years ago

rickstaa commented 5 years ago

When I try to use the autolab_core.calibration.CameraChessboardRegistration class in a python 3 interpreter I get the following error:

Traceback (most recent call last):
  File "/home/ricks/.vscode-insiders/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/ricks/.vscode-insiders/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/ricks/.vscode-insiders/extensions/ms-python.python-2019.6.24221/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/opt/conda/envs/autograsp/lib/python3.7/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/opt/conda/envs/autograsp/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/opt/conda/envs/autograsp/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ricks/panda_autograsp/tools/test_perception_calibration.py", line 28, in <module>
    calibration_result = calibrator.register(sensor, new_config)
  File "/home/ricks/panda_autograsp/panda_autograsp/calibration.py", line 163, in register
    points_3d_plane = (k * points_3d_plane + points_3d[corner_ind]) / (k + 1)
TypeError: unsupported operand type(s) for /: 'PointCloud' and 'int'

This is caused by the fact that in python3 the __div__ operator was replaced by the __truediv__ and __floordiv__ operators (See this issue). I tested the solution in a python 2.7 and python 3.6 environment and send a pull request #26.

mjd3 commented 4 years ago

Fixed (#27 and #28)! Thanks for your help!