From fb867321f01fbb17e45fd56f5acb4d1f5a11b650 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Mon, 11 Dec 2023 18:40:52 +0100 Subject: [PATCH 1/3] Fix #338 (2) --- phobos/io/representation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phobos/io/representation.py b/phobos/io/representation.py index 27349ad2..1eba30c0 100644 --- a/phobos/io/representation.py +++ b/phobos/io/representation.py @@ -1104,17 +1104,19 @@ def apply_scale(self): elif BPY_AVAILABLE and isinstance(self.mesh_object, bpy.types.Mesh): from ..blender.utils import blender as bUtils objname = "tmp_export_" + self.unique_name - tmpobject = bUtils.createPrimitive(objname, 'box', self.scale) + tmpobject = bUtils.createPrimitive(objname, 'box', (1,1,1)) + tmpobject.scale = self.scale # copy the mesh here - tmpobject.data = self.mesh_object + tmpobject.data = self.mesh_object.copy() bpy.ops.object.select_all(action='DESELECT') tmpobject.select_set(True) bpy.ops.object.transform_apply(scale=True) bpy.ops.object.select_all(action='DESELECT') tmpobject.select_set(True) + self.mesh_object = tmpobject.data bpy.ops.object.delete() else: - raise NotImplentedError() + raise NotImplementedError() self._operations.append("apply_scale") self.history.append(f"apply_scale {self.scale}") From 5ff300f1558bb68a4160d25c67c28837f2cf4a27 Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Tue, 9 Jan 2024 07:30:50 +0100 Subject: [PATCH 2/3] Fix link pose not exported in sdf #338 (1) #339 Exporting pose relative to root link because gazebo 9 ignores relative_to attribute --- phobos/blender/io/blender2phobos.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phobos/blender/io/blender2phobos.py b/phobos/blender/io/blender2phobos.py index 0cc600dd..3f671dd8 100644 --- a/phobos/blender/io/blender2phobos.py +++ b/phobos/blender/io/blender2phobos.py @@ -430,11 +430,18 @@ def deriveLink(obj, objectlist=None, logging=True, errors=None): annotations[k1] = {} annotations[k1][k2] = v + root = obj + while sUtils.getEffectiveParent(root) is not None: + root = sUtils.getEffectiveParent(root) + + # Exporting pose relative to root link because gazebo 9 ignores relative_to attribute + return representation.Link( name=obj.get("link/name", obj.name), # this is for backwards compatibility normally the linkname should be the object name visuals=visuals, collisions=collisions, inertial=inertial, + origin=deriveObjectPose(obj, effectiveparent=root), # [TODO v2.1.0] Add KCCD support kccd_hull=None, **annotations From a6f6e6deecd2ddaa3234864c49cdd25e2540db0b Mon Sep 17 00:00:00 2001 From: Alex Zastrow Date: Wed, 14 Feb 2024 18:10:54 +0100 Subject: [PATCH 3/3] Fix urdf export --- phobos/blender/io/blender2phobos.py | 3 ++- phobos/data/xml_formats.json | 2 +- phobos/io/representation.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/phobos/blender/io/blender2phobos.py b/phobos/blender/io/blender2phobos.py index 3f671dd8..ab11134c 100644 --- a/phobos/blender/io/blender2phobos.py +++ b/phobos/blender/io/blender2phobos.py @@ -435,13 +435,14 @@ def deriveLink(obj, objectlist=None, logging=True, errors=None): root = sUtils.getEffectiveParent(root) # Exporting pose relative to root link because gazebo 9 ignores relative_to attribute + # Remove originRoot in a future update return representation.Link( name=obj.get("link/name", obj.name), # this is for backwards compatibility normally the linkname should be the object name visuals=visuals, collisions=collisions, inertial=inertial, - origin=deriveObjectPose(obj, effectiveparent=root), + originRoot=deriveObjectPose(obj, effectiveparent=root), # [TODO v2.1.0] Add KCCD support kccd_hull=None, **annotations diff --git a/phobos/data/xml_formats.json b/phobos/data/xml_formats.json index 7e5fcff6..78f62d4c 100644 --- a/phobos/data/xml_formats.json +++ b/phobos/data/xml_formats.json @@ -653,7 +653,7 @@ "children": { "pose": { "classname": "Pose", - "varname": "origin" + "varname": "originRoot" }, "inertial": { "classname": "Inertial", diff --git a/phobos/io/representation.py b/phobos/io/representation.py index 1eba30c0..8559ad9c 100644 --- a/phobos/io/representation.py +++ b/phobos/io/representation.py @@ -1553,11 +1553,12 @@ def from_collision(self, coll, npoints=None, iv_mesh=None, kccd_path=None): class Link(Representation, SmurfBase): _class_variables = ["name", "visuals", "collisions", "inertial", "kccd_hull", "origin"] - def __init__(self, name=None, visuals=None, inertial=None, collisions=None, origin=None, + def __init__(self, name=None, visuals=None, inertial=None, collisions=None, origin=None, originRoot=None, noDataPackage=None, reducedDataPackage=None, is_human=None, kccd_hull=None, joint=None, **kwargs): SmurfBase.__init__(self, **kwargs) self.name = name self.origin = _singular(origin) + self.originRoot = _singular(originRoot) self.is_human = is_human self.returns += ['name', "is_human"] self.visuals = _plural(visuals)