'Render image at specific viewpoint

I'd like to render images in the Drake simulator to my hard disk (i.e. serialize PNGs or JPGs).

How can I:

  1. Set the camera viewing frame? For example, could I move the visualizer GUI around (controlling the camera) and save the camera extrinsics somewhere, then load it for rendering?

  2. After I get the camera extrinsics, my guess is I can use: https://drake.mit.edu/doxygen_cxx/classdrake_1_1geometry_1_1render_1_1_render_engine_vtk.html#a81e26b02c3a6d32b4187fc3f14261cbf

Is there a simple example of using that?



Solution 1:[1]

I have a simple example of posing the camera and grabbing the image in my manipulation course notes: https://manipulation.csail.mit.edu/pose.html#example1 . We don't have a good way of getting the camera pose from the visualizer camera viewpoint (I assume you are using MeshCat), but I agree it would be a nice feature to have.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Russ Tedrake