Skip to content

Commit

Permalink
examples: Show custom configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Oct 14, 2024
1 parent c4b915a commit e20e970
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 36 additions & 0 deletions examples/show_custom_configuration.py
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.

0 comments on commit e20e970

Please sign in to comment.