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.

src/pycram/description.py Show resolved Hide resolved


@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

@@ -785,7 +785,7 @@ def get_aabb_for_link(self) -> AxisAlignedBoundingBox:
link_pose_trans = self.link.transform
inverse_trans = link_pose_trans.invert()
prospection_object.set_orientation(inverse_trans.to_pose())
return self.link.get_axis_aligned_bounding_box()
return self.link.get_bounding_box()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this mean that the bounding box is not necessarily axis aligned?

@@ -26,6 +27,14 @@ def get_point_as_list(point: Point) -> List[float]:
return [point.x, point.y, point.z]


def get_list_from_points(points: List[Point]) -> List[List[float]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

No documentation

transform)

def get_corners(self, transform: Optional[Transform] = None) -> List[List[float]]:
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

No documentation

src/pycram/datastructures/world.py Show resolved Hide resolved
src/pycram/datastructures/world.py Show resolved Hide resolved
src/pycram/description.py Show resolved Hide resolved
@@ -487,7 +501,7 @@ def get_link_axis_aligned_bounding_box(self, link_name: str) -> AxisAlignedBound
:param link_name: The name of the link.
:return: The axis aligned bounding box of the link.
"""
return self.links[link_name].get_axis_aligned_bounding_box()
return self.links[link_name].get_bounding_box()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could Return a bounding box that is Not Anis aligned which is confusing given the Method Name

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