dair_pll.vis_utils
Utility functions for visualizing trajectories.
Visualization of Drake systems can be done with Drake’s VideoWriter. This allows for a relatively thin implementation of visualization for very complex geometries.
The main contents of this file are as follows:
A method to generate a dummy
DrakeSystemwhich simultaneously visualizes two trajectories of the same system.A method which takes a
DrakeSystemand corresponding trajectory, captures a visualization video, and outputs it as a numpy ndarray.
- dair_pll.vis_utils.generate_visualization_system(base_system, visualization_file, learned_system=None, base_system_color=Rgba(r=0.6, g=0.0, b=0.0, a=0.5), learned_system_color=Rgba(r=0.0, g=0.0, b=0.6, a=0.7))[source]
Generate a dummy
DrakeSystemfor visualizing comparisons between two trajectories ofbase_system.Does so by generating a new
DrakeSystemin which every model in the base system has a copy. Each illustration geometry element in these two copies is uniformly colored to be visually distinguishable.The copy of the base system can optionally be rendered in its learned geometry.
- Parameters:
base_system (
DrakeSystem) – System to be visualized.visualization_file (
str) – Output GIF filename for trajectory video.learned_system (
Optional[DrakeSystem]) – Optionally, the learned system so the predicted trajectory is rendered with the learned geometry.base_system_color (
Rgba) – Color to repaint every thing in base system.learned_system_color (
Rgba) – Color to repaint every thing in duplicated system.
- Return type:
- Returns:
New
DrakeSystemwith doubled state and repainted elements.
- dair_pll.vis_utils.visualize_trajectory(drake_system, x_trajectory, framerate=30)[source]
Visualizes trajectory of system.
Specifies a
frameratefor output video, though should be noted that this framerate is only approximately represented by homogeneous integer downsampling of the state trajectory. For example,if drake_system.dt == 1/60andframerate == 11, the true video framerate will be:max(round(60/11), 1) == 5.
- Parameters:
drake_system (
DrakeSystem) – System associated with provided trajectory.x_trajectory (
Tensor) – (T, drake_system.space.n_x) state trajectory.framerate (
int) – desired frames per second of output video.
- Return type:
- Returns:
(1, T, 3, H, W) ndarray video capture of trajectory with resolution H x W, which are set to 480x640 in
dair_pll.drake_utils. The true framerate, rounded to an integer.