-
Notifications
You must be signed in to change notification settings - Fork 3
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
Update MeshBuilder
class
#38
Conversation
cc @flferretti |
@diegoferigo With these changes, nothing is broken from my side! |
Excellent! I assume nothing broken except the change of name of |
Waiting a quick check from @traversaro before merging. |
Yes, exactly! |
I am a bit confused by the mass property in |
It is also not clear to me where we are accounting for the center of mass when computing the inertia properties. For all other primitive shapes, the center of mass is at the origin of the frame in which the primitive shape is expressed, but this is not true for meshes. |
msg = "Mesh '{}' is not watertight. Using a dummy inertia tensor." | ||
logging.warning(msg.format(self.mesh_uri)) | ||
self.inertia_tensor = np.eye(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it is better to just raise an error, instead of specifying a wrong value? So the user can specify the correct inertia if they want, instead of using a wrong value if the warning are overlooked (as it commonly happens)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done in this way for speeding up the generation of programmatic models having also meshes when correct inertial data is not needed. Setting the density of the mesh with trimesh is not a big effort, and since we have the support of automatically gathering the inertial properties from the mesh, I'm not against converting this warning to an exception.
All Meshes are different, because it's not possible to compute the inertia automatically unless, as you linked, the density is set and the mesh is watertight. The
I think this is related to what I asked in a previous review #33 (comment). Right now, all the builders expect the inertia expressed in a frame located at the CoM. If this is not the case, the user can specify a different pose of such frame when they call: |
Thanks, the explanation of the different use case is more clear. To be even more clear, I will name the following use cases you mentioned.
However, I am bit confused as in the tests only the mass is specified, following the use case common in the rest of the primitive builder, i.e.
Just to complete the analysis, there is a UC4 in which the user overrides the inertia specified at the shape level, i.e.
In the following I provide comments for all this use cases: UC1
Actually this was referred to the pose of the mesh, that is a transform between the link frame and the frame in which the mesh (i.e. the point composing the mesh) is expressed. For a generic mesh, there is no constraint for the center of mass of the mesh to lay at the origin of the frame in which the point of the mesh is expressed. In general, a mesh can have a CoM in a point different from the origin of the frame in which the mesh is expressed (diffently from the primitive shapes currently supported), so I think it make sense to permit the user to also specify the CoM in this API. UC2
I see two main problems in this use case:
UC3
Apparently this workflow is the one used in the tests.
Just fyi the only condition if for the mesh to be watertight. As long as as the mesh is watertight, you can compute the density corresponding to a given mass as mass/volume, and you can compute the inertia at the CoM as InertiaWithRodMass = ((mass/volume)/trimeshdensity)*InertiaWithTrimeshdensity . So a possible strategy is to permit to compute the inertia from the mass, and just raise an error if the mesh is not watertight. However, in this case you also need to properly propagate the CoM from the mesh, that is not currently accounted for (see previous comments). UC4
From what I understand, this UC seems clear. |
Ah, probably I would at least explicitly disallow the possibility of not setting the mass but setting explicitly the inertia. |
Getting back on this PR. Thanks for the feedback @traversaro! For the moment, I'm focusing on other things with higher priority. Let's see when I find some time to process your suggestions. Leaving this PR as stale for a more while. |
703b3ee
to
40a4967
Compare
@diegoferigo @traversaro what is the status of this PR ? thanks |
This PR streamlines building links with mesh-like collision and visual elements. There are open discussion points on how to handle the mass and inertia tensor, and specifically how to rely on trimesh for some sort of automatic computation from the mesh volume. If done well, the resulting logic (together with the mesh scale) could be taken as inspiration for extending hw optimization to meshed links. It's something that need proper thought and testing. Personally, I won't have enough time to dedicate on this in the short term. |
@diegoferigo I will take it then thanks. Is there an MVP PR you would like to merge before I take over ? |
Not really, excluding what detailed by @traversaro in #38 (comment), that was mainly related to the computation of mass|inertia tensor|CoM displacement, this PR was already working (if I recall) in the simplified use case that was first proposed by @lorycontixd. All Silvo's comments were additional considerations to make the final usage more complete and sound. |
Sorry, can’t we merge the simplified case used by @lorycontixd and defer improvements una. Subsequent PR ? @traversaro @diegoferigo |
Sure, no problem for me in merging as it is. |
40a4967
to
a8f97c6
Compare
Merging with failing isort since it will get fixed in #46. |
This PR enhances the mesh support introduced in #33. In particular:
cc @lorycontixd can you please try if the changes break your pipeline? For sure you have to update
mesh_path
withmesh_uri
. Sorry for this change, I overlooked this use-case in your original contribution.