Search code examples
drake

colab notebook in Chapter 3 of Underactuated Robotics is not working


The colab notebooks are not working even I used pip install:

!pip install drake
import importlib
import sys
from urllib.request import urlretrieve

# Install drake (and underactuated).
if 'google.colab' in sys.modules and importlib.util.find_spec('underactuated') is None:
    urlretrieve(f"http://underactuated.csail.mit.edu/setup/setup_underactuated_colab.py",
                "setup_underactuated_colab.py")
    from setup_underactuated_colab import setup_underactuated
    setup_underactuated(underactuated_sha='e089af19ca62590e131ad295b51d2c950a5ecc10', drake_version='0.27.0', drake_build='release')

server_args = []
if 'google.colab' in sys.modules:
  server_args = ['--ngrok_http_tunnel']
# Start two meshcat server instances to use for the remainder of this notebook.
from meshcat.servers.zmqserver import start_zmq_server_as_subprocess
proc_planar, zmq_url_planar, web_url_planar = start_zmq_server_as_subprocess(server_args=server_args)
proc, zmq_url, web_url = start_zmq_server_as_subprocess(server_args=server_args)

import numpy as np
from ipywidgets import FloatSlider, ToggleButton
from IPython.display import display, SVG
import pydot

import pydrake.all
from pydrake.all import (
    DiagramBuilder, LinearQuadraticRegulator, Saturation, SceneGraph, Simulator, 
    WrapToSystem, AddMultibodyPlantSceneGraph, Parser
)
from pydrake.examples.acrobot import AcrobotPlant, AcrobotGeometry
from pydrake.systems.jupyter_widgets import WidgetSystem
from pydrake.common.containers import namedview
from underactuated import FindResource
from underactuated.jupyter import running_as_notebook



The drake version 0.27.0 that you've specified will be ignored.  We've switched to a `pip install` workflow for colab, and are transitioning to that.
Cloning into '/opt/underactuated'...

HEAD is now at e089af1 setup colab uses pip install drake

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.11.1+cu111 requires torch==1.10.0, but you have torch 1.8.1 which is incompatible.
torchtext 0.11.0 requires torch==1.10.0, but you have torch 1.8.1 which is incompatible.
torchaudio 0.10.0+cu111 requires torch==1.10.0, but you have torch 1.8.1 which is incompatible.
albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible.


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/x/xorg-server/xvfb_1.19.6-1ubuntu4.9_amd64.deb  404  Not Found [IP: 91.189.88.142 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-3-7cd256303862> in <module>()
      8                 "setup_underactuated_colab.py")
      9     from setup_underactuated_colab import setup_underactuated
---> 10     setup_underactuated(underactuated_sha='e089af19ca62590e131ad295b51d2c950a5ecc10', drake_version='0.27.0', drake_build='release')
     11 
     12 server_args = []

1 frames
/content/setup_underactuated_colab.py in run(cmd, **kwargs)
     94         if cp.stderr:
     95             print(cp.stderr)
---> 96         assert cp.returncode == 0, cp
     97 
     98     # Clone the repo (if necessary).

AssertionError: CompletedProcess(args=['apt', 'install', 'xvfb'], returncode=100, stdout='Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following NEW packages will be installed:\n  xvfb\n0 upgraded, 1 newly installed, 0 to remove and 37 not upgraded.\nNeed to get 784 kB of archives.\nAfter this operation, 2,270 kB of additional disk space will be used.\nIgn:1 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.9\nErr:1 http://security.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.9\n  404  Not Found [IP: 91.189.88.142 80]\n', stderr='\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\nE: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/x/xorg-server/xvfb_1.19.6-1ubuntu4.9_amd64.deb  404  Not Found [IP: 91.189.88.142 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n')

Solution

  • Good news. As of this morning, you no longer have to use the setup_underactuated, and can install with pip, e.g. via

    !pip install underactuated==2022.01.03
    

    at the top of the notebook.

    Unforunately, ngrok seems to have changed their support for unregistered connections, so you might still have to overcome this: https://github.com/RussTedrake/underactuated/issues/454