theg4sh / sdf2urdf

Converter gazebo's sdf to urdf.
22 stars 4 forks source link

TypeError: cannot concatenate 'str' and 'NoneType' objects #3

Open gonultasbu opened 2 years ago

gonultasbu commented 2 years ago

Hello,

I am getting the following error running the script with Python 2.7

Traceback (most recent call last):
  File ".\sdf2urdf.py", line 378, in <module>
    main()
  File ".\sdf2urdf.py", line 373, in main
    doc.convert()
  File ".\sdf2urdf.py", line 350, in convert
    c.convert()
  File ".\sdf2urdf.py", line 350, in convert
    c.convert()
  File ".\sdf2urdf.py", line 350, in convert
    c.convert()
  File ".\sdf2urdf.py", line 350, in convert
    c.convert()
  File ".\sdf2urdf.py", line 296, in convert
    mesh.setAttribute("filename", "file://"+self.uriToPath(model))
TypeError: cannot concatenate 'str' and 'NoneType' objects
theg4sh commented 2 years ago

@gonultasbu hi, thank you for reporting the issue.

This exception is kind of unuseful without source of sdf. Could you please provide it? And which OS you are using?

Offtopic: Could you please reproduce this issue using python3 and changes in https://github.com/theg4sh/sdf2urdf/pull/4? Asking due to python 2.7 is deprecated (https://peps.python.org/pep-0373/#update-april-2014) and I have not see any reason to continue support it.

AllenHuangDongyue commented 1 year ago

the same as python 3 Python-dotenv could not parse statement starting at line 4 Python-dotenv could not parse statement starting at line 5 Python-dotenv could not parse statement starting at line 6 Python-dotenv could not parse statement starting at line 7 Python-dotenv could not parse statement starting at line 8 Python-dotenv could not parse statement starting at line 9 Python-dotenv could not parse statement starting at line 10 Python-dotenv could not parse statement starting at line 11 Python-dotenv could not parse statement starting at line 21 Traceback (most recent call last): File "./sdf2urdf.py", line 403, in main() File "./sdf2urdf.py", line 398, in main doc.convert() File "./sdf2urdf.py", line 373, in convert c.convert() File "./sdf2urdf.py", line 373, in convert c.convert() File "./sdf2urdf.py", line 373, in convert c.convert() File "./sdf2urdf.py", line 260, in convert materials = gzMaterial.getColor(name) AttributeError: 'NoneType' object has no attribute 'getColor'

bascetta74 commented 1 month ago

I have the same issue, in my case the reason is that I have meshes in my package and thus many lines in my sdf like

model://bunker_common/meshes/bunker.stl

The function uriToPath, however, assumes that all models, meshes, etc. are located in a subfolder of GAZEBO_MODEL_PATH. For this reason the uri is converted into a path like "/usr/share/gazebo-11/models/bunker_additions/sensor_support/meshes/bar_20x20x100.stl" (that is wrong as my mesh is in the package folder, not in the gazebo folder). As a consequence if os.path.exists(path) fails and uriToPath returns None.