Skip to content

Commit

Permalink
tutorials: Add example of using meshcat visualizer (RobotLocomotion#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
EricCousineau-TRI authored Feb 5, 2020
1 parent 76bacc1 commit 2bf44a1
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tutorials/rendering_multibody_plant.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"* Adding a `MultibodyPlant` and `SceneGraph` to a diagram\n",
"* Adding two separate IIWAs to the `MultibodyPlant`\n",
"* Adding LCM visualization for Drake Visualizer\n",
"* Adding `meshcat` visualization\n",
"* Adding a camera with a VTK renderer\n",
"* Rendering color and label images (at zero configuration)\n",
"* Using `SceneGraphInspector` to query `SceneGraph` geometries\n",
Expand Down Expand Up @@ -66,6 +67,7 @@
"from pydrake.multibody.tree import BodyIndex\n",
"from pydrake.systems.analysis import Simulator\n",
"from pydrake.systems.framework import DiagramBuilder\n",
"from pydrake.systems.meshcat_visualizer import MeshcatVisualizer\n",
"from pydrake.systems.sensors import RgbdSensor"
]
},
Expand Down Expand Up @@ -236,7 +238,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add Drake Visualizer."
"## Add Drake Visualizer.\n",
"\n",
"You will need to have launched the `drake_visualizer` binary\n",
"before calling `simulator.Initialize(...)`."
]
},
{
Expand All @@ -248,6 +253,38 @@
"ConnectDrakeVisualizer(builder, scene_graph)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add and show `meshcat` Visualizer.\n",
"\n",
"This will show a `meshcat` widget inside of this notebook.\n",
"\n",
"**Note**: This currently does *not* work in a remote workflow (e.g.\n",
"Docker without appropriate port forwarding, Binder, Google Colab, etc.).\n",
"Please see [#12645](https://github.com/RobotLocomotion/drake/issues/12645)\n",
"for more details. If this does appear to work, then it is most likely due\n",
"to you running a local instance of the `meshcat` server.\n",
"\n",
"<!-- TODO(eric.cousineau): Move this to a separate visualization-specific\n",
"tutorial. -->"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"meshcat_vis = builder.AddSystem(\n",
" MeshcatVisualizer(scene_graph, zmq_url=\"new\", open_browser=False))\n",
"builder.Connect(\n",
" scene_graph.get_pose_bundle_output_port(),\n",
" meshcat_vis.get_input_port(0))\n",
"meshcat_vis.vis.jupyter_cell()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 2bf44a1

Please sign in to comment.