pydrake.systems.planar_scenegraph_visualizer

pydrake.systems.planar_scenegraph_visualizer.ConnectPlanarSceneGraphVisualizer(builder, scene_graph, output_port=None, **kwargs)

Creates an instance of PlanarSceneGraphVisualizer, adds it to the diagram, and wires the scene_graph pose bundle output port to the input port of the visualizer. Provides an interface comparable to DrakeVisualizer.AddToBuilder.

Parameters
  • builder – The diagram builder used to construct the Diagram.

  • scene_graph – The SceneGraph in builder containing the geometry to be visualized.

  • output_port – (optional) If not None, then output_port will be connected to the visualizer input port instead of the scene_graph. get_query_output_port(). This is required, for instance, when the SceneGraph is inside a Diagram, and we must connect the exposed port to the visualizer instead of the original SceneGraph port.

  • PlanarSceneGraphVisualizer (Additional kwargs are passed through to the) –

  • constructor.

Returns

The newly created PlanarSceneGraphVisualizer object.

class pydrake.systems.planar_scenegraph_visualizer.PlanarSceneGraphVisualizer(scene_graph, draw_period=None, T_VW=array([[1., 0., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), xlim=[- 1.0, 1], ylim=[- 1, 1], facecolor=[1, 1, 1], use_random_colors=False, substitute_collocated_mesh_files=True, ax=None, show=None)

Bases: pydrake.systems.pyplot_visualizer.PyPlotVisualizer

Given a SceneGraph and a view plane, provides a view of the robot by projecting all geometry onto the view plane.

This is intended to be used for robots that operate in the plane, but should render any robot approximately correctly. It has the following caveats: - z-ordering of objects is done based on the object centroid, which is not perfect for non-planar scenes. - Object geometry is projected onto the view plane, then a chull is taken, and finally that chull is drawn as a patch. Nonconvex geometry will thus be drawn incorrectly, and geometry with many vertices will slow down the visualizer.

Specifics on view setup:

T_VW specifies the 3x4 view projection matrix. For planar orthographic projection, use: [ <x axis select> x_axis_shift

<y axis select> y_axis_shift

0, 0, 0, 1] % homogenizer

e.g.

[ 1 0 0 0.5

0 1 0 0 0 0 0 1].

would give a top-down view (i.e squashing the z axis), and would shift things in the x axis positively by 0.5.

T_VW can be any valid view projection matrix. If the bottom row is [0, 0, 0, 1], the view projection will be an orthographic projection.

xlim and ylim don’t technically provide extra functionality, but it’s easier to keep handling scaling with xlim, ylim, and view plane selection and maybe offsetting with the projection matrix.

__init__(scene_graph, draw_period=None, T_VW=array([[1., 0., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), xlim=[- 1.0, 1], ylim=[- 1, 1], facecolor=[1, 1, 1], use_random_colors=False, substitute_collocated_mesh_files=True, ax=None, show=None)
Parameters
  • scene_graph – A SceneGraph object.

  • draw_period – The rate at which this class publishes to the visualizer. When None, a suitable default will be used.

  • T_VW – The view projection matrix from world to view coordinates.

  • xlim – View limit into the scene.

  • ylim – View limit into the scene.

  • facecolor – Passed through to figure() and sets background color. Both color name strings and RGB triplets are allowed. Defaults to white.

  • use_random_colors – If set to True, will render each body with a different color. (Multiple visual elements on the same body will be the same color.)

  • substitute_collocated_mesh_files – If True, then a mesh file specified with an unsupported filename extension may be replaced by a file of the same base name in the same directory, but with a supported filename extension.

  • ax – If supplied, the visualizer will draw onto those axes instead of creating a new set of axes. The visualizer will still change the view range and figure size of those axes.

  • show – Opens a window during initialization / publish iff True. Default is None, which implies show=True unless matplotlib.get_backend() is ‘template’.

draw(context)

Overrides base with the implementation.

static frame_name(frame_id, inspector)

Produces a visualizer name for a frame.

get_geometry_query_input_port()