This package provides a Julia interface to the Drake Visualizer, part of the Drake project and built on top of Director, a highly customizable 3D interface for robotics visualization and interaction.
DrakeVisualizer.jl uses BinDeps.jl to try to automatically install an appropriate copy of Director for you. On Ubuntu (14.04 and higher) and macOS, this package will attempt to download the pre-built binaries of Director from http://people.csail.mit.edu/patmarion/software/director/. On other Linux platforms, it will compile Director from source. If you would like to force Director to build from source on any platform, just set the environment variable DIRECTOR_BUILD_FROM_SOURCE=1
.
On Ubuntu (14.04 and up) and macOS, all of Director's dependencies will automatically be installed using BinDeps.jl. On other platforms, you'll need to provide them yourself. The required packages are available via apt-get
as:
libqt4-dev
libqt4-opengl-dev
python-numpy
python-dev
If you have issues with the Director application itself (like your geometry not showing up), you may have an out-of-date version of the Director binaries. To clear the downloaded binaries, you can run:
julia> DrakeVisualizer.delete_director_binaries()
After which you will need to re-download the binaries with:
julia> Pkg.build("DrakeVisualizer")
DrakeVisualizer
uses LCM for communication, and LCM uses UDP under the hood. Very large LCM messages (like those created when loading a robot with lots of mesh geometries) can result in UDP packets being dropped, which will result in you not seeing anything in the visualizer. If that happens to you, you'll need to follow the instructions in this comment. Edit /etc/sysctl.conf
and add:
net.core.rmem_max=2097152
net.core.rmem_default=2097152
You can launch the viewer application with
julia> DrakeVisualizer.new_window()
which is just a convenience wrapper around a call to the drake-visualizer
executable, included in the director
binaries or source installation.
This package makes use of GeometryTypes.jl to represent robot geometries and CoordinateTransformations.jl to represent spatial transformations. Check out demo.ipynb for some examples of usage.
Geometric primitives from GeometryTypes.jl can be visualized directly:
using DrakeVisualizer
using GeometryTypes
box = HyperRectangle(Vec(0.,0,0), Vec(1.,1,1))
model = Visualizer(box)
sphere = HyperSphere(Point(0., 0, 0), 1.0)
model = Visualizer(sphere)
Once a Visualizer model has been created, it can be rendered at arbitrary positions and orientations:
using CoordinateTransformations
settransform!(model, Translation(1.0, 0.0, 0.0))
DrakeVisualizer can also render mesh data:
using MeshIO
using FileIO
cat = load(joinpath(Pkg.dir("GeometryTypes"), "test", "data", "cat.obj"))
Visualizer(cat)
And it can even generate 3D contours from functions:
# First, we'll define our function:
f = x -> sum(sin, 5 * x)
# Then we pick a region of interest in which to sample the function.
# This region starts at (-1, -1, -1) and extends to (1, 1, 1):
lower_bound = Vec(-1.,-1,-1)
upper_bound = Vec(1., 1, 1)
# contour_mesh constructs a mesh representing an approximation of
# the surface in 3D space for which f(x) = 0
mesh = contour_mesh(f, lower_bound, upper_bound)
Visualizer(mesh)
For more visualizations, including moving and rotating visualized elements, and visualizing the level sets of functions, check out demo.ipynb.