-
Notifications
You must be signed in to change notification settings - Fork 8
Draft: Add grasp annotator #196
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,11 @@ | |||||||||||||||||||||||||||||||||||||||||
| from embodichain.utils.math import convert_quat | ||||||||||||||||||||||||||||||||||||||||||
| from embodichain.utils.math import matrix_from_quat, quat_from_matrix, matrix_from_euler | ||||||||||||||||||||||||||||||||||||||||||
| from embodichain.utils import logger | ||||||||||||||||||||||||||||||||||||||||||
| from embodichain.toolkits.graspkit.pg_grasp.antipodal_annotator import ( | ||||||||||||||||||||||||||||||||||||||||||
| GraspAnnotator, | ||||||||||||||||||||||||||||||||||||||||||
| GraspAnnotatorCfg, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+41
|
||||||||||||||||||||||||||||||||||||||||||
| from embodichain.toolkits.graspkit.pg_grasp.antipodal_annotator import ( | |
| GraspAnnotator, | |
| GraspAnnotatorCfg, | |
| ) | |
| try: | |
| from embodichain.toolkits.graspkit.pg_grasp.antipodal_annotator import ( | |
| GraspAnnotator, | |
| GraspAnnotatorCfg, | |
| ) | |
| except ImportError: | |
| logger.warning( | |
| "Optional dependency 'embodichain.toolkits.graspkit.pg_grasp.antipodal_annotator' " | |
| "could not be imported. Grasp-related functionality may be unavailable." | |
| ) | |
| GraspAnnotator = None # type: ignore[assignment] | |
| GraspAnnotatorCfg = None # type: ignore[assignment] |
Copilot
AI
Mar 25, 2026
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.
New public method RigidObject.get_grasp_pose() adds user-facing behavior (caching + pose computation) but there is no automated test coverage for it. Since tests/sim/objects/test_rigid_object.py exists, please add at least a unit test for the deterministic math path and a smoke test for the [num_envs, 4, 4] output shape.
Copilot
AI
Mar 23, 2026
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.
get_grasp_pose() caches _grasp_annotator on first call and reuses it thereafter, but it also takes a cfg parameter. If callers pass a different cfg later (e.g., different viser_port / sampling params), it will be silently ignored because the existing annotator isn’t updated/recreated. Consider recreating the annotator when cfg changes (or remove cfg from the method signature and configure via a setter/constructor).
| if hasattr(self, "_grasp_annotator") is False: | |
| self._grasp_annotator = GraspAnnotator(cfg=cfg) | |
| if hasattr(self, "_hit_point_pairs") is False or cfg.force_regenerate: | |
| # (Re)create grasp annotator if it does not exist yet or if the | |
| # configuration has changed since the last call. | |
| annotator_needs_update = ( | |
| not hasattr(self, "_grasp_annotator") | |
| or not hasattr(self, "_grasp_annotator_cfg") | |
| or self._grasp_annotator_cfg != cfg | |
| ) | |
| if annotator_needs_update: | |
| self._grasp_annotator = GraspAnnotator(cfg=cfg) | |
| self._grasp_annotator_cfg = cfg | |
| # Invalidate cached hit point pairs so they will be regenerated | |
| # with the new annotator / configuration. | |
| if hasattr(self, "_hit_point_pairs"): | |
| del self._hit_point_pairs | |
| if not hasattr(self, "_hit_point_pairs") or cfg.force_regenerate: |
Copilot
AI
Mar 25, 2026
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.
open_lengths contains tensors from get_approach_grasp_poses(), but visualize_grasp_pose() expects open_length: float and uses it in Open3D geometry transforms. Convert to a Python float (e.g., open_length.item()) before passing it to avoid runtime type errors in visualization.
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.
RigidObjectnow importsGraspAnnotator(and its dependencies likeviser/trimesh/open3d) at module import time. This makes the core sim objects package depend on optional UI/geometry libraries and can break environments that don’t have those extras installed, even if grasp annotation isn’t used. Consider moving these imports insideget_grasp_pose()and raising a clear, actionable error if the optional deps are missing.