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

Add precompiled drake-visualizer to Bazel build #6259

Merged
merged 2 commits into from
Jun 12, 2017
Merged

Add precompiled drake-visualizer to Bazel build #6259

merged 2 commits into from
Jun 12, 2017

Conversation

jamiesnape
Copy link
Contributor

@jamiesnape jamiesnape commented Jun 6, 2017

Toward #3129. This will need a Mac CI update immediately before it is merged. It also may need to be coordinated with RobotLocomotion/director#508.


This change is Reviewable

@jamiesnape
Copy link
Contributor Author

+@mwoehlke-kitware for feature review.

@jamiesnape
Copy link
Contributor Author

@mwoehlke-kitware Could you review this? Very high priority.

@mwoehlke-kitware
Copy link
Contributor

:LGTM: after cursory review, however I cannot test, and am not sure I'm the best person to review


Reviewed 7 of 7 files at r1.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


tools/director.bzl, line 15 at r1 (raw file):

                 "sed is missing")

        result = repository_ctx.execute([

BTW, since we're using this now in multiple places, would it make sense to move it to a utility function?


tools/director.bzl, line 28 at r1 (raw file):

        distro = " ".join(distro)

        if distro == "Ubuntu 14.04":

Oh, goody... is this (unlike VTK) something I can turn off if I don't want it?


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

I'll take platform review and test it locally, though we should probably get one more volunteer to test locally.


Comments from Reviewable

@soonho-tri
Copy link
Member

I'll do test this on my local macs today.

@jwnimmer-tri
Copy link
Collaborator

Reviewed 7 of 7 files at r1.
Review status: all files reviewed at latest revision, 8 unresolved discussions.


WORKSPACE, line 262 at r1 (raw file):

    name = "drake_visualizer",
    local_path = __workspace_dir__ + "/build/install/bin/drake-visualizer",
)

BTW Probably this stanza (and its bzl file) should be removed in this PR? Or is that happening in a follow-up?

In whichever PR removes this stanza, the drake/examples/kuka_iiwa_arm/dev/monolithic_pick_and_place/README.md has a paragraph about it (though with no regression test) that should be updated.


drake/automotive/BUILD, line 439 at r1 (raw file):

        ":lcm-spy",
        ":steering_command_driver",
        "//tools:drake_visualizer",

The README.md in this directory has a caveat about soft_failure that now no longer applies, so that whole subsection should be removed.


tools/BUILD, line 28 at r1 (raw file):

    data = [
        "@director",
        "@vtk",

Probably the @director//:director filegroup should say data = ["@vtk"], instead of mentioning it here?


tools/director.bzl, line 55 at r1 (raw file):

director_repository = repository_rule(
    local = True,

Are you sure we need local = True here? (Maybe add a comment if so explaining why.) Over the past week, vtk.bzl has been really aggressive about re-downloading for reasons I couldn't understand -- and I think this might be it.

The only thing I can see that might need local = True would be the distro check, but I'm not sure that we need to handle that changing hermetically.


tools/drake_visualizer_apple.sh, line 4 at r1 (raw file):

export DYLD_LIBRARY_PATH="external/director/lib:$DYLD_LIBRARY_PATH"
export PYTHONPATH="external/director/lib/python2.7/dist-packages:/usr/local/opt/[email protected]/lib/python2.7/site-packages:$PYTHONPATH"

FYI So this is probably fine, but is repeating some @vtk implementation details within this file. Another approach would be to have our vtk.bzl unpacking rules offer a datafile with this path (or shell script to add it), and then inject that here via that indirection.


tools/drake_visualizer_linux.sh, line 3 at r1 (raw file):

#!/bin/bash

export LD_LIBRARY_PATH="external/director/lib:$LD_LIBRARY_PATH"

FYI If you want to be a bit safer with LD_LIBRARY_PATH modification, apparently the better syntax goes like torch/distro#228. I'm not sure that it matters when we're in a sandbox already, though.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

jamiesnape commented Jun 9, 2017

I'll do test this on my local macs today.

You may need to wait for an update of the drake-visualizer binary for Mac.

@jamiesnape
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 8 unresolved discussions.


tools/director.bzl, line 55 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Are you sure we need local = True here? (Maybe add a comment if so explaining why.) Over the past week, vtk.bzl has been really aggressive about re-downloading for reasons I couldn't understand -- and I think this might be it.

The only thing I can see that might need local = True would be the distro check, but I'm not sure that we need to handle that changing hermetically.

I think we need it for Mac. I will double check.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 8 unresolved discussions.


WORKSPACE, line 262 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

BTW Probably this stanza (and its bzl file) should be removed in this PR? Or is that happening in a follow-up?

In whichever PR removes this stanza, the drake/examples/kuka_iiwa_arm/dev/monolithic_pick_and_place/README.md has a paragraph about it (though with no regression test) that should be updated.

I was going to follow up, but I should probably do that here.


tools/director.bzl, line 28 at r1 (raw file):

Previously, mwoehlke-kitware (Matthew Woehlke) wrote…

Oh, goody... is this (unlike VTK) something I can turn off if I don't want it?

Not at present.


Comments from Reviewable

@mwoehlke-kitware
Copy link
Contributor

Review status: all files reviewed at latest revision, 8 unresolved discussions.


tools/drake_visualizer_linux.sh, line 3 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

FYI If you want to be a bit safer with LD_LIBRARY_PATH modification, apparently the better syntax goes like torch/distro#228. I'm not sure that it matters when we're in a sandbox already, though.

Indeed; I'd be in favor of that also:

export LD_LIBRARY_PATH="external/director/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):
Testing locally on Xenial, appears broken. I'll see if I can debug it.

jwnimmer@call-cc:~/tmp/jamiesnape/drake$ bazel run drake/automotive:demo -- --num_simple_car=1 --driving_command_gui_names=0 --num_trajectory_car=1
INFO: Found 1 target...
Target //drake/automotive:demo up-to-date:
  bazel-bin/drake/automotive/demo
INFO: Elapsed time: 0.234s, Critical Path: 0.00s

INFO: Running command line: bazel-bin/drake/automotive/demo '--num_simple_car=1' '--driving_command_gui_names=0' '--num_trajectory_car=1'
*** LCM logs will be in /home/jwnimmer/.cache/bazel/_bazel_jwnimmer/14d2e3dc00ee544c7d1fe9fb0ce2dd15/execroot/drake/bazel-out/clang-3.9-linux-opt/bin/drake/automotive/demo.runfiles/drake
[automotive_demo.py] drake_visualizer exited 127
external/director/bin/drake-visualizer: error while loading shared libraries: libvtkGUISupportQt-7.1.so.1: cannot open shared object file: No such file or directory
[automotive_demo.py] drake_visualizer failed to launch
ERROR: Non-zero return code '127' from command: Process exited with status 127.

Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 9 unresolved discussions.


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Testing locally on Xenial, appears broken. I'll see if I can debug it.

jwnimmer@call-cc:~/tmp/jamiesnape/drake$ bazel run drake/automotive:demo -- --num_simple_car=1 --driving_command_gui_names=0 --num_trajectory_car=1
INFO: Found 1 target...
Target //drake/automotive:demo up-to-date:
  bazel-bin/drake/automotive/demo
INFO: Elapsed time: 0.234s, Critical Path: 0.00s

INFO: Running command line: bazel-bin/drake/automotive/demo '--num_simple_car=1' '--driving_command_gui_names=0' '--num_trajectory_car=1'
*** LCM logs will be in /home/jwnimmer/.cache/bazel/_bazel_jwnimmer/14d2e3dc00ee544c7d1fe9fb0ce2dd15/execroot/drake/bazel-out/clang-3.9-linux-opt/bin/drake/automotive/demo.runfiles/drake
[automotive_demo.py] drake_visualizer exited 127
external/director/bin/drake-visualizer: error while loading shared libraries: libvtkGUISupportQt-7.1.so.1: cannot open shared object file: No such file or directory
[automotive_demo.py] drake_visualizer failed to launch
ERROR: Non-zero return code '127' from command: Process exited with status 127.

Is libvtkGUISupportQt-7.1.so.1 present anywhere in your sandbox (i.e., am are looking in the wrong place or is something to do with the extraction of the package wrong)?


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):

Previously, jamiesnape (Jamie Snape) wrote…

Is libvtkGUISupportQt-7.1.so.1 present anywhere in your sandbox (i.e., am are looking in the wrong place or is something to do with the extraction of the package wrong)?

The first fix was to export LD_LIBRARY_PATH="external/director/lib:external/vtk/lib:$LD_LIBRARY_PATH" in the launcher script, i.e., VTK was missing from LD_LIBRARY_PATH. Now I'm getting SIGFPE with no other output.


Comments from Reviewable

@soonho-tri
Copy link
Member

You may need to wait for an update of the drake-visualizer binary for Mac.

Sure. Please ping me here when it's ready.


Review status: all files reviewed at latest revision, 9 unresolved discussions.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 9 unresolved discussions.


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

The first fix was to export LD_LIBRARY_PATH="external/director/lib:external/vtk/lib:$LD_LIBRARY_PATH" in the launcher script, i.e., VTK was missing from LD_LIBRARY_PATH. Now I'm getting SIGFPE with no other output.

I probably need to fix the Python path too.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):

Previously, jamiesnape (Jamie Snape) wrote…

I probably need to fix the Python path too.

Indeed export PYTHONPATH="external/director/lib/python2.7/dist-packages:external/vtk/lib/python2.7/site-packages:$PYTHONPATH" get the main window up and running.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 9 unresolved discussions.


WORKSPACE, line 262 at r1 (raw file):

Previously, jamiesnape (Jamie Snape) wrote…

I was going to follow up, but I should probably do that here.

Do you want the file soft_failure.bzl removing as well?


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

WORKSPACE, line 262 at r1 (raw file):

Previously, jamiesnape (Jamie Snape) wrote…

Do you want the file soft_failure.bzl removing as well?

I think yes; git remembers.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Waiting on update of drake-visualizer binaries from @sankhesh.

@jamiesnape
Copy link
Contributor Author

Review status: 2 of 10 files reviewed at latest revision, 8 unresolved discussions.


a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Indeed export PYTHONPATH="external/director/lib/python2.7/dist-packages:external/vtk/lib/python2.7/site-packages:$PYTHONPATH" get the main window up and running.

Done.


WORKSPACE, line 262 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I think yes; git remembers.

Done. 🐘


drake/automotive/BUILD, line 439 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

The README.md in this directory has a caveat about soft_failure that now no longer applies, so that whole subsection should be removed.

Done.


tools/BUILD, line 28 at r1 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Probably the @director//:director filegroup should say data = ["@vtk"], instead of mentioning it here?

Done.


tools/director.bzl, line 55 at r1 (raw file):

Previously, jamiesnape (Jamie Snape) wrote…

I think we need it for Mac. I will double check.

Apparently not. Gone here and in VTK.


tools/drake_visualizer_linux.sh, line 3 at r1 (raw file):

Previously, mwoehlke-kitware (Matthew Woehlke) wrote…

Indeed; I'd be in favor of that also:

export LD_LIBRARY_PATH="external/director/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

Done. Also for DYLD_LIBRARY_PATH. You get PYTHONPATH as a bonus just to keep things neat.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

Reviewed 8 of 8 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

tools/drake_visualizer_linux.sh, line 4 at r2 (raw file):

export LD_LIBRARY_PATH="external/director/lib:external/vtk/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PYTHONPATH="external/director/lib/python2.7/dist-packages:external/vtk/lib/python2.7/site_packages${PYTHONPATH:+:$PYTHONPATH}"

The site_packages should be site-packages.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):
FYI On Xenial, when I close drake-visualizer I get:

