Skip to content

Commit 07333df

Browse files
Example that loads all quadruped robot descriptions
1 parent 2e1ae67 commit 07333df

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
- Description: Ability Hand (MJCF)
1111
- Description: Ability Hand (URDF)
1212
- Description: Apptronik Apollo (MJCF)
13+
- Example: Load all quadruped robot descriptions
1314
- Export `DESCRIPTIONS` dictionary from top-level module
1415

1516
### Changed

examples/show_all_quadrupeds.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
# Copyright 2025 Inria
6+
7+
"""
8+
Show all quadruped robot descriptions using Pinocchio and MeshCat.
9+
"""
10+
11+
try:
12+
import pinocchio as pin
13+
from pinocchio.visualize import MeshcatVisualizer
14+
except ImportError as e:
15+
raise ImportError("Pinocchio not found, try `pip install pin`") from e
16+
17+
from robot_descriptions import DESCRIPTIONS
18+
from robot_descriptions.loaders.pinocchio import load_robot_description
19+
20+
GRID_SPACING = 2.0 # [m]
21+
GRID_SIZE = 5
22+
23+
if __name__ == "__main__":
24+
nb_quadrupeds = 0
25+
viewer = None
26+
visualizer = MeshcatVisualizer()
27+
28+
for name, description in DESCRIPTIONS.items():
29+
if "quadruped" not in description.tags:
30+
continue
31+
if name == "a1_mj_description":
32+
# See https://github.com/stack-of-tasks/pinocchio/issues/2613
33+
continue
34+
if name in ("anymal_b_mj_description", "anymal_c_mj_description"):
35+
# See https://github.com/stack-of-tasks/pinocchio/issues/2611
36+
continue
37+
robot = load_robot_description(
38+
name,
39+
root_joint=pin.JointModelFreeFlyer(),
40+
)
41+
robot.setVisualizer(visualizer)
42+
if viewer is None:
43+
robot.initViewer(open=True)
44+
viewer = robot.viewer
45+
robot.loadViewerModel()
46+
row = nb_quadrupeds // GRID_SIZE
47+
column = nb_quadrupeds % GRID_SIZE
48+
nb_quadrupeds += 1
49+
q = robot.q0.copy()
50+
q[0] = row * GRID_SPACING # [m]
51+
q[1] = column * GRID_SPACING # [m]
52+
robot.display(q)
53+
54+
print(f"Displaying {nb_quadrupeds} quadruped robot descriptions")
55+
input("Press Enter to close MeshCat and terminate... ")

0 commit comments

Comments
 (0)