[pre_v2.0.0] Importing SDF bug
brothermechanic opened this issue · comments
Describe the bug
Importing SDF bug
To Reproduce
Steps to reproduce the behavior:
- importing SDF
Python: Traceback (most recent call last):
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/blender/operators/io.py", line 316, in execute
robot = core.Robot(inputfile=self.filepath)
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/core/robot.py", line 39, in __init__
raise e
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/core/robot.py", line 33, in __init__
super().__init__(xmlfile=xmlfile, submechanisms_file=submechanisms_file, smurffile=smurffile,
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/smurfrobot.py", line 95, in __init__
base_robot = parse_xml(self.xmlfile)
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/parser.py", line 49, in parse_xml
return XMLRobot.from_xml(xml_root, dialect=file_type, _xmlfile=xml_file)
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/base.py", line 350, in from_xml
return cls.factory[dialect].from_xml(cls, xml, **kwargs)
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/xml_factory.py", line 299, in from_xml
return classtype.create(**super(XMLFactory, self).kwargs_from_xml(xml, **kwargs))
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/base.py", line 342, in create
return cls(*args, **kwargs)
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/xmlrobot.py", line 76, in __init__
self.link_entities()
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/xmlrobot.py", line 122, in link_entities
assert self.check_linkage()
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/xmlrobot.py", line 133, in check_linkage
out &= entity.check_linkage()
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/base.py", line 204, in check_linkage
linked &= getattr(self, var).check_linkage()
File "/home/bm/.config/blender/3.5/scripts/addons/phobos/io/representation.py", line 75, in check_linkage
assert self.relative_to is not None
AssertionError
Expected behavior
Importing URDF works fine!
urdf.zip
Thanks could you share the SDF file you are loading? That'd be really helpful.
For the context:
Normally when importing a robot file the following happens:
-
The file is read and for all entities (links, joints, collisions, visuals, etc.) the representations are created
-
These representations are stored inside the Robot object.
-
Then all the entities are linked to the robot.
Many entity types hold references to others (e.g. a joint refers to a parent and a child link). To be more efficient in memory usage and compoutation the follwing states exist:- An unlinked robot: This means that those reference are just strings. E.g. joint states that its parent is "the_link".
- A linked robot: This means that all those references are indeed the link object. So the joint object holds under the parent property a python-reference of the real like object that is stored in the robot.
This way operations like renaming has to only rename the (e.g. link) object once and not all it's reference as well.
During this linking process some additional operations are executed. Like ensuring that poses hold a reference to the frame they are defined relative_to this step is e.g. done in the link (so that the poses of the link's parts (collisions etc.) refer to that link if not specified else in SDF.
Regarding this issue: I guess that for some case this definition of the relative frame is not yet implemented correctly. Therefore it would help to see the SDF if and how reltive_to is defined and for which parts.
To debug this issue I'd add some prints in io/base.py -> link_with_robot() to check when this occurs. The commit a just pushed might already help debugging this.
@brothermechanic Does this issue persist? This issue should be solved with my last commits. At least for e you blend file exports without issues. ;)
I consider this as solved. Please reopen if not.
Solved with 522aaa3
PS: As the fix changes which properties are stored inside blender it might be necessary for the file you have there to remove all origin related custom properties. ;)