Gepetto / gepetto-viewer

Graphical Interface for Pinocchio and HPP.
BSD 2-Clause "Simplified" License
44 stars 30 forks source link

gepetto-viewer and Jupyter Notebook #179

Closed IoannisDadiotis closed 3 years ago

IoannisDadiotis commented 3 years ago

Hi,

I have installed gepetto-viewer and I can successfully use it as follows:

As a result I can see the motion generated by the solvers.

However, when trying to run examples of crocoddyl in jupyter notebooks (while gepetto-gui is running on a terminal) gepetto-viewer is not working (like if the notebook cannot find the running gepetto-gui). E.g. when running the bipedal_walking.ipynb I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-8f57f921a9fe> in <module>()
     37 
     38 # Using the meshcat displayer, you could enable gepetto viewer for nicer view
---> 39 display = crocoddyl.GepettoDisplay(talos_legs, 4, 4, frameNames=[rightFoot, leftFoot])
     40 # display = crocoddyl.MeshcatDisplay(talos_legs, 4, 4, False)
     41 ddp.setCallbacks([crocoddyl.CallbackLogger(),

/opt/openrobots/lib/python2.7/site-packages/crocoddyl/__init__.pyc in __init__(self, robot, rate, freq, cameraTF, floor, frameNames, visibility)
     98             self.frameTrajColor[fr] = list(np.hstack([np.random.choice(range(256), size=3) / 256., 1.]))
     99 
--> 100         self._addRobot()
    101         self._setBackground()
    102         if cameraTF is not None:

/opt/openrobots/lib/python2.7/site-packages/crocoddyl/__init__.pyc in _addRobot(self)
    237         # Spawn robot model
    238         self.robot.initViewer(windowName="crocoddyl", loadModel=False)
--> 239         self.robot.loadViewerModel(rootNodeName="robot")
    240 
    241     def _setBackground(self):

/opt/openrobots/lib/python2.7/site-packages/pinocchio/robot_wrapper.pyc in loadViewerModel(self, *args, **kwargs)
    292     def loadViewerModel(self, *args, **kwargs):
    293         """Create the scene displaying the robot meshes in gepetto-viewer"""
--> 294         self.viz.loadViewerModel(*args, **kwargs)
    295 
    296     @deprecated("Use loadViewerModel")

/opt/openrobots/lib/python2.7/site-packages/pinocchio/visualize/gepetto_visualizer.pyc in loadViewerModel(self, rootNodeName)
    135 
    136         # Start a new "scene" in this window, named "world", with just a floor.
--> 137         gui = self.viewer.gui
    138         self.viewerRootNodeName = self.sceneName + "/" + rootNodeName
    139 

AttributeError: 'GepettoVisualizer' object has no attribute 'viewer'

I have installed jupyter from Anaconda for python 2.7 in my Ubuntu 18.04. I have installed gepetto-viewer with robotpkg-py27-qt5-gepetto-viewer-corba.

Any idea how to fix this?

nim65s commented 3 years ago

Hi,

Anaconda provides a separate python interpreter, and its binary packages are usually not compatible with those made for the python interpreter of the system.

Please choose between:

  1. use only anaconda and its packages
  2. don't use it at all.

I'd personally go for 2.

Also, I strongly encourage you to move to python 3, you'll get a more up-to-date jupyter.

IoannisDadiotis commented 3 years ago

Does going for 1. means installing gepetto-viewer binaries with conda in practice?

If yes, I am reporting some info. I tried conda install gepetto-viewer gepetto-viewer-corba -c conda-forge but the process takes strangely a lot of time and is not completed (I waited around 10-15 min and then I cancelled the process). The terminal output during this time is: Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json):

nim65s commented 3 years ago

Sorry, I wrote 1 when I meant 2. For conda, yes, gepetto-viewer, gepetto-viewer-corba, and crocoddyl etc. should be installable by conda, but I personally never tried it :/

IoannisDadiotis commented 3 years ago

ok, thanks for the clarification.