toddlerbot.visualization package

Submodules

toddlerbot.visualization.vis_depth_comparison module

Depth Comparison Script

This script compares depth maps and point clouds between ground truth and prediction results.

Expected folder structure:

results/
├── depth_blake_0529_fs_480x640_object/  # Ground truth folder
│   ├── 10_depth.npy                     # Depth map files
│   ├── 10_pcd.ply                       # Point cloud files
│   └── ...
└── depth_blake_0529_fs_96x128_object/   # Prediction folder
    ├── 10_depth.npy                     # Depth map files
    ├── 10_pcd.ply                       # Point cloud files
    └── ...
Filename format:
  • Depth maps: {frame_num}_depth.npy

  • Point clouds: {frame_num}_pcd.ply

where frame_num is an integer (e.g., 10, 20, 30, etc.)

Usage examples:

# Compare frame 10 between two depth result folders
python test_compare_depth.py --gt-folder results/depth_blake_0529_fs_480x640_object --pred-folder results/depth_blake_0529_fs_96x128_object --frame 10

# Compare with depth threshold (only evaluate depths <= 2000cm)
python test_compare_depth.py --gt-folder results/gt_folder --pred-folder results/pred_folder --frame 10 --zmax 2000
toddlerbot.visualization.vis_depth_comparison.compare_depth_maps_npy(depth_path_1, depth_path_2, mask_invalid=True, zmax=None)
toddlerbot.visualization.vis_depth_comparison.compute_pointcloud_metrics(source, target)
toddlerbot.visualization.vis_depth_comparison.create_bev_overlap(gt_path, pred_path, voxel=0.01, res=0.01, overhang_threshold=None, opacity=0.5)
toddlerbot.visualization.vis_depth_comparison.generate_bev_image(points, color, bounds, resolution, overhang_threshold=None)
toddlerbot.visualization.vis_depth_comparison.load_point_cloud(path, voxel_size=None)

Load and optionally downsample a point cloud.

toddlerbot.visualization.vis_depth_comparison.run_icp(source_pcd, target_pcd, max_dist=0.05)

toddlerbot.visualization.vis_plot module

Plotting functions for robot data visualization.

toddlerbot.visualization.vis_plot.plot_ang_vel_frequency(time_seq_sim: List[float], time_seq_real: List[float], ang_vel_sim: ndarray[Any, dtype[float32]], ang_vel_real: ndarray[Any, dtype[float32]], save_path: str, x_label: str = 'Frequency (Hz)', y_label: str = 'Magnitude', file_name: str = 'ang_vel_freq_comparison', file_suffix: str = '', title_list: List[str] = [], set_ylim: bool = False, line_suffix: List[str] = ['_sim', '_real'], save_config: bool = True, blocking: bool = True)

Plot frequency domain comparison of angular velocity between simulation and real data.

Parameters:
  • time_seq_sim – Time sequence for simulation data

  • time_seq_real – Time sequence for real data

  • ang_vel_sim – Angular velocity simulation data with shape (n_samples, 3) for [x, y, z]

  • ang_vel_real – Angular velocity real data with shape (n_samples, 3) for [x, y, z]

  • save_path – Path to save the plot

  • x_label – X-axis label

  • y_label – Y-axis label

  • file_name – Name of the output file

  • file_suffix – Suffix for the output file

  • title_list – List of titles for each subplot

  • set_ylim – Whether to set y-axis limits

  • line_suffix – Suffixes for legend labels

  • save_config – Whether to save configuration

  • blocking – Whether to show plot in blocking mode

