Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed outdated Panda3D examples #2087

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions examples/panda3d-viewer-play.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# This examples shows how to load and move a robot in panda3d_viewer.
# Note: this feature requires panda3d_viewer to be installed, this can be done using
# pip install --user panda3d_viewer
# pip install panda3d_viewer


import pinocchio as pin
import numpy as np
import sys

import sys
import numpy as np
from os.path import dirname, join, abspath

# add path to the example-robot-data package
# Add path to the example-robot-data package
path = join(dirname(dirname(abspath(__file__))), 'models', 'example-robot-data', 'python')
sys.path.append(path)
from example_robot_data import loadTalos
from example_robot_data.robots_loader import TalosLoader

# import visualizer
from panda3d_viewer import ViewerClosedError
from pinocchio.visualize.panda3d_visualizer import Panda3dVisualizer

talos = loadTalos()
# talos is a RobotWrapper object
talos = TalosLoader().robot
# Attach talos to the viewer scene
talos.setVisualizer(Panda3dVisualizer())
talos.initViewer()
talos.loadViewerModel(group_name='talos', color=(1, 1, 1, 1))
Expand All @@ -42,7 +43,7 @@ def play_sample_trajectory():
)

while True:
talos.play(traj, 1. / update_rate)
talos.play(traj.T, 1. / update_rate)
traj = np.flip(traj, 1)


Expand Down
28 changes: 14 additions & 14 deletions examples/panda3d-viewer.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# This examples shows how to load several robots in panda3d_viewer.
# Note: this feature requires panda3d_viewer to be installed, this can be done using
# pip install --user panda3d_viewer
# pip install panda3d_viewer

import pinocchio as pin
import sys

from os.path import dirname, join, abspath

# add path to the example-robot-data package
# Add path to the example-robot-data package
path = join(dirname(dirname(abspath(__file__))), 'models', 'example-robot-data', 'python')
sys.path.append(path)
from example_robot_data import loadTalos, loadRomeo, loadICub, loadTiago
from example_robot_data import loadSolo, loadHyQ, loadHector
from example_robot_data.robots_loader import TalosLoader, RomeoLoader, ICubLoader, TiagoLoader
from example_robot_data.robots_loader import Solo8Loader, HyQLoader, HectorLoader

# import visualizer
from panda3d_viewer import Viewer
from pinocchio.visualize.panda3d_visualizer import Panda3dVisualizer

# open a GUI window
# Open a Panda3D GUI window
viewer = Viewer(window_title='python-pinocchio')

loaders = (loadTalos, loadRomeo, loadICub, loadTiago, loadSolo, loadHyQ,
loadHector)
# These RobotLoader classes are defined in example_robot_data
loaders = (TalosLoader, RomeoLoader, ICubLoader, TiagoLoader,
Solo8Loader, HyQLoader, HectorLoader)

for i, load in enumerate(loaders):
robot = load()
for i, loader in enumerate(loaders):
# The robot is loaded as a RobotWrapper object
robot = loader().robot
# Attach the robot to the viewer scene
robot.setVisualizer(Panda3dVisualizer())
robot.initViewer(viewer=viewer) # attach to a viewer's scene
robot.initViewer(viewer=viewer)
robot.loadViewerModel(group_name=robot.model.name)

q = robot.q0[:]
q[1] = 3 - i
if load is loadRomeo:
if loader is RomeoLoader:
q[2] = 0.87

robot.display(q)
Expand Down
Loading