panda3d-viewer-play.py
Go to the documentation of this file.
1 # This examples shows how to load and move a robot in panda3d_viewer.
2 # Note: this feature requires panda3d_viewer to be installed, this can be done using
3 # pip install panda3d_viewer
4 # ruff: noqa: E402
5 
6 
7 import sys
8 from pathlib import Path
9 
10 import numpy as np
11 
12 # Add path to the example-robot-data package from git submodule.
13 # If you have a proper install version, there is no need for this sys.path thing
14 path = Path(__file__).parent.parent / "models" / "example-robot-data" / "python"
15 sys.path.append(str(path))
16 from example_robot_data.robots_loader import TalosLoader
17 from panda3d_viewer import ViewerClosedError
18 from pinocchio.visualize.panda3d_visualizer import Panda3dVisualizer
19 
20 # talos is a RobotWrapper object
21 talos = TalosLoader().robot
22 # Attach talos to the viewer scene
23 talos.setVisualizer(Panda3dVisualizer())
24 talos.initViewer()
25 talos.loadViewerModel(group_name="talos", color=(1, 1, 1, 1))
26 
27 
28 # Play a sample trajectory in a loop
30  update_rate = 60
31  cycle_time = 3
32  traj = np.repeat(talos.q0.reshape((-1, 1)), cycle_time * update_rate, axis=1)
33  beta = np.linspace(0, 1, traj.shape[1])
34  traj[[2, 9, 10, 11, 22, 15, 16, 17, 30]] = (
35  0.39 + 0.685 * np.cos(beta),
36  -beta,
37  2.0 * beta,
38  -beta,
39  0.1 + beta * 1.56,
40  -beta,
41  2.0 * beta,
42  -beta,
43  -0.1 - beta * 1.56,
44  )
45 
46  while True:
47  talos.play(traj.T, 1.0 / update_rate)
48  traj = np.flip(traj, 1)
49 
50 
51 try:
53 except ViewerClosedError:
54  # an exception will be thrown when the window is closed
55  pass
example_robot_data.robots_loader
Definition: robots_loader.py:1
panda3d-viewer-play.play_sample_trajectory
def play_sample_trajectory()
Definition: panda3d-viewer-play.py:29
example_robot_data.robots_loader.TalosLoader
Definition: robots_loader.py:265
pinocchio.visualize.panda3d_visualizer
Definition: panda3d_visualizer.py:1
pinocchio.visualize.panda3d_visualizer.Panda3dVisualizer
Definition: panda3d_visualizer.py:17


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:12