From e20e970d75900bdbcbddfc97bd45cf2073145733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Caron?= Date: Mon, 14 Oct 2024 14:30:47 +0200 Subject: [PATCH] examples: Show custom configuration --- CHANGELOG.md | 7 +++- examples/show_custom_configuration.py | 36 +++++++++++++++++++ ...shcat.py => show_neutral_configuration.py} | 0 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 examples/show_custom_configuration.py rename examples/{show_in_meshcat.py => show_neutral_configuration.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6761bd..128bd91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,12 @@ All notable changes to this project will be documented in this file. ### Added - Bazel: Export all URDF variants in `upkie_description` filegroup -- Example to visualize wheel frames while both legs move around +- examples: Show robot in a custom configuration +- examples: Visualize wheel frames while both legs move around + +### Changed + +- examples: Rename example to "show in neutral configuration" ### Fixed diff --git a/examples/show_custom_configuration.py b/examples/show_custom_configuration.py new file mode 100644 index 0000000..f1260d4 --- /dev/null +++ b/examples/show_custom_configuration.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Inria + +""" +Display the center of mass and visual model of the robot. +""" + +import argparse +import time + +import numpy as np +import upkie_description +from pinocchio.visualize import MeshcatVisualizer + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("left_hip", help="Left hip joint angle in [rad]") + parser.add_argument("left_knee", help="Left knee joint angle in [rad]") + parser.add_argument("left_wheel", help="Left wheel joint angle in [rad]") + parser.add_argument("right_hip", help="Right hip joint angle in [rad]") + parser.add_argument("right_knee", help="Right knee joint angle in [rad]") + parser.add_argument("right_wheel", help="Right wheel joint angle in [rad]") + args = parser.parse_args() + + robot = upkie_description.load_in_pinocchio(root_joint=None) + q = np.array([float(pair[1]) for pair in args._get_kwargs()]) + + robot.setVisualizer(MeshcatVisualizer()) + robot.initViewer(open=True) + robot.loadViewerModel() + robot.display(q) + + time.sleep(10.0) # avoid terminating too fast diff --git a/examples/show_in_meshcat.py b/examples/show_neutral_configuration.py similarity index 100% rename from examples/show_in_meshcat.py rename to examples/show_neutral_configuration.py