Skip to content

Commit 6f2cd1e

Browse files
Update CLI interface and show command to show_in_yourdfpy
1 parent 6ee1b42 commit 6f2cd1e

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ Loaders are implemented for the following robotics software:
5252

5353
Loading will automatically download the robot description if needed, and cache it to a local directory.
5454

55+
### Show a description
56+
57+
You can display a robot description directly from the command line:
58+
59+
```console
60+
python -m robot_descriptions show_in_meshcat go2_description
61+
```
62+
63+
A `robot_descriptions` alias for `python -m robot_descriptions` is also available.
64+
5565
### Import as submodule
5666

5767
You can also import a robot description directly as a submodule of `robot_descriptions`:
@@ -104,14 +114,6 @@ Visualizing a robot description:
104114
- [RoboMeshCat](https://github.com/robot-descriptions/robot_descriptions.py/tree/main/examples/show_in_robomeshcat.py)
105115
- [yourdfpy](https://github.com/robot-descriptions/robot_descriptions.py/tree/main/examples/show_in_yourdfpy.py)
106116

107-
## Command line tool
108-
109-
The command line tool can be used to visualize any of the robot descriptions below. For example:
110-
111-
```console
112-
robot_descriptions show solo_description
113-
```
114-
115117
## Descriptions
116118

117119
Available robot descriptions ([gallery](https://github.com/robot-descriptions/awesome-robot-descriptions#gallery)) are listed in the following categories:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ opts = [
4242
]
4343

4444
[project.scripts]
45-
robot_descriptions = "robot_descriptions._command_line:main"
45+
robot_descriptions = "robot_descriptions.__main__:main"
4646

4747
[project.urls]
4848
Homepage = "https://github.com/robot-descriptions"

robot_descriptions/__main__.py

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

51-
# show --------------------------------------------------------------------
51+
# show_in_yourdfpy --------------------------------------------------------
5252
parser_show = subparsers.add_parser(
53-
"show",
53+
"show_in_yourdfpy",
5454
help="load and display a given robot description",
5555
)
5656
parser_show.add_argument(
@@ -96,7 +96,7 @@ def list_descriptions():
9696
print(f"- {name} [{formats}]")
9797

9898

99-
def show(
99+
def show_in_yourdfpy(
100100
name: str,
101101
configuration: List[float],
102102
collision: bool,
@@ -114,8 +114,8 @@ def show(
114114
module = import_module(f"robot_descriptions.{name}_description")
115115
if not hasattr(module, "URDF_PATH"):
116116
raise ValueError(
117-
"show command only applies to URDF, check out the "
118-
"`show_in_mujoco.py` example for MJCF descriptions"
117+
"This command only works with URDF descriptions, use "
118+
"`show_in_mujoco` for MJCF descriptions"
119119
)
120120

121121
try:
@@ -156,7 +156,7 @@ def animate(name: str) -> None:
156156
if not hasattr(module, "URDF_PATH"):
157157
raise ValueError(
158158
"animation is only available for URDF descriptions, "
159-
"check out the ``show_in_mujoco.py`` example for MJCF"
159+
"check out the `show_in_mujoco.py` example for MJCF"
160160
)
161161

162162
print(
@@ -172,9 +172,13 @@ def main(argv=None):
172172
args = parser.parse_args(argv)
173173
if args.subcmd == "list":
174174
list_descriptions()
175-
elif args.subcmd == "show":
176-
show(args.name, args.configuration, args.collision)
175+
elif args.subcmd == "show_in_yourdfpy":
176+
show_in_yourdfpy(args.name, args.configuration, args.collision)
177177
elif args.subcmd == "animate":
178178
animate(args.name)
179179
else: # no subcommand
180180
parser.print_help()
181+
182+
183+
if __name__ == "__main__":
184+
main()

robot_descriptions/_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def update(
4343
op_code: Integer that can be compared against Operation IDs and
4444
stage IDs.
4545
cur_count: Current item count.
46-
max_count: Maximum item count, or ``None`` if there is none.
46+
max_count: Maximum item count, or `None` if there is none.
4747
message: Unused here.
4848
"""
4949
self.progress.total = max_count
@@ -112,8 +112,8 @@ def clone_to_cache(description_name: str, commit: Optional[str] = None) -> str:
112112
113113
Notes:
114114
By default, robot descriptions are cached to
115-
``~/.cache/robot_descriptions``. This behavior can be overriden by
116-
setting the ``ROBOT_DESCRIPTIONS_CACHE`` environment variable to an
115+
`~/.cache/robot_descriptions`. This behavior can be overriden by
116+
setting the `ROBOT_DESCRIPTIONS_CACHE` environment variable to an
117117
alternative path.
118118
"""
119119
try:

0 commit comments

Comments
 (0)