urdfpy icon indicating copy to clipboard operation
urdfpy copied to clipboard

Use of specific classname instead of cls when loading from xml

Open fishbotics opened this issue 5 years ago • 0 comments

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

fishbotics avatar Aug 14 '20 18:08 fishbotics