Skip to content

Commit

Permalink
Add simple visualization example
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Sep 11, 2024
1 parent d1570c8 commit c4b915a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/show_in_meshcat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Inria

"""Load Upkie in Pinocchio and display its visual model in MeshCat."""

import argparse
import time

import pinocchio as pin
import upkie_description
from pinocchio.visualize import MeshcatVisualizer

if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--variant",
help="variant of the robot description to load",
)
args = parser.parse_args()

label = "robot"
if args.variant:
label = f"'{args.variant}' variant of the robot"
robot = upkie_description.load_in_pinocchio(
# NB: we add a free-flyer so that the torso mass is included
root_joint=pin.JointModelFreeFlyer(),
variant=args.variant,
)
robot.setVisualizer(MeshcatVisualizer())
robot.initViewer(open=True)
robot.loadViewerModel()
robot.display(robot.q0)

time.sleep(1.0) # wait long enough for MeshCat to fire up

0 comments on commit c4b915a

Please sign in to comment.