diff --git a/CHANGELOG.md b/CHANGELOG.md index 141e671..37da0b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - Description: BXI Elf2 (URDF) - Example: Load all humanoid robot descriptions - Example: Load all quadruped robot descriptions +- Example: Show any robot description in the Candlewick viewer - Export `DESCRIPTIONS` dictionary from top-level module ### Changed diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..e30355f --- /dev/null +++ b/examples/README.md @@ -0,0 +1,21 @@ +# Examples + +## Show all humanoid descriptions + +This example shows all humanoid robot descriptions using Pinocchio and MeshCat: + +``` +python all_humanoids.py +``` + +![image](https://github.com/user-attachments/assets/cc3cc4e9-622e-4cc5-b7d1-5a01d22cb827) + +## Show all quadruped descriptions + +This example shows all quadruped robot descriptions using Pinocchio and MeshCat: + +``` +python all_quadrupeds.py +``` + +![image](https://github.com/user-attachments/assets/0de682e5-8b8e-4c9d-856c-386c1aa6214a) diff --git a/examples/load_in_idyntree.py b/examples/load_in_idyntree.py index 95aa5bf..32cd08e 100644 --- a/examples/load_in_idyntree.py +++ b/examples/load_in_idyntree.py @@ -5,7 +5,7 @@ # Copyright 2022 Giulio Romualdi """ -Load a robot description, specified from the command line, in iDynTree. +Load a robot description selected from the command line in iDynTree. This example requires iDynTree, which can be installed by `conda install -c conda-forge idyntree`. diff --git a/examples/load_in_mujoco.py b/examples/load_in_mujoco.py index 61d54f2..fbdf33e 100644 --- a/examples/load_in_mujoco.py +++ b/examples/load_in_mujoco.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Show a robot description, specified from the command line, in MuJoCo. +Load a robot description selected from the command line in MuJoCo. This example requires MuJoCo, which is installed by `pip install mujoco`. """ diff --git a/examples/load_in_pinocchio.py b/examples/load_in_pinocchio.py index 36e50d5..090f813 100644 --- a/examples/load_in_pinocchio.py +++ b/examples/load_in_pinocchio.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Load a robot description, specified from the command line, in Pinocchio. +Load a robot description selected from the command line in Pinocchio. This example requires Pinocchio, installed by e.g. `conda install pinocchio`. """ diff --git a/examples/load_in_pybullet.py b/examples/load_in_pybullet.py index 7765e1f..1cbcf08 100644 --- a/examples/load_in_pybullet.py +++ b/examples/load_in_pybullet.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Load a robot description, specified from the command line, in PyBullet. +Load a robot description selected from the command line in PyBullet. This example requires PyBullet, which is installed by `pip install pybullet`. """ diff --git a/examples/load_in_robomeshcat.py b/examples/load_in_robomeshcat.py index c8bc0d1..1e88265 100644 --- a/examples/load_in_robomeshcat.py +++ b/examples/load_in_robomeshcat.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Load a robot description, specified from the command line, in RoboMeshCat. +Load a robot description selected from the command line in RoboMeshCat. This example uses RoboMeshCat: https://github.com/petrikvladimir/RoboMeshCat """ diff --git a/examples/load_in_yourdfpy.py b/examples/load_in_yourdfpy.py index cb71093..24defe9 100644 --- a/examples/load_in_yourdfpy.py +++ b/examples/load_in_yourdfpy.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Load a robot description, specified from the command line, using yourdfpy. +Load a robot description selected from the command line in yourdfpy. This example requires yourdfpy, which is installed by `pip install yourdfpy`. """ diff --git a/examples/show_in_candlewick.py b/examples/show_in_candlewick.py new file mode 100644 index 0000000..71177fa --- /dev/null +++ b/examples/show_in_candlewick.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2025 Inria + +""" +Show a robot description selected from the command line in Candlewick. + +This example requires Pinocchio, installed by e.g. `conda install pinocchio`, +and Candlewick: https://github.com/Simple-Robotics/candlewick. +""" + +import argparse + +try: + from candlewick.multibody import Visualizer, VisualizerConfig +except ImportError as import_error: + raise ImportError( + "Candlewick not found, " + "see https://github.com/Simple-Robotics/candlewick" + ) from import_error + +from robot_descriptions.loaders.pinocchio import load_robot_description + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("name", help="name of the robot description") + parser.add_argument("--width", help="window width in px", default=1600) + parser.add_argument("--height", help="window height in px", default=900) + args = parser.parse_args() + + try: + robot = load_robot_description(args.name) + except ModuleNotFoundError: + robot = load_robot_description(f"{args.name}_description") + + config = VisualizerConfig() + config.width = args.width + config.height = args.height + visualizer = Visualizer(config, robot.model, robot.visual_model) + while not visualizer.shouldExit: + visualizer.display(robot.q0) diff --git a/examples/show_in_meshcat.py b/examples/show_in_meshcat.py index 88f763f..6b8f656 100644 --- a/examples/show_in_meshcat.py +++ b/examples/show_in_meshcat.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Show a robot descriptions, specified from the command line, using MeshCat. +Show a robot description selected from the command line using MeshCat. This example is equivalent to `python -m robot_descriptions show_in_meshcat`. It requires Pinocchio, installed by e.g. `conda install pinocchio`, and diff --git a/examples/show_in_mujoco.py b/examples/show_in_mujoco.py index 6933696..1a1256b 100644 --- a/examples/show_in_mujoco.py +++ b/examples/show_in_mujoco.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Show a robot description, specified from the command line, using MuJoCo. +Show a robot description selected from the command line using MuJoCo. This example is equivalent to `python -m robot_descriptions show_in_mujoco`. It requires MuJoCo, which is installed by `pip install mujoco`, and the MuJoCo diff --git a/examples/show_in_pybullet.py b/examples/show_in_pybullet.py index 76b2c95..e6b045c 100644 --- a/examples/show_in_pybullet.py +++ b/examples/show_in_pybullet.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Show a robot description, specified from the command line, using PyBullet. +Show a robot description selected from the command line using PyBullet. This example is equivalent to `python -m robot_descriptions show_in_pybullet`. It requires PyBullet, which can be installed by `pip install pybullet`. diff --git a/examples/show_in_robomeshcat.py b/examples/show_in_robomeshcat.py index 91e29ae..47ca3c9 100644 --- a/examples/show_in_robomeshcat.py +++ b/examples/show_in_robomeshcat.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Load a robot description, specified from the command line, in RoboMeshCat. +Load a robot description selected from the command line in RoboMeshCat. This example uses RoboMeshCat: https://github.com/petrikvladimir/RoboMeshCat """ diff --git a/examples/show_in_yourdfpy.py b/examples/show_in_yourdfpy.py index 168efba..2d36d34 100644 --- a/examples/show_in_yourdfpy.py +++ b/examples/show_in_yourdfpy.py @@ -5,7 +5,7 @@ # Copyright 2022 Stéphane Caron """ -Show a robot description, specified from the command line, using yourdfpy. +Show a robot description selected from the command line in yourdfpy. This example is equivalent to `python -m robot_descriptions show_in_yourdfpy`. It requires `yourdfpy`, an optional dependency that can be installed by `pip