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

Fix panda3d installation and example #1183

Merged
merged 4 commits into from
Apr 25, 2020
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
1 change: 1 addition & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ IF(BUILD_PYTHON_INTERFACE)
base_visualizer.py
gepetto_visualizer.py
meshcat_visualizer.py
panda3d_visualizer.py
)

FOREACH(python ${PYTHON_VISUALIZE_FILES})
Expand Down
1 change: 1 addition & 0 deletions bindings/python/pinocchio/visualize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .base_visualizer import BaseVisualizer
from .gepetto_visualizer import GepettoVisualizer
from .meshcat_visualizer import MeshcatVisualizer
from .panda3d_visualizer import Panda3dVisualizer
8 changes: 3 additions & 5 deletions bindings/python/pinocchio/visualize/panda3d_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
except ImportError:
WITH_HPP_FCL_BINDINGS = False

from panda3d_viewer import Viewer as Panda3dViewer, ViewerClosedError

__all__ = ['Panda3dVisualizer', 'Panda3dViewer', 'ViewerClosedError']


class Panda3dVisualizer(BaseVisualizer):
"""
A Pinocchio display using panda3d engine.
Expand All @@ -28,6 +23,7 @@ def initViewer(self, viewer=None, load_model=False): # pylint: disable=arguments
self.display_collisions = False
self.viewer = viewer

from panda3d_viewer import Viewer as Panda3dViewer
if viewer is None:
self.viewer = Panda3dViewer(window_title="python-pinocchio")

Expand Down Expand Up @@ -121,3 +117,5 @@ def displayVisuals(self, visibility):
"""Set whether to display visual objects or not."""
self.viewer.show_group(self.visual_group, visibility)
self.display_visuals = visibility

__all__ = ['Panda3dVisualizer']
Copy link
Member Author

@cmastalli cmastalli Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcarpent removing Panda3dViewer from __all__ breaks the examples written in Pinocchio.

I am not familiar with the code, but it seems we need to put back the previous __all___ definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmastalli @ikalevatykh The changes are relevant, as panda3d_viewer may not be available. Then, you cannot import the lib, otherwise, you will get an error.

Copy link
Contributor

@ikalevatykh ikalevatykh Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcarpent Original variant was also OK as panda3d_visualize was not imported in visualize. _import_. Just to clarify

4 changes: 2 additions & 2 deletions examples/panda3d-viewer-play.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# pip install --user panda3d_viewer

import pinocchio as pin
pin.switchToNumpyMatrix()
import numpy as np
import sys

Expand All @@ -18,6 +17,7 @@
from pinocchio.visualize.panda3d_visualizer import Panda3dVisualizer, ViewerClosedError

talos = loadTalos()
nq = talos.model.nq
talos.setVisualizer(Panda3dVisualizer())
talos.initViewer()
talos.loadViewerModel(group_name='talos', color=(1, 1, 1, 1))
Expand All @@ -27,7 +27,7 @@
def play_sample_trajectory():
update_rate = 60
cycle_time = 3
traj = np.repeat(talos.q0, cycle_time * update_rate, axis=1)
traj = np.repeat(talos.q0.reshape((nq,1)), cycle_time * update_rate, axis=1)
beta = np.linspace(0, 1, traj.shape[1])
traj[[2, 9, 10, 11, 22, 15, 16, 17, 30]] = (
0.39 + 0.685 * np.cos(beta),
Expand Down