bdaiinstitute / spatialmath-python

Create, manipulate and convert representations of position and orientation in 2D or 3D using Python
MIT License
497 stars 82 forks source link

typing glitches? #111

Closed PhilFreeman closed 8 months ago

PhilFreeman commented 9 months ago

Installed everything with pip install rvc3python When I run ~/.local/bin/rvctool I get the following:

phil@Office:~$ ~/.local/bin/rvctool 
Traceback (most recent call last):
  File "/home/phil/.local/bin/rvctool", line 5, in <module>
    from RVC3.bin.rvctool import main
  File "/home/phil/.local/lib/python3.10/site-packages/RVC3/bin/rvctool.py", line 42, in <module>
    from spatialmath import *  # lgtm [py/polluting-import]
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/__init__.py", line 3, in <module>
    from spatialmath.pose2d import SO2, SE2
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/pose2d.py", line 26, in <module>
    import spatialmath.base as smb
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/base/__init__.py", line 5, in <module>
    from spatialmath.base.argcheck import *  # lgtm [py/polluting-import]
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/base/argcheck.py", line 19, in <module>
    from spatialmath.base.symbolic import issymbol, symtype
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/base/symbolic.py", line 15, in <module>
    from spatialmath.base.types import *
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/base/types.py", line 9, in <module>
    from spatialmath.base._types_39 import *
  File "/home/phil/.local/lib/python3.10/site-packages/spatialmath/base/_types_39.py", line 37, in <module>
    ArrayLike = Union[float, List[float], Tuple[float, ...], ndarray[Any, dtype[floating]]]
TypeError: 'numpy._DTypeMeta' object is not subscriptable

Which, looking at the other issues, looks like it may be more typing challenges. Python is v. 3.10.12, OS is Ubuntu 22.04.3 LTS

jcao-bdai commented 8 months ago

Hi @PhilFreeman , sorry for the late response.

Could you please try again (e.g. pip install --upgrade rvc3python)?

We actually just pushed a new release for spatialmath today. I tried your sequence just now and it seems to be working

# i started with a fresh environment for this test
pip install rvc3python
rvctool

 ____       _           _   _             __     ___     _                ___      ____            _             _   _____ 
|  _ \ ___ | |__   ___ | |_(_) ___ ___    \ \   / (_)___(_) ___  _ __    ( _ )    / ___|___  _ __ | |_ _ __ ___ | | |___ / 
| |_) / _ \| '_ \ / _ \| __| |/ __/ __|    \ \ / /| / __| |/ _ \| '_ \   / _ \/\ | |   / _ \| '_ \| __| '__/ _ \| |   |_ \ 
|  _ < (_) | |_) | (_) | |_| | (__\__ \_    \ V / | \__ \ | (_) | | | | | (_>  < | |__| (_) | | | | |_| | | (_) | |  ___) |
|_| \_\___/|_.__/ \___/ \__|_|\___|___( )    \_/  |_|___/_|\___/|_| |_|  \___/\/  \____\___/|_| |_|\__|_|  \___/|_| |____/ 
                                          |/                                                                                   
for Python (RTB==1.1.0, MVTB==0.9.4, SG==1.1.6, SMTB==1.1.6, NumPy==1.26.3, SciPy==1.11.4, Matplotlib==3.8.2)

    import math
    import numpy as np
    from scipy import linalg, optimize
    import matplotlib.pyplot as plt
    from spatialmath import *
    from spatialmath.base import *
    from spatialmath.base import sym
    from spatialgeometry import *
    from roboticstoolbox import *
    from machinevisiontoolbox import *
    import machinevisiontoolbox.base as mvb

    # useful variables
    from math import pi
    puma = models.DH.Puma560()
    panda = models.DH.Panda()

    func/object?       - show brief help
    help(func/object)  - show detailed help
    func/object??      - show source code

Results of assignments will be displayed, use trailing ; to suppress

Python 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.19.0 -- An enhanced Interactive Python. Type '?' for help.
'%.3g;'

>>> 
PhilFreeman commented 8 months ago

Yup! Set up a venv and did a clean pip install. Worked just as you show. Seems to have fixed the issue.