|
| 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 a robot description selected from the command line in Candlewick. |
| 9 | +
|
| 10 | +This example requires Pinocchio, installed by e.g. `conda install pinocchio`, |
| 11 | +and Candlewick: https://github.com/Simple-Robotics/candlewick. |
| 12 | +""" |
| 13 | + |
| 14 | +import argparse |
| 15 | + |
| 16 | +try: |
| 17 | + from candlewick.multibody import Visualizer, VisualizerConfig |
| 18 | +except ImportError as import_error: |
| 19 | + raise ImportError( |
| 20 | + "Candlewick not found, " |
| 21 | + "see https://github.com/Simple-Robotics/candlewick" |
| 22 | + ) from import_error |
| 23 | + |
| 24 | +from robot_descriptions.loaders.pinocchio import load_robot_description |
| 25 | + |
| 26 | +if __name__ == "__main__": |
| 27 | + parser = argparse.ArgumentParser(description=__doc__) |
| 28 | + parser.add_argument("name", help="name of the robot description") |
| 29 | + parser.add_argument("--width", help="window width in px", default=1600) |
| 30 | + parser.add_argument("--height", help="window height in px", default=900) |
| 31 | + args = parser.parse_args() |
| 32 | + |
| 33 | + try: |
| 34 | + robot = load_robot_description(args.name) |
| 35 | + except ModuleNotFoundError: |
| 36 | + robot = load_robot_description(f"{args.name}_description") |
| 37 | + |
| 38 | + config = VisualizerConfig() |
| 39 | + config.width = args.width |
| 40 | + config.height = args.height |
| 41 | + visualizer = Visualizer(config, robot.model, robot.visual_model) |
| 42 | + while not visualizer.shouldExit: |
| 43 | + visualizer.display(robot.q0) |
0 commit comments