mmatl / urdfpy

Python parser for URDFs
http://urdfpy.readthedocs.io/
MIT License
224 stars 81 forks source link

Use of specific classname instead of cls when loading from xml #13

Open fishbotics opened 3 years ago

fishbotics commented 3 years ago

Hi,

I'm using urdfpy for some deep learning tasks and wrote a hacky extension that uses Pytorch tensors instead of numpy arrays. In order to do this, I extended the classes in urdfpy and only replaced the relevant methods. While doing that, I noticed that a lot of the classes have a _from_xml classmethod, but at the end of the method, they end up instantiating with the specific class instead of the cls variable. I ended up having to override all of these methods so that I could instantiate my subclass.

I'm happy to make a PR to change this, but I wanted to know: is there any reason why it's written the way it currently is?

As an example: https://github.com/mmatl/urdfpy/blob/master/urdfpy/urdf.py#L1145