Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting scaled meshes #338

Open
23pointsNorth opened this issue Oct 12, 2023 · 2 comments
Open

Exporting scaled meshes #338

23pointsNorth opened this issue Oct 12, 2023 · 2 comments
Assignees
Labels
bug Confirmed bug in Phobos code confirm fix Fixed bug, waiting for confirmation of reporter. merge requested Feature waiting for merge by developers.

Comments

@23pointsNorth
Copy link
Contributor

Describe the bug
I've sketched up a scene and rigged it with motors/joints.
(1) When exporting without [Apply mesh scale], the process succeeds, but with wrong model, as some of the meshes have non-uniform x,y,z, scales + the collision boxes don't get loaded in gazebo.
(2) When exporting with selected checkbox on [Apply mesh scale], I am getting the following error:

Error: Python: Traceback (most recent call last):
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/io.py", line 142, in invoke
    return self.execute(context)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/io.py", line 260, in execute
    self.exportModel(root, exportpath)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/io.py", line 215, in exportModel
    robot.export(
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/core/robot.py", line 682, in export
    self.export_meshes(mesh_output_dir=os.path.join(outputdir, rel_mesh_pathes[mf]), format=mf, apply_scale=apply_scale)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/core/robot.py", line 61, in export_meshes
    vc.geometry.provide_mesh_file(targetpath=os.path.abspath(mesh_output_dir), format=format,
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/io/representation.py", line 916, in provide_mesh_file
    self.apply_scale()
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/io/representation.py", line 1113, in apply_scale
    bpy.ops.object.transform_apply(scale=True)
  File "/snap/blender/4022/3.3/scripts/modules/bpy/ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Cannot apply to a multi user: Object "tmp_export_mesh.001", Mesh "mesh.001", aborting

Attempted to select the Object -> Relations -> Make Single User -> Object & Data & Materials, but it doesn't change the result. Is this Phobos related, or blender related?

To Reproduce
Steps to reproduce the behavior:

  1. Take model.
    excavator_dummy_boom.zip
  2. Click on export model with [Apply mesh scale] selected.
  3. See error

Expected behavior
For the exported dae meshes to contain the correct scale.

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu] Version 22.04]
  • Blender version 3.3

Additional context
(If they sound like bug and not user errors, can create issues)

  1. Another interesting quirk -> if a joint is rotated by 90 deg, the collision body generated from Phobos of a box, approximated with a box is very off (create a collision for visual object boom in this model.)
  2. Should all meshes be able to generate an inertial object?
Original exception was:
File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/editing.py", line 1048, in toggleVisual
Traceback (most recent call last):
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/editing.py", line 1189, in execute
    inertia = inertialib.calculateInertia(obj, mass, geometry, adjust=True, logging=True)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/utils/validation.py", line 806, in validation_wrapper
    return function(obj, *args, logging=logging, **kwargs)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/model/inertia.py", line 70, in calculateInertia
    inertia = calculateMeshInertia(mass, obj.data, scale=obj.scale)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/utils/inertia.py", line 150, in calculateMeshInertia
    triangles += [face]
ValueError: operands could not be broadcast together with shapes (0,) (1,17) (0,) 
Error: Python: Traceback (most recent call last):
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/operators/editing.py", line 1189, in execute
    inertia = inertialib.calculateInertia(obj, mass, geometry, adjust=True, logging=True)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/utils/validation.py", line 806, in validation_wrapper
    return function(obj, *args, logging=logging, **kwargs)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/blender/model/inertia.py", line 70, in calculateInertia
    inertia = calculateMeshInertia(mass, obj.data, scale=obj.scale)
  File "/home/bot/.config/blender/3.3/scripts/addons/phobos/utils/inertia.py", line 150, in calculateMeshInertia
    triangles += [face]
ValueError: operands could not be broadcast together with shapes (0,) (1,17) (0,) 
@AlpenAalAlex AlpenAalAlex self-assigned this Dec 10, 2023
AlpenAalAlex added a commit to AlpenAalAlex/phobos that referenced this issue Dec 11, 2023
AlpenAalAlex added a commit to AlpenAalAlex/phobos that referenced this issue Jan 9, 2024
Exporting pose relative to root link because gazebo 9 ignores relative_to attribute
AlpenAalAlex added a commit to AlpenAalAlex/phobos that referenced this issue Jan 10, 2024
Exporting pose relative to root link because gazebo 9 ignores relative_to attribute
@AlpenAalAlex AlpenAalAlex added the bug Confirmed bug in Phobos code label Feb 7, 2024
@AlpenAalAlex AlpenAalAlex added merge requested Feature waiting for merge by developers. confirm fix Fixed bug, waiting for confirmation of reporter. labels Mar 13, 2024
@hwiedPro
Copy link
Collaborator

@23pointsNorth Did you try @AlpenAalAlex PR?

@23pointsNorth
Copy link
Contributor Author

Sorry, I have not. I can see the model is attached in the original comment, so potentially can be tested.

AlpenAalAlex added a commit to AlpenAalAlex/phobos that referenced this issue Aug 8, 2024
Exporting pose relative to root link because gazebo 9 ignores relative_to attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug in Phobos code confirm fix Fixed bug, waiting for confirmation of reporter. merge requested Feature waiting for merge by developers.
Projects
None yet
Development

No branches or pull requests

3 participants