toddlerbot.visualization.vis_plot.plot_ankle_mapping(joint_limits: Dict[str, List[float]], ankle_ik: Callable[[...], List[float]], save_path: str, file_name: str = 'ankle_mapping')
toddlerbot.visualization.vis_plot.plot_bar_graph(y: Any, x: Any = None, fig_size: Tuple[int, int] = (10, 6), legend_labels: List[str] = [], bar_colors: List[str] = [], title: str = '', x_label: str = '', y_label: str = '', save_config: bool = False, save_path: str = '', file_name: str = '', file_suffix: str = '', blocking: bool = True, ax: Any = None, bar_width: float = 0.25, joint_labels: List[str] = [], number_font_size: int = 0)
toddlerbot.visualization.vis_plot.plot_footsteps(foot_pos_list: ndarray[Any, dtype[float32]], support_leg_list: List[int], foot_size: Tuple[float, float], foot_to_com_y: float, fig_size: Tuple[int, int] = (10, 6), title: str = '', x_label: str = '', y_label: str = '', save_config: bool = True, save_path: str = '', file_name: str = '', file_suffix: str = '', blocking: bool = True, ax: Any = None) Callable[[], None]
toddlerbot.visualization.vis_plot.plot_joint_drive_direction(time_seq_dict: Dict[str, List[float]], joint_data_dict: Dict[str, List[float]], binary_data_dict: Dict[str, List[float]], save_path: str, x_label: str = 'Time (s)', y_label: str = 'Position (rad)', file_name: str = 'pos_vs_drive', file_suffix: str = '', title_list: List[str] = [], set_ylim: bool = False, save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_joint_tracking(time_seq_dict: Dict[str, List[float]], time_seq_ref_dict: Dict[str, List[float]], joint_data_dict: Dict[str, List[float]], joint_data_ref_dict: Dict[str, List[float]], save_path: str, joint_limits: Dict[str, List[float]] | None = None, x_label: str = 'Time (s)', y_label: str = 'Position (rad)', file_name: str = 'motor_pos_tracking', file_suffix: str = '', title_list: List[str] = [], set_ylim: bool = False, line_suffix: List[str] = ['_obs', '_act'], save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_joint_tracking_frequency(time_seq_dict: Dict[str, List[float]], time_seq_ref_dict: Dict[str, List[float]], joint_data_dict: Dict[str, List[float]], joint_data_ref_dict: Dict[str, List[float]], save_path: str, x_label: str = 'Frequency (Hz)', y_label: str = 'Magnitude', file_name: str = 'motor_freq_tracking', file_suffix: str = '', title_list: List[str] = [], set_ylim: bool = False, line_suffix: List[str] = ['_obs', '_ref'], save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_joint_tracking_single(time_seq_dict: Dict[str, List[float]], joint_data_dict: Dict[str, List[float]], save_path: str, x_label: str = 'Time (s)', y_label: str = 'Velocity (rad/s)', file_name: str = 'motor_vel_tracking', file_suffix: str = '', title_list: List[str] = [], set_ylim: bool = False, save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_line_graph(y: Any, x: Any = None, fig_size: Tuple[int, int] = (10, 6), legend_labels: List[str] = [], line_styles: List[str] = [], line_colors: List[str] = [], title: str = '', x_label: str = '', y_label: str = '', save_config: bool = False, save_path: str = '', file_name: str = '', file_suffix: str = '', blocking: bool = True, ax: Any = None, checkpoint_period: List[int] = [])
toddlerbot.visualization.vis_plot.plot_loop_time(loop_time_list: List[float], save_path: str, file_name: str = 'loop_time', save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_motor_vel_tor_mapping(motor_vel_list: List[float], motor_tor_list: List[float], save_path: str, file_name: str = 'motor_vel_tor_mapping', save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_one_footstep(ax: Axes, center: ndarray[Any, dtype[float32]], size: Tuple[float, float], angle: float, side: int)
toddlerbot.visualization.vis_plot.plot_path_tracking(time_obs_list: List[float], pos_obs_list: List[ndarray[Any, dtype[float32]]], euler_obs_list: List[ndarray[Any, dtype[float32]]], control_inputs_dict: Dict[str, List[float]], save_path: str, file_name: str = 'path_tracking', save_config: bool = True, blocking: bool = True)

Plots the observed path (pos_obs_list) and the integrated path of walk commands.

toddlerbot.visualization.vis_plot.plot_scatter_graph(y: ndarray[Any, dtype[float32]], x: ndarray[Any, dtype[float32]], colors: ndarray[Any, dtype[float32]] | str, fig_size: Tuple[int, int] = (10, 6), title: str = '', x_label: str = '', y_label: str = '', legend_label: str = '', save_config: bool = False, save_path: str = '', file_name: str = '', file_suffix: str = '', blocking: bool = True, ax: Any = None)
toddlerbot.visualization.vis_plot.plot_sim2real_gap_bar(rmse_dict: Dict[str, float], rmse_label: str, save_path: str, title: str = 'Root Mean Squared Error by Joint', x_label: str = 'Joints', y_label: str = 'Root Mean Squared Error', file_name: str = 'sim2real_gap', file_suffix: str = '', save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_sim2real_gap_line(time_sim_list: List[float], time_real_list: List[float], data_sim: ndarray[Any, dtype[float32]], data_real: ndarray[Any, dtype[float32]], save_path: str, title: str = 'Euler Angles', x_label: str = 'Time (s)', y_label: str = 'Euler Angles (rad)', axis_names: List[str] = ['roll', 'pitch', 'yaw'], file_name: str = 'euler_gap', file_suffix: str = '', save_config: bool = True, blocking: bool = True)
toddlerbot.visualization.vis_plot.plot_teleop_dataset(action_data: ndarray[Any, dtype[float32]], episode_ends: ndarray, save_path: str, file_name: str, file_suffix: str = '')
toddlerbot.visualization.vis_plot.plot_waist_mapping(joint_limits: Dict[str, List[float]], waist_ik: Callable[[...], List[float]], save_path: str, file_name: str = 'waist_mapping')

toddlerbot.visualization.vis_utils module

Visualization utilities and helper functions.

toddlerbot.visualization.vis_utils.is_x11_available()

Check if the X11 server is available on the system.

Returns:

True if X11 is available, False otherwise.

Return type:

bool

toddlerbot.visualization.vis_utils.load_and_run_visualization(config_path: str)

Loads a configuration from a pickle file and executes a specified visualization function.

Parameters:

config_path (str) – The file path to the pickle configuration file.

Raises:

FileNotFoundError – If the configuration file does not exist or is not a pickle file.

The configuration file must contain a dictionary with the keys: - “function”: A string specifying the full path of the function to be executed. - “parameters”: A dictionary of parameters to be passed to the function.

toddlerbot.visualization.vis_utils.log_plot_config(func)
toddlerbot.visualization.vis_utils.make_vis_function(func: Callable[[...], Any], ax: Any = None, title: str = '', x_label: str = '', y_label: str = '', save_path: str = '', file_name: str = '', file_suffix: str = '')

Executes a visualization function with specified parameters and optional configuration saving.

Parameters:
  • func (Callable[..., Any]) – The visualization function to execute.

  • ax (Any, optional) – The axes object for the plot. Defaults to None.

  • title (str, optional) – The title of the plot. Defaults to an empty string.

  • x_label (str, optional) – The label for the x-axis. Defaults to an empty string.

  • y_label (str, optional) – The label for the y-axis. Defaults to an empty string.

  • save_config (bool, optional) – Whether to save the configuration. Defaults to False.

  • save_path (str, optional) – The directory path to save the configuration. Defaults to an empty string.

  • file_name (str, optional) – The name of the file to save the configuration. Defaults to an empty string.

  • file_suffix (str, optional) – The suffix for the saved file. Defaults to an empty string.

  • blocking (bool, optional) – Whether the function call should be blocking. Defaults to True.

Module contents

Visualization and plotting utilities for ToddlerBot data analysis.

This package provides tools and utilities for visualizing robot data, simulation results, and analysis outputs, including:

  • Real-time plotting of sensor data and robot states

  • Depth estimation visualization and comparison tools

  • Performance metrics and training progress visualization

  • Robot trajectory and motion visualization

  • Sensor calibration and system identification plots

  • General-purpose plotting utilities with consistent styling

The visualization tools support both interactive plotting for real-time monitoring and static plot generation for reports and publications, with customizable styling and export options.