Skip to content

Commit 4517227

Browse files
Merge pull request #160 from haixuanTao/main
add download command to cache folder in advance
2 parents 5eb58a9 + 84c0d93 commit 4517227

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add `pull` in the CLI to pull `robot_description` and cache it. (thanks to @haixuantao)
10+
711
## [1.18.0] - 2025-06-19
812

913
### Added

robot_descriptions/__main__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ def get_argument_parser() -> argparse.ArgumentParser:
4848
help="list all available robot descriptions",
4949
)
5050

51+
# pull ----------------------------------------------------------------
52+
parser_pull = subparsers.add_parser(
53+
"pull",
54+
help="load given robot description from the web and save it in cache",
55+
)
56+
parser_pull.add_argument(
57+
"name",
58+
help="name of the robot description",
59+
)
60+
5161
# show_in_meshcat --------------------------------------------------------
5262
parser_meshcat = subparsers.add_parser(
5363
"show_in_meshcat",
@@ -126,6 +136,22 @@ def list_descriptions():
126136
print(f"- {name} [{formats}]")
127137

128138

139+
def pull(name: str) -> None:
140+
"""Pull a robot description from the web and save it in cache.
141+
142+
Args:
143+
name: Name of the robot description.
144+
"""
145+
try:
146+
module = import_module(f"robot_descriptions.{name}")
147+
except ModuleNotFoundError:
148+
module = import_module(f"robot_descriptions.{name}_description")
149+
if hasattr(module, "URDF_PATH"):
150+
print(module.URDF_PATH)
151+
elif hasattr(module, "MJCF_PATH"):
152+
print(module.MJCF_PATH)
153+
154+
129155
def show_in_meshcat(name: str) -> None:
130156
"""Show a robot description in MeshCat.
131157
@@ -283,6 +309,8 @@ def main(argv=None):
283309
args = parser.parse_args(argv)
284310
if args.subcmd == "list":
285311
list_descriptions()
312+
elif args.subcmd == "pull":
313+
pull(args.name)
286314
elif args.subcmd == "show_in_meshcat":
287315
show_in_meshcat(args.name)
288316
elif args.subcmd == "show_in_mujoco":

0 commit comments

Comments
 (0)