forked from dexsuite/dex-retargeting
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update] update README and postion retargeting examples
- Loading branch information
Showing
7 changed files
with
143 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/manopth/ | ||
/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from pathlib import Path | ||
from typing import Optional, Tuple, List | ||
|
||
import numpy as np | ||
import tyro | ||
|
||
from dataset import DexYCBVideoDataset | ||
from dex_retargeting.constants import RobotName, HandType | ||
from dex_retargeting.retargeting_config import RetargetingConfig | ||
from hand_robot_viewer import RobotHandDatasetSAPIENViewer | ||
from hand_viewer import HandDatasetSAPIENViewer | ||
|
||
# For numpy version compatibility | ||
np.bool = bool | ||
np.int = int | ||
np.float = float | ||
np.str = str | ||
np.complex = complex | ||
np.object = object | ||
np.unicode = np.unicode_ | ||
|
||
|
||
def viz_hand_object(robots: Optional[Tuple[RobotName]], data_root: Path, fps: int): | ||
dataset = DexYCBVideoDataset(data_root, hand_type="right") | ||
if robots is None: | ||
viewer = HandDatasetSAPIENViewer(headless=True, use_ray_tracing=True) | ||
else: | ||
viewer = RobotHandDatasetSAPIENViewer(list(robots), HandType.right, headless=True, use_ray_tracing=True) | ||
|
||
# Data ID, feel free to change it to visualize different trajectory | ||
data_id = 4 | ||
|
||
sampled_data = dataset[data_id] | ||
for key, value in sampled_data.items(): | ||
if "pose" not in key: | ||
print(f"{key}: {value}") | ||
viewer.load_object_hand(sampled_data) | ||
viewer.render_dexycb_data(sampled_data, fps) | ||
|
||
|
||
def main(dexycb_dir: str, robots: Optional[List[RobotName]] = None, fps: int = 10): | ||
""" | ||
Render the human and robot trajectories for grasping object inside DexYCB dataset. | ||
The human trajectory is visualized as provided, while the robot trajectory is generated from position retargeting | ||
Args: | ||
dexycb_dir: Data root path to the dexycb dataset | ||
robots: The names of robots to render, if None, render human hand trajectory only | ||
fps: frequency to render hand-object trajectory | ||
""" | ||
data_root = Path(dexycb_dir).absolute() | ||
robot_dir = Path(__file__).absolute().parent.parent.parent / "assets" / "robots" / "hands" | ||
RetargetingConfig.set_default_urdf_dir(robot_dir) | ||
if not data_root.exists(): | ||
raise ValueError(f"Path to DexYCB dir: {data_root} does not exist.") | ||
else: | ||
print(f"Using DexYCB dir: {data_root}") | ||
|
||
viz_hand_object(robots, data_root, fps) | ||
|
||
|
||
if __name__ == "__main__": | ||
tyro.cli(main) |