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

Mesh and object #206

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

AbdelrhmanBassiouny
Copy link
Collaborator

@AbdelrhmanBassiouny AbdelrhmanBassiouny commented Oct 9, 2024

Added some extra functionality to use information from the meshes and adjust the meshes before they are cached if needed.

Added the option of getting the axis_aligned_bounding_box from mesh and link geometry in general instead of only from simulator, this adds more flexibility and does not require the simulator always to provide this functionality.

Also now there is rotated_bounding_box, and convex hull.

Added the option to provide callbacks for object addition and removal to be used by the users if needed.

@@ -50,7 +52,8 @@ def delete_cache_dir(self):

def update_cache_dir_with_object(self, path: str, ignore_cached_files: bool,
object_description: 'ObjectDescription', object_name: str,
scale_mesh: Optional[float] = None) -> str:
scale_mesh: Optional[float] = None,
mesh_transform: Optional['Transform'] = None) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to put Transform in quotation marks if you add the import:
from future import annotations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh that's nicee thanks

return cls(min_point[0], min_point[1], min_point[2], max_point[0], max_point[1], max_point[2])
:return: The points of the bounding box as a list of Point instances.
"""
return [Point(self.min_x, self.min_y, self.min_z),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this intended like this? and why are there so many points?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes these are the 8 corners of the bounding box.

"""
:param rotated: If True, return the rotated bounding box, otherwise the axis-aligned bounding box.
:return: The axis-aligned or rotated bounding box of a link. First try to get it from the simulator, if not,
then calculate it depending on the type of the link geometry.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add return to doc string

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean? there is already a :return: in the doc string.



@dataclass
class RotatedBoundingBox(BoundingBox):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why dont use a polytope here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can add the convex hull version which is available directly from trimesh, but this does not remove the need for a rotated shape, because the rotation here is meant to rotate the shape to the current pose of the link, this rotation will also be needed in a polytope or a convex hull as we only get the points relative to the object origin and are aligned with world frame not with object current frame.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added a method to get convex hull

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.

3 participants