RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.25k stars 1.25k forks source link

`drake_visualizer` cannot find `pydrake` for resolving package paths #7861

Closed rdeits closed 6 years ago

rdeits commented 6 years ago

Observed while running the Valkyrie simulation. drake_visualizer (installed by Drake) fails with:

INFO: Running command line: bazel-bin/tools/drake_visualizer
Traceback (most recent call last):
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/lcmUtils.py", line 119, in handleMessage
    callback(msg)
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 344, in onViewerLoadRobot
    self.addLinksFromLCM(msg)
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 368, in addLinksFromLCM
    self.addLink(Link(link), link.robot_num, link.name)
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 291, in __init__
    self.geometry.extend(Geometry.createGeometry(link.name + ' geometry data', g))
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 264, in createGeometry
    polyDataList, visInfo = Geometry.createPolyDataFromFiles(geom)
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 196, in createPolyDataFromFiles
    filename = Geometry.resolvePackageFilename(geom.string_data)
  File "/home/rdeits/.cache/bazel/_bazel_rdeits/e8708faf339a91021110cca2d500ef13/execroot/drake/bazel-out/clang-4.0-linux-opt/bin/tools/drake_visualizer.runfiles/drake/external/drake_visualizer/lib/python2.7/dist-packages/director/drakevisualizer.py", line 185, in resolvePackageFilename
    import pydrake
ImportError: No module named pydrake

The result is that the visualizer doesn't find any of the Val meshes and thus can't visualize the robot.

I can reproduce this by building //... and running bazel-bin/tools/drake_visualizer and bazel-bin/examples/valkyrie/valkyrie_simulation. Running drake_visualizer with bazel run does not appear to make a difference.

EricCousineau-TRI commented 6 years ago

Hm... Not sure why this is happening.

@jamiesnape Any ideas on this? Is this related to any pre-packaged drake_visualizer updates?

jamiesnape commented 6 years ago

I have not actually updated the packages yet, so no.

EricCousineau-TRI commented 6 years ago

Alright, I am working on reproducing this locally, will update in this comment once I've finished building off of master.

EDIT 1: I can import pydrake if I install from master (8ee580c). My steps:

$ cd drake
$ git log -n1 --oneline
8ee580c Merge pull request #7815 from osrf/ign-cosmetic-fixups
$ mkdir build_install
$ bazel run //:install -- ~+/build_install
$ ./build_install/bin/drake-visualizer
# In drake-visualizer, F8 to bring up Console.
>>> import pydrake; pydrake.__file__
'/home/eacousineau/proj/tri/repo/branches/drake/master/drake/build_install/lib/python2.7/site-packages/pydrake/__init__.pyc'

I am on Ubuntu 16.04.

~@rdeits Are you on Mac?~ EDIT 2: Actually, it does not work from Bazel (but it does work from Bazel install).

$ bazel build //tools:drake_visualizer
$ ./bazel-bin/tools/drake_visualizer
>>> import pydrake
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named pydrake

Will see if I can diagnose.

Also fails: bazel run //tools:drake_visualizer

EDIT 3: Ah, just seems like we need a rename in drake_visualizer. When inspecting paths from import sys; print("\n".join(sys.path)):

${runfiles}/drake/external/drake_visualizer/lib/python2.7/site-packages
${runfiles}/drake/external/drake_visualizer/lib/python2.7/dist-packages
${runfiles}/drake/drake/bindings
${runfiles}/drake/drake/lcmtypes
${runfiles}/drake/external/drake_visualizer/lib/python2.7/dist-packages
${runfiles}/drake/external/lcmtypes_bot2_core/lcmtypes
${runfiles}/drake/external/lcmtypes_robotlocomotion/lcmtypes
${runfiles}/drake/external/optitrack_driver/lcmtypes
${runfiles}/drake/external/vtk/lib/python2.7/site-packages
${runfiles}/drake/external
...
${runfiles}/drake

Looks like we just need to remove drake from there.

Will look into submitting a PR; I will see if we can use the py_env_runner.py hack to avoid needing to do all of this.

EricCousineau-TRI commented 6 years ago

@rdeits Just to check, do you still get an error if you use bazel run //:install, or if you use CMake?

rdeits commented 6 years ago

Thanks @EricCousineau-TRI ! I will try with //:install and report back.

rdeits commented 6 years ago

After //:install, the installed drake-visualizer does find pydrake successfully, but then fails to find the valkyrie meshes (even though I am now running from a checkout named "drake"):

failed to resolve filename, unknown package: package://valkyrie/urdf/model/meshes/pelvis/pelvis.dae
warning, cannot find file: package://valkyrie/urdf/model/meshes/pelvis/pelvis.dae
Traceback (most recent call last):
  File "/home/rdeits/locomotion/drake/install/lib/python2.7/dist-packages/director/lcmUtils.py", line 119, in handleMessage
    callback(msg)
  File "/home/rdeits/locomotion/drake/install/lib/python2.7/dist-packages/director/drakevisualizer.py", line 344, in onViewerLoadRobot
    self.addLinksFromLCM(msg)
  File "/home/rdeits/locomotion/drake/install/lib/python2.7/dist-packages/director/drakevisualizer.py", line 368, in addLinksFromLCM
    self.addLink(Link(link), link.robot_num, link.name)
  File "/home/rdeits/locomotion/drake/install/lib/python2.7/dist-packages/director/drakevisualizer.py", line 291, in __init__
    self.geometry.extend(Geometry.createGeometry(link.name + ' geometry data', g))
  File "/home/rdeits/locomotion/drake/install/lib/python2.7/dist-packages/director/drakevisualizer.py", line 264, in createGeometry
    polyDataList, visInfo = Geometry.createPolyDataFromFiles(geom)
ValueError: need more than 0 values to unpack
EricCousineau-TRI commented 6 years ago

Sorry for your troubles! Is this related to #7855? Or does this seem like another problem?

rdeits commented 6 years ago

Unrelated--I've already renamed my checkout to drake 😉

EricCousineau-TRI commented 6 years ago

Sorry for the late follow-up, but it seems like the package path issue should be fixed by https://github.com/RobotLocomotion/drake/pull/7774 My assumption is that this may land within the next few business days. Do you have a workaround for this, or is it blocking your work?

(When installed, it looks for ${install}/share/drake/drake/examples/atlas/urdf/atlas_minimal_contact.urdf, but the file exists at ${install}/share/drake/examples/atlas/urdf/atlas_minimal_contact.urdf.)

rdeits commented 6 years ago

Ok, makes sense, thanks. I can work around it for now.

EricCousineau-TRI commented 6 years ago

This should be fixed once the two PRs are merged:

rdeits commented 6 years ago

Thank you!