| name | pywayne-visualization-pangolin-utils |
| description | 3D visualization toolkit wrapping Pangolin viewer for real-time display of point clouds, trajectories, cameras, planes, chessboards, and images. Use when visualizing sensor data (IMU, SLAM, tracking), robot states, or any 3D data with camera poses and trajectories. Supports dual-image display, step mode for debugging, and main camera following. |
Pywayne Visualization Pangolin Utils
pywayne.visualization.pangolin_utils.PangolinViewer provides a Python interface to Pangolin 3D visualization library.
Quick Start
from pywayne.visualization.pangolin_utils import PangolinViewer, Colors
import numpy as np
viewer = PangolinViewer(800, 600)
viewer.init()
while viewer.should_not_quit():
viewer.show(delay_time_in_s=0.03)
viewer.join()
Colors
Use Colors class for common colors:
Colors.RED
Colors.GREEN
Colors.BLUE
Colors.YELLOW
Colors.CYAN
Colors.MAGENTA
Colors.WHITE
Colors.BLACK
Colors.ORANGE
Colors.PURPLE
Colors.GRAY
Colors.BROWN
Colors.PINK
Core Control
viewer.run()
viewer.close()
viewer.join()
viewer.reset()
viewer.init()
viewer.show(0.03)
viewer.should_not_quit()
viewer.clear_all_visual_elements()
Point Cloud
viewer.clear_all_points()
viewer.add_points(points, point_size=4.0)
viewer.add_points_with_colors(points, colors, point_size=4.0)
viewer.add_points_with_color_name(points, color_name="red", point_size=4.0)
Trajectory
viewer.clear_all_trajectories()
viewer.add_trajectory_quat(
positions,
orientations,
color=Colors.GREEN,
quat_format="wxyz",
line_width=2.0,
show_cameras=True,
camera_size=0.05
)
viewer.add_trajectory_se3(
poses_se3,
color=Colors.GREEN,
line_width=2.0,
show_cameras=False
)
Camera
viewer.clear_all_cameras()
viewer.set_main_camera(camera_id)
cam_id = viewer.add_camera_quat(
position,
orientation,
color=Colors.YELLOW,
quat_format="wxyz",
scale=0.1,
line_width=1.0
)
cam_id = viewer.add_camera_se3(
pose_se3,
color=Colors.YELLOW,
scale=0.1,
line_width=1.0
)
Plane
viewer.clear_all_planes()
viewer.add_plane(
vertices,
color=Colors.GRAY,
alpha=0.5,
label="plane"
)
viewer.add_plane_normal_center(
normal,
center,
size,
color=Colors.GRAY,
alpha=0.5,
label="plane"
)
viewer.add_plane_from_Twp(
Twp,
size=1.0,
color=Colors.GREEN,
alpha=0.5,
label="plane"
)
Chessboard
Useful for camera calibration and spatial reference:
viewer.add_chessboard(rows=8, cols=8, cell_size=0.1)
viewer.add_chessboard(
rows=9, cols=6, cell_size=0.025,
origin=np.array([0, 0, 0]),
normal=np.array([1, 0, 0]),
color1=Colors.RED,
color2=Colors.YELLOW,
alpha=0.8
)
viewer.add_chessboard_from_Twp(
rows=9, cols=6, cell_size=0.025,
Twp=pose_matrix,
color1=Colors.BLACK,
color2=Colors.WHITE,
alpha=0.8,
label="calib"
)
Line
viewer.clear_all_lines()
viewer.add_line(
start_point,
end_point,
color=Colors.WHITE,
line_width=1.0
)
Image Display
viewer.set_img_resolution(width, height)
viewer.add_image_1(img_array)
viewer.add_image_1(image_path="path.jpg")
viewer.add_image_2(img_array)
viewer.add_image_2(image_path="path.jpg")
Step Mode (Debugging)
viewer.is_step_mode_active()
viewer.wait_for_step()
Important Notes
- Dependencies: Requires Pangolin library (auto-downloaded via
gettool)
- Data types: All position/point inputs must be
float32
- Quaternion formats: Support
wxyz and xyzw formats
- SE3 poses: Support (4, 4) or (4, 7) matrix formats
- Automatic cleaning:
clear_all_visual_elements() clears points, trajectories, cameras, planes, lines
- Camera following: Use
set_main_camera() with camera ID from add_camera_*() return