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

position retargeting demo fails when only *_glb.urdf is available #39

Closed
giuliano-97 opened this issue Sep 4, 2024 · 3 comments
Closed

Comments

@giuliano-97
Copy link
Contributor

RobotHandDatasetSAPIENViewer raises an exception when the only the *_glb.urdf is available for the selected robot.

Steps to reproduce

  1. Setup the code as described in the readme
  2. Follow the steps in the position retargeting readme to setup the dexycb dataset
  3. Run the position retargeting script with panda as the target robot - for this specific robot, only the *_glb.urdf file is available in the assets folder, whereas for the others there are two versions, *.urdf and *_glb.urdf:
python example/position_retargeting/visualize_hand_object.py --dexycb-dir=/path/to/dexycp/root --robots panda

Error

 Mimic joint adaptor enabled. The mimic joint tags in the URDF will be considered during retargeting.
To disable mimic joint adaptor, consider setting ignore_mimic_joint=True in the configuration. 
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/giuliano/.vscode/extensions/ms-python.debugpy-2024.10.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/home/giuliano/dev/h2r/dex-retargeting/example/position_retargeting/visualize_hand_object.py", line 64, in <module>
    tyro.cli(main)
  File "/home/giuliano/.virtualenvs/dex-retargeting/lib/python3.10/site-packages/tyro/_cli.py", line 229, in cli
    return run_with_args_from_cli()
  File "/home/giuliano/dev/h2r/dex-retargeting/example/position_retargeting/visualize_hand_object.py", line 60, in main
    viz_hand_object(robots, data_root, fps)
  File "/home/giuliano/dev/h2r/dex-retargeting/example/position_retargeting/visualize_hand_object.py", line 28, in viz_hand_object
    viewer = RobotHandDatasetSAPIENViewer(list(robots), HandType.right, headless=False)
  File "/home/giuliano/dev/h2r/dex-retargeting/example/position_retargeting/hand_robot_viewer.py", line 69, in __init__
    urdf_name = urdf_path.split("/")[-1]
AttributeError: 'PosixPath' object has no attribute 'split'

Cause and suggested fix

The issue is caused by this section in hand_robot_viewer.py i.e. when the path already contains the string "glb" it is not converted to a string which causes the call to split to fail. This can be fixed e.g. like this:

diff --git a/example/position_retargeting/hand_robot_viewer.py b/example/position_retargeting/hand_robot_viewer.py
index ecd1639..bb5dc71 100644
--- a/example/position_retargeting/hand_robot_viewer.py
+++ b/example/position_retargeting/hand_robot_viewer.py
@@ -65,6 +65,8 @@ class RobotHandDatasetSAPIENViewer(HandDatasetSAPIENViewer):
             urdf_path = Path(config.urdf_path)
             if "glb" not in urdf_path.stem:
                 urdf_path = str(urdf_path).replace(".urdf", "_glb.urdf")
+            else:
+                urdf_path = str(urdf_path)
             robot_urdf = urdf.URDF.load(str(urdf_path), add_dummy_free_joints=True, build_scene_graph=False)
             urdf_name = urdf_path.split("/")[-1]
             temp_dir = tempfile.mkdtemp(prefix="dex_retargeting-")
@yzqin
Copy link
Member

yzqin commented Sep 5, 2024

Hi @giuliano-97

Thanks for pointing out this bug and thank you so much for the proposed fix. I was wondering whether you would like to create a pull request from your forked repo to this repo and I can perform the merge request from your PR.

Thank you!

@giuliano-97
Copy link
Contributor Author

Hi @giuliano-97

Thanks for pointing out this bug and thank you so much for the proposed fix. I was wondering whether you would like to create a pull request from your forked repo to this repo and I can perform the merge request from your PR.

Thank you!

no problem, happy to help - and thank you for releasing this package, I think it will save me a fair bit of time :)
here you go: #40

@yzqin
Copy link
Member

yzqin commented Sep 5, 2024

Thank you!

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

No branches or pull requests

2 participants