{ "cells": [ { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wed Dec 11 15:28:03 2024 \n", "+-----------------------------------------------------------------------------+\n", "| NVIDIA-SMI 525.116.04 Driver Version: 525.116.04 CUDA Version: 12.0 |\n", "|-------------------------------+----------------------+----------------------+\n", "| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n", "| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n", "| | | MIG M. |\n", "|===============================+======================+======================|\n", "| 0 NVIDIA GeForce ... On | 00000000:3D:00.0 Off | N/A |\n", "| 27% 28C P8 10W / 250W | 3MiB / 11264MiB | 0% Default |\n", "| | | N/A |\n", "+-------------------------------+----------------------+----------------------+\n", " \n", "+-----------------------------------------------------------------------------+\n", "| Processes: |\n", "| GPU GI CI PID Type Process name GPU Memory |\n", "| ID ID Usage |\n", "|=============================================================================|\n", "| No running processes found |\n", "+-----------------------------------------------------------------------------+\n" ] } ], "source": [ "!nvidia-smi" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "only got 88/128 samples!\n", "only got 117/128 samples!\n", "only got 120/128 samples!\n", "only got 119/128 samples!\n", "only got 126/128 samples!\n", "only got 124/128 samples!\n", "only got 120/128 samples!\n", "only got 116/128 samples!\n", "only got 120/128 samples!\n", "only got 121/128 samples!\n", "only got 124/128 samples!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing link #0: base_link\n", "Processing link #1: link_0.0\n", "Processing link #2: link_1.0\n", "Processing link #3: link_2.0\n", "Processing link #4: link_3.0\n", "Processing link #5: link_3.0_tip\n", "Processing link #6: link_4.0\n", "Processing link #7: link_5.0\n", "Processing link #8: link_6.0\n", "Processing link #9: link_7.0\n", "Processing link #10: link_7.0_tip\n", "Processing link #11: link_8.0\n", "Processing link #12: link_9.0\n", "Processing link #13: link_10.0\n", "Processing link #14: link_11.0\n", "Processing link #15: link_11.0_tip\n", "Processing link #16: link_12.0\n", "Processing link #17: link_13.0\n", "Processing link #18: link_14.0\n", "Processing link #19: link_15.0\n", "Processing link #20: link_15.0_tip\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "only got 58/64 samples!\n", "only got 59/64 samples!\n", "only got 63/64 samples!\n", "only got 62/64 samples!\n", "only got 63/64 samples!\n", "only got 62/64 samples!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing link #0: palm\n", "Processing link #1: ffknuckle\n", "Processing link #2: ffproximal\n", "Processing link #3: ffmiddle\n", "Processing link #4: ffdistal\n", "Processing link #5: fftip\n", "Processing link #6: mfknuckle\n", "Processing link #7: mfproximal\n", "Processing link #8: mfmiddle\n", "Processing link #9: mfdistal\n", "Processing link #10: mftip\n", "Processing link #11: rfknuckle\n", "Processing link #12: rfproximal\n", "Processing link #13: rfmiddle\n", "Processing link #14: rfdistal\n", "Processing link #15: rftip\n", "Processing link #16: lfmetacarpal\n", "Processing link #17: lfknuckle\n", "Processing link #18: lfproximal\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "only got 62/64 samples!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Processing link #19: lfmiddle\n", "Processing link #20: lfdistal\n", "Processing link #21: lftip\n", "Processing link #22: thbase\n", "Processing link #23: thproximal\n", "Processing link #24: thhub\n", "Processing link #25: thmiddle\n", "Processing link #26: thdistal\n", "Processing link #27: thtip\n" ] } ], "source": [ "# ROOT_DIR = \"/data/Multi-GraspLLM\"\n", "# import os\n", "# import sys\n", "# sys.path.append(ROOT_DIR)\n", "# os.chdir(ROOT_DIR)\n", "\n", "from utils.hand_model import HandModel\n", "from utils.panda_gripper import PandaGripper\n", "import json\n", "\n", "\n", "urdf_allegro_path=\"./hand_model/allegro_hand_description/allegro_hand_description_right.urdf\"\n", "meshes_allegro_path=\"./hand_model/allegro_hand_description/meshes\"\n", "allegro_hand_model = HandModel(\"allegro\", urdf_allegro_path, meshes_allegro_path, batch_size=1, device=\"cuda\", hand_scale=1)\n", "\n", "urdf_shadow_path=\"./hand_model/shadow_hand_description/urdf/shadowhand_adjust.urdf\"\n", "meshes_shadow_path=\"./hand_model/shadow_hand_description/meshes\"\n", "shadow_hand_model = HandModel(\"shadowhand\", urdf_shadow_path, meshes_shadow_path, batch_size=1, device=\"cuda\", hand_scale=1)\n", "\n", "\n", "panda_gripper=PandaGripper()\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pickle\n", "\n", "with open(\"./mid-level-data/shadow.pkl\",\"rb\") as f:\n", " meta_shadow=pickle.load(f)\n", "\n", "with open(\"./mid-level-data/allegro.pkl\",\"rb\") as f:\n", " meta_allegro=pickle.load(f)\n", " \n", "with open(\"./mid-level-data/panda.pkl\",\"rb\") as f:\n", " meta_panda=pickle.load(f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualize Allegro Hand" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Little finger,middle finger,thumb finger and index finger touch the bottle body of cylinder_bottle.', 'Little finger,middle finger,thumb finger and index finger touch the bottle body of cylinder_bottle.']\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import trimesh\n", "import re\n", "import torch\n", "import numpy as np\n", "vocab_size=511\n", "object_code=\"cylinder_bottle_s104\"\n", "num=1\n", "angle=meta_allegro[object_code][num]['angle']\n", "obj_id=object_code\n", "\n", "\n", "infer_pose=torch.tensor(angle[0]+angle[1][:, :2].T.ravel().tolist()+angle[2])\n", "mesh_hand_list_infer=allegro_hand_model.get_meshes_from_q(q=infer_pose.cuda().unsqueeze(0))\n", "mesh_hand= trimesh.util.concatenate(mesh_hand_list_infer)\n", "\n", "pc=np.load(f\"./pc_8192/{obj_id}.npy\")[:,:3]\n", "point_colors = np.tile([255, 0, 0, 255], (pc.shape[0], 1))\n", "point_cloud = trimesh.points.PointCloud(pc,colors=point_colors)\n", "print(meta_allegro[object_code][num]['contact_info'])\n", "scene = trimesh.Scene()\n", "scene.add_geometry(point_cloud)\n", "scene.add_geometry(mesh_hand)\n", "scene.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualize Shadow Hand" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Little finger,ring finger,middle finger,thumb finger and index finger touch the mug body of mug.', 'all fingers touches the mug body of mug']\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import trimesh\n", "import re\n", "vocab_size=511\n", "object_code=\"mug_s139\"\n", "num=1\n", "angle=meta_shadow[object_code][num]['angle']\n", "obj_id=object_code\n", "\n", "\n", "\n", "\n", "\n", "infer_pose=torch.tensor(angle[0]+angle[1][:, :2].T.ravel().tolist()+angle[2])\n", "mesh_hand_list_infer=shadow_hand_model.get_meshes_from_q(q=infer_pose.cuda().unsqueeze(0))\n", "mesh_hand= trimesh.util.concatenate(mesh_hand_list_infer)\n", "\n", "print(meta_shadow[object_code][num]['contact_info'])\n", "pc=np.load(f\"./data/pc_8192/{obj_id}.npy\")[:,:3]\n", "point_colors = np.tile([255, 0, 0, 255], (pc.shape[0], 1))\n", "point_cloud = trimesh.points.PointCloud(pc,colors=point_colors)\n", "scene = trimesh.Scene()\n", "scene.add_geometry(point_cloud)\n", "scene.add_geometry(mesh_hand)\n", "scene.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Visual Panda Gripper" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dict_keys(['pump head', 'bottle body'])\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "object_code=\"chaoneng_handwash\"\n", "print(meta_panda[object_code].keys())\n", "\n", "angle=meta_panda[object_code]['pump head'][0]\n", "mesh_hand=panda_gripper.get_meshes(angle)\n", "\n", "pc=np.load(f\"./data/pc_8192/{object_code}.npy\")[:,:3]\n", "point_colors = np.tile([255, 0, 0, 255], (pc.shape[0], 1))\n", "point_cloud = trimesh.points.PointCloud(pc,colors=point_colors)\n", "scene = trimesh.Scene()\n", "scene.add_geometry(point_cloud)\n", "scene.add_geometry(mesh_hand)\n", "scene.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:eval_github]", "language": "python", "name": "conda-env-eval_github-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.21" } }, "nbformat": 4, "nbformat_minor": 2 }