*** Error in `external/director/bin/drake-visualizer': double free or corruption (!prev): 0x00000000035b7ae0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f48a166a7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7f48a1672e0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f48a167698c]
/lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0x9a)[0x7f48a162d36a]
external/vtk/lib/libvtkCommonSystem-7.1.so.1(+0x86b3)[0x7f489c0c76b3]

Valgrind identifies the culprit as:

==32722== Invalid read of size 8
==32722==    at 0xE5ADDF8: std::vector<vtkTimerLogEntry, std::allocator<vtkTimerLogEntry> >::~vector() (in /home/jwnimmer/.cache/bazel/_bazel_jwnimmer/14d2e3dc00ee544c7d1fe9fb0ce2dd15/external/vtk/lib/libvtkCommonSystem-7.1.so.1)
==32722==    by 0x8EF1369: __cxa_finalize (cxa_finalize.c:56)
==32722==    by 0xE5A76B2: ??? (in /home/jwnimmer/.cache/bazel/_bazel_jwnimmer/14d2e3dc00ee544c7d1fe9fb0ce2dd15/external/vtk/lib/libvtkCommonSystem-7.1.so.1)
==32722==    by 0x4010C16: _dl_fini (dl-fini.c:235)
==32722==    by 0x8EF0FF7: __run_exit_handlers (exit.c:82)
==32722==    by 0x8EF1044: exit (exit.c:104)
==32722==    by 0x8ED7836: (below main) (libc-start.c:325)
==32722==  Address 0x5e25feb0 is 16 bytes inside a block of size 5,600 free'd
==32722==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==32722==    by 0x8EF0FF7: __run_exit_handlers (exit.c:82)
==32722==    by 0x8EF1044: exit (exit.c:104)
==32722==    by 0x8ED7836: (below main) (libc-start.c:325)

Hello to our old friend, the static destruction order fiasco (probably).

I don't think that should block this PR, but is annoying and worth a follow-up issue.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

Review status: 9 of 10 files reviewed at latest revision, 3 unresolved discussions.


tools/drake_visualizer_linux.sh, line 4 at r2 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

The site_packages should be site-packages.

Done.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

Tested on Xenial. We should probably get ack's from Trusty and OS X testers as well.

:lgtm:


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

When testing, also run bazel test //drake/systems/sensors:rgbd_camera_test since I had to update VTK.

@SeanCurtis-TRI
Copy link
Contributor

Tested on Trusty. :LGTM:


Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@SeanCurtis-TRI
Copy link
Contributor

Double :lgtm: Drake visualizer runs, rgbd_camera_test passes on Trusty.


Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

@soonho-tri The new Mac packages are uploaded. Do a brew (re)install [email protected] first.

@jwnimmer-tri
Copy link
Collaborator

Reviewed 1 of 1 files at r4.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented Jun 9, 2017

Re-confirmed to work for me on Xenial (and the shutdown error is no longer happening to me, for whatever reason).


Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@soonho-tri
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


a discussion (no related file):
@jamiesnape , I've tested it on my iMac and a MacPro.

  1. bazel test //drake/systems/sensors:rgbd_camera_test works on both machines.

  2. I tried bazel run //drake/automotive:demo <options>. But it failed with the following error on both macs:

 RuntimeError: Timeout waiting for channel DRAKE_VIEWER_STATUS
ERROR: Non-zero return code '1' from command: Process exited with status 1.

Also, the symbolic link bazel-bin/external/drake_visualizer/drake-visualizer is broken. PTAL:

$ ls -al bazel-bin/external/drake_visualizer/drake-visualizer
lrwxr-xr-x  1 soonhok  wheel  139 Jun  6 10:32 bazel-bin/external/drake_visualizer/drake-visualizer -> /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drak

$ ls /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drake-distro/external/drake_visualizer/__success_drake-visualizer
ls: /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drake-distro/external/drake_visualizer/__success_drake-visualizer: No such file or directory

Comments from Reviewable

@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):

Previously, soonho-tri (Soonho Kong) wrote…

@jamiesnape , I've tested it on my iMac and a MacPro.

  1. bazel test //drake/systems/sensors:rgbd_camera_test works on both machines.

  2. I tried bazel run //drake/automotive:demo <options>. But it failed with the following error on both macs:

 RuntimeError: Timeout waiting for channel DRAKE_VIEWER_STATUS
ERROR: Non-zero return code '1' from command: Process exited with status 1.

Also, the symbolic link bazel-bin/external/drake_visualizer/drake-visualizer is broken. PTAL:

$ ls -al bazel-bin/external/drake_visualizer/drake-visualizer
lrwxr-xr-x  1 soonhok  wheel  139 Jun  6 10:32 bazel-bin/external/drake_visualizer/drake-visualizer -> /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drak

$ ls /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drake-distro/external/drake_visualizer/__success_drake-visualizer
ls: /private/var/tmp/_bazel_soonhok/51e1ef8bb59598000e1968965dd33f03/execroot/drake-distro/external/drake_visualizer/__success_drake-visualizer: No such file or directory

bazel-bin/external/drake_visualizer/drake-visualizer is what's on master, and removed by this PR? The external name is now @director.

Does bazel run //tools:drake_visualizer work?


Comments from Reviewable

@soonho-tri
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


a discussion (no related file):

Does bazel run //tools:drake_visualizer work?

No.

  1. It seems that qt and qt@4 conflicts each other? FYI, both of them are listed in the installation instrauctions: http://drake.mit.edu/mac.html .
objc[58147]: Class QCocoaMenuLoader is implemented in both /usr/local/Cellar/qt/5.9.0/plugins/platforms/libqcocoa.dylib (0x108819848) and /usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui (0x10fa11f90). One of the two will be used. Which one is undefined.

In the end, I also have:

AttributeError: 'vtkCommonCorePython.vtkObject' object has no attribute 'GetInteractor'

Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

jamiesnape commented Jun 9, 2017

I guess we need to split the instructions into Bazel and CMake at the very least. For now, uninstall qt@4 and vtk5. I will try to work out if there is a way they can coexist.

@soonho-tri
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


a discussion (no related file):

Previously, soonho-tri (Soonho Kong) wrote…

Does bazel run //tools:drake_visualizer work?

No.

  1. It seems that qt and qt@4 conflicts each other? FYI, both of them are listed in the installation instrauctions: http://drake.mit.edu/mac.html .
objc[58147]: Class QCocoaMenuLoader is implemented in both /usr/local/Cellar/qt/5.9.0/plugins/platforms/libqcocoa.dylib (0x108819848) and /usr/local/opt/qt@4/lib/QtGui.framework/Versions/4/QtGui (0x10fa11f90). One of the two will be used. Which one is undefined.

In the end, I also have:

AttributeError: 'vtkCommonCorePython.vtkObject' object has no attribute 'GetInteractor'

Running brew uninstall pyqt@4 qwt-qt4 vtk5 fixes my problem.


Comments from Reviewable

@soonho-tri
Copy link
Member

Review status: all files reviewed at latest revision, 1 unresolved discussion.


a discussion (no related file):

Previously, soonho-tri (Soonho Kong) wrote…

Running brew uninstall pyqt@4 qwt-qt4 vtk5 fixes my problem.

:lgtm:


Comments from Reviewable

@jamiesnape
Copy link
Contributor Author

We will update CI on Monday morning and then merge this. Once RobotLocomotion/director#508 goes in, life will get easier as everything can use Qt 5 and VTK 8.

@soonho-tri
Copy link
Member

BTW, I think it's a good practice not to destructive-update the master branch of RobotLocomotion/director. While I was testing this PR, I got:

$ brew update
error: Failed to merge in the changes.
Patch failed at 0001 Add [email protected] formula
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

A user has to untap and retap to resolve the issue (or go to the repository and do git reset --hard).

@jamiesnape
Copy link
Contributor Author

CI has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants