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

Fix merging inertials with mass 0 #357

Conversation

AlpenAalAlex
Copy link
Collaborator

Description

On export we calculate the center of mass of all inertials of an object. This fails if their mass totals 0. In this case this PR uses their center as center of mass.

Related Issue

#349

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Assuming every inertial has the same mass if their mass is 0 in total
combined_com = mathutils.Vector((0.0,) * 3)
for obj in objects:
combined_com = combined_com + obj.matrix_local.translation
log(message=f"Inertial {objects[0].name} exported with mass 0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way you put the else part the combined_com will be somewhere outside the objects. If there is now mass we should take the center of volumes. Therefore the obj.matrix_local.translation should be weighted with the volume off the obj (convex hull if not watertight).

@hwiedPro hwiedPro mentioned this pull request May 16, 2024
6 tasks
@hwiedPro
Copy link
Collaborator

Thanks for your changes, @AlpenAalAlex , this looks fine to me now.

@hwiedPro hwiedPro merged commit b0d7dc9 into dfki-ric:master Jun 13, 2024
@hwiedPro hwiedPro mentioned this pull request Jun 13, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants