Skip to content

Renderer API

API reference for SoRoMoX visualization and rendering backends.

Start with the Rendering overview to compare output and choose a backend. Camera, color, base, ground-plane, multi-robot, and recording options are documented under Shared Configuration.

Shared Renderer Contract

All renderers inherit from BaseSoftRobotRenderer, which provides cached forward kinematics, backbone sampling, color resolution, and a common interface for individual and batched robot configurations.

BaseSoftRobotRenderer (abstract base)
├── MatplotlibRenderer         # Generic 2D and 3D plots
├── Open3DRenderer             # Interactive 3D visualization
├── ViserRenderer              # Browser-based interactive 3D visualization
├── OpenCVPlanarRenderer       # Fast planar rendering
└── OpenCVPlanarHSARenderer    # Planar HSA-specific rendering
API Shared behavior Availability
BaseSoftRobotRenderer Backbone sampling, cached forward kinematics, batched layouts, color resolution, and the common rendering interface All renderers
Robot base fixed_base_pose mounts fixed robots; floating renderers follow the base coordinates in each runtime configuration All renderers
Base plate config.geometry.base_plate_style, base_plate_radius_scale and base_plate_thickness configure the mount Open3D and Viser; Matplotlib draws a filled disk in 3D or a transverse marker in 2D
Ground plane config.scene.ground configures a world floor or base-aligned planes, including colors, size, grid and opacity Open3D and Viser, with backend approximations

Cross-Section Geometry

Open3D and Viser evaluate robot.cross_section_geometry(q, s) along the backbone and support circular, elliptical, and rectangular sections with constant or abscissa-varying dimensions.

backbone_style Representation Resolution controls
"swept" Surfaces lofted from ordered material-frame contours; modern Open3D joins matching link ends with smooth normals and retains caps at cross-section discontinuities num_points is the longitudinal station count; cross_section_resolution is the transverse contour resolution
"discrete" Independent spheres, boxes, or ellipsoids aligned with the local material frame num_points is the marker count; cross_section_resolution is ignored

Swept rendering assigns at least two stations to every positive-length link; zero-length articulated-chain entries do not produce surface geometry. Additional swept geometry families can be supported in both backends with register_cross_section_contour(...).

soromox.rendering.cross_sections

Renderer-neutral cross-section contours and swept-mesh construction.

CrossSection dataclass
CrossSection(geometry: int, dimensions: NDArray[float64])

A cross-section family and its dimensions at one backbone position.

The contour is represented in the robot material frame. Its first coordinate is longitudinal and therefore zero; the remaining coordinates lie in the material-frame yz plane. The contour is implicitly closed, so the first point is not repeated at the end.

__post_init__
__post_init__() -> None

Normalize the descriptor without imposing geometry-specific dimensions.

contour
contour(resolution: int) -> NDArray[float64]

Return the ordered material-frame contour for this section.

discrete_marker
discrete_marker() -> DiscreteCrossSectionMarker

Return the shared 3D marker representation for discrete rendering.

DiscreteCrossSectionMarker dataclass
DiscreteCrossSectionMarker(primitive: Literal['sphere', 'box', 'ellipsoid'], scale_xyz: NDArray[float64], align_with_material_frame: bool)

Backend-neutral 3D proxy used for one discrete backbone station.

The local primitive axes are ordered as material-frame (y, z, x). The third scale gives a discrete marker finite longitudinal depth; it is not a swept cross-section thickness.

__post_init__
__post_init__() -> None

Validate and freeze the marker scale.

CrossSectionSweepLayout dataclass
CrossSectionSweepLayout(abscissae: NDArray[float64], segment_starts: NDArray[int64], segment_ends: NDArray[int64])

Backbone stations and link-local index ranges for a swept surface.

Internal link boundaries occur twice in abscissae: once just inside the outgoing link and once just inside the incoming link. This lets each side carry its own cross-section family and material frame without lofting one link directly into the next.

edge_caps
edge_caps() -> dict[int, tuple[bool, bool]]

Return start- and end-cap flags for every link-local surface edge.

Returns:

Type Description
dict[int, tuple[bool, bool]]

Mapping from surface-edge indices to (cap_start, cap_end).

dict[int, tuple[bool, bool]]

Zero-length links have empty station ranges and therefore contribute

dict[int, tuple[bool, bool]]

no edges. The first positive-length link is open at its base; every

dict[int, tuple[bool, bool]]

later positive-length link is capped at both sides of the preceding

dict[int, tuple[bool, bool]]

interface.

cross_section_sweep_layout
cross_section_sweep_layout(segment_lengths: Iterable[float], num_points: int) -> CrossSectionSweepLayout

Distribute swept-surface stations across links with explicit interfaces.

num_points remains the total number of stations. Each positive-length link receives at least a base and tip station; zero-length articulated-chain entries receive an empty station range. Internal boundary stations are moved by one float32 ULP into their owning link. The offset survives JAX's default float32 conversion while remaining negligible at rendering scale.

register_cross_section_contour
register_cross_section_contour(geometry: int, builder: ContourBuilder, *, replace: bool = False) -> None

Register a contour builder for an additional cross-section family.

A builder receives the geometry-specific dimension array and requested contour resolution. It must return exactly resolution ordered points with shape (resolution, 3) in the material-frame yz plane.

evaluate_cross_sections
evaluate_cross_sections(robot: SoftRobot, q: Any, abscissae: Iterable[float]) -> tuple[CrossSection, ...]

Evaluate cross-section descriptors with one compiled vectorized call.

loft_cross_sections
loft_cross_sections(p0: NDArray[float64], p1: NDArray[float64], frame0: NDArray[float64], frame1: NDArray[float64], section0: CrossSection, section1: CrossSection, resolution: int, *, cap_start: bool = False, cap_end: bool = False) -> tuple[NDArray[float64], NDArray[int32]]

Connect two material-frame contours into one swept surface segment.

loft_cross_section_contours
loft_cross_section_contours(p0: NDArray[float64], p1: NDArray[float64], frame0: NDArray[float64], frame1: NDArray[float64], contour0: NDArray[float64], contour1: NDArray[float64], *, cap_start: bool = False, cap_end: bool = False) -> tuple[NDArray[float64], NDArray[int32]]

Connect two prepared material-frame contours into a swept segment.

Actuator and Helper Geometry

For SoftRobot systems, the rendering layer automatically adapts supported installed actuators and passive elements into semantic geometry when render_actuators=True. The adapter returns one or more ActuatorVisualLayer objects with points shaped (num_actuators_in_layer, num_points, dim). It is also available directly as soromox.rendering.actuator_visual_layers(...).

Specialized or third-party robots may override this default by exposing actuator_visual_layers(q, s_points, *, actuator_inputs=None).

For batches and trajectories, robots may additionally provide actuator_visual_layers_batched(...) or actuator_visual_layers_trajectory(...). The base renderer uses these hooks when available and otherwise falls back to the generic adapter or the single-configuration custom hook.

Open3D and Viser also accept helper spheres through static_spheres_positions, static_spheres_radii, and static_spheres_colors. Their sequence renderers additionally support the corresponding dynamic_spheres_* arguments.

Base Class

soromox.rendering.base.BaseSoftRobotRenderer

BaseSoftRobotRenderer(robot: SoftRobot, config: RendererConfig | None = None)

Bases: ABC


              flowchart TD
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

              

              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

Abstract base class for soft robot visualization backends.

Provides cached forward kinematics and a common interface for rendering soft robots across different backends (Matplotlib, Open3D, OpenCV).

Subclasses must implement
  • render_frame: Render single configuration to RGB image array
  • render_sequence: Render animated sequence
  • show: Display a single frame interactively
Subclasses may override
  • is_3d: Default uses robot.is_planar
  • _extract_positions: Extract xyz/xy from FK poses

Attributes:

Name Type Description
robot SoftRobot

SoftRobot system object with forward_kinematics method

width

Image width in pixels

height

Image height in pixels

num_points

Number of points for discretizing backbone curve

background_color

RGB tuple for background color (0-1 range)

color_config

Shared color configuration for renderers

L_max

Total length of the robot backbone

base_pose

Robot base pose coordinates. Planar robots use [theta, x, y]; spatial robots use scalar-last quaternion pose [qx, qy, qz, qw, x, y, z].

base_transform

Homogeneous base transform. Shape (3, 3) for planar robots and (4, 4) for spatial robots.

show_ground_plane

Whether supported backends render a ground reference

Initialize the renderer with a robot and visualization parameters.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared scene, camera, color, geometry and output defaults.

None
robot SoftRobot

Robot system with forward_kinematics method and length property

required

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

is_3d property

is_3d: bool

Return True for 3D rendering, False for planar rendering.

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

render_frame abstractmethod

render_frame(q: Array) -> ndarray

Render single configuration to RGB image array.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
ndarray

RGB image as numpy array of shape (height, width, 3), dtype uint8

render_sequence abstractmethod

render_sequence(ts: Array, q_ts: Array, playback_speed: float = 1.0, record_path: str | None = None, **kwargs: Any) -> None

Render animated sequence to video file.

Default implementation uses animate_cv2. Subclasses can override for native playback (e.g., Open3D interactive viewer).

Parameters:

Name Type Description Default
ts Array

Time stamps array of shape (T,)

required
q_ts Array

Configurations array of shape (T, DOF)

required
playback_speed float

Speed up factor for the video (playback)

1.0
record_path str | None

Path to save video file (required for default impl)

None

show abstractmethod

show(q: Array, **kwargs) -> None

Display single frame interactively (blocking).

Default implementation uses matplotlib. Subclasses can override for native viewers (e.g., Open3D window).

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.

Matplotlib Renderer

MatplotlibRenderer provides static figures, notebook-friendly inspection, slider-based playback, and ordinary animations for planar and spatial robots. Spatial configurations use a 3D axes view controlled by CameraConfig. Figures use a white background and standard Matplotlib axes and grid. Scene backgrounds, ground planes, backdrops, lighting, materials and effects are ignored. Robot colors, geometry, camera direction and output settings apply.

soromox.rendering.matplotlib_renderer.MatplotlibRenderer

MatplotlibRenderer(robot: SoftRobot, config: RendererConfig | None = None, base_offsets: Array | None = None)

Bases: BaseSoftRobotRenderer


              flowchart TD
              soromox.rendering.matplotlib_renderer.MatplotlibRenderer[MatplotlibRenderer]
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

                              soromox.rendering.base.BaseSoftRobotRenderer --> soromox.rendering.matplotlib_renderer.MatplotlibRenderer
                


              click soromox.rendering.matplotlib_renderer.MatplotlibRenderer href "" "soromox.rendering.matplotlib_renderer.MatplotlibRenderer"
              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

Matplotlib visualization for any continuum soft robot.

Supports both 2D (planar) and 3D robots, with FuncAnimation and slider modes. The dimensionality is auto-detected from the robot's forward kinematics output. Figures use a white background and standard Matplotlib axes. Scene appearance presets are ignored; camera, robot colors, geometry and output settings apply. Bases use a filled disk in 3D or a transverse marker in 2D, independently of the mesh mount style selected for Open3D and Viser.

Example
renderer = MatplotlibRenderer(robot)
renderer.show(q)
renderer.animate(ts, q_ts, mode="slider")

Initialize Matplotlib renderer.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared camera, color, geometry and output defaults. Scene appearance is ignored in favor of a white plotting background.

None
robot SoftRobot

Robot system with forward_kinematics method

required
base_offsets Array | None

Optional explicit base offsets for batched layouts

None

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

is_3d property

is_3d: bool

Return True for 3D rendering, False for planar rendering.

render_frame

render_frame(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None) -> ndarray

Render configuration(s) to an RGB image array.

Parameters:

Name Type Description Default
q Array

Robot configuration array. Shape (DOF,) for a single robot or (N, DOF) for batched rendering.

required
base_offsets Array | None

Optional explicit base offsets of shape (N, 2) or (N, 3) for batched layouts. When provided for a single robot, accepts (dim,) or (1, dim).

None
color_config RendererColorConfig | None

Shared renderer color configuration.

None
camera_config CameraConfig | None

Camera configuration. Matplotlib uses its field of view and the direction from position to look-at for 3D plots.

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None

Returns:

Name Type Description
img ndarray

RGB image of shape (height, width, 3), dtype uint8.

show

show(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None) -> None

Display a single frame interactively (supports batched inputs).

Parameters:

Name Type Description Default
q Array

Robot configuration array. Shape (DOF,) or (N, DOF).

required
base_offsets Array | None

Optional explicit base offsets for batched layouts (N, ⅔) or (1, dim) for single robot.

None
color_config RendererColorConfig | None

Shared renderer color configuration.

None
camera_config CameraConfig | None

Camera configuration. Matplotlib uses its field of view and the direction from position to look-at for 3D plots.

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None

Returns:

Type Description
None

None

animate

animate(ts: Array, q_ts: Array, interval: int = 50, mode: str = 'slider', show: bool = True, playback_speed: float = 1.0, record_path: str | None = None, video_config: VideoEncodingConfig | None = None, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None) -> AnimateReturn

Interactive matplotlib animation with slider or auto-play.

Parameters:

Name Type Description Default
ts Array

Time stamps array of shape (T,)

required
q_ts Array

Configurations array of shape (T, DOF) or (N, T, DOF)

required
interval int

Frame interval in ms (for animation mode)

50
mode str

"slider" for manual scrubbing, "animation" for auto-play

'slider'
show bool

Whether to call plt.show()

True
playback_speed float

Multiplier for playback speed (>1 = faster)

1.0
video_config VideoEncodingConfig | None

Complete video encoding override; None uses output defaults.

None
record_path str | None

Optional path to save animation (mp4/gif depending on writer)

None
base_offsets Array | None

Optional explicit base offsets for batched layouts

None
color_config RendererColorConfig | None

Shared renderer color configuration.

None
camera_config CameraConfig | None

Camera configuration. Matplotlib uses its field of view and the direction from position to look-at for 3D plots.

None
render_actuators bool

Whether to render actuator visual layers if available

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None

Returns:

Type Description
AnimateReturn

HTML object for Jupyter display (animation mode only)

render_sequence

render_sequence(ts: Array, q_ts: Array, *, interval: int = 50, record_path: str | None = None, video_config: VideoEncodingConfig | None = None, playback_speed: float = 1.0, camera_config: CameraConfig | None = None, color_config: RendererColorConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, show: bool = False) -> None

Render an animated sequence (optionally saving to disk).

This reuses the animation code path with mode='animation'.

Parameters:

Name Type Description Default
ts Array

Time stamps array of shape (T,)

required
q_ts Array

Configurations array of shape (T, DOF) or (N, T, DOF)

required
interval int

Frame interval in ms

50
video_config VideoEncodingConfig | None

Complete video encoding override; None uses output defaults.

None
record_path str | None

Optional path to save animation

None
playback_speed float

Multiplier for playback speed

1.0
camera_config CameraConfig | None

Camera configuration. Matplotlib uses its field of view and the direction from position to look-at for 3D plots.

None
color_config RendererColorConfig | None

Shared renderer color configuration.

None
render_actuators bool

Whether to render actuator visual layers if available

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
show bool

Whether to display the animation

False

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.

Open3D Renderer

Open3DRenderer provides interactive spatial visualization with mesh geometry, camera controls, playback, screenshots, and offline frame or video capture. Use the patched Open3D 0.20 dependency; macOS needs the source build with the Metal readback patch.

render_frame() and render_sequence(..., record_path=...) use the modern Filament renderer. Recordings export selected frames synchronously and return; interactive playback controls do not affect the export. Meshes and actuator lines are rebuilt for each exported frame, with a fixed camera fitted to the whole trajectory.

show() displays a fixed configuration with the modern GUI and the same materials, lighting and backdrop as exports. It supports mouse camera controls, R to reset the camera, C/L to save/restore it, S to save a modern snapshot, V to print the camera, and Q/Esc to close the window. On Linux, a separate process checks native window creation first. A failed display connection raises RuntimeError with the native log. This check adds GUI startup time and may briefly display a test window. Use an X11/XWayland session or Xvfb with GLX support for interactive viewing; headless workflows can use image or video export.

Sequences without record_path use the legacy viewer for efficient geometry updates. A warning explains that materials, lighting, transparency, shadows and ambient occlusion can differ from modern rendering. Its keyboard snapshots capture the animated preview appearance.

Set config.geometry.backbone_style="discrete" for per-point markers or "swept" for a material-frame surface lofted from the robot's cross-section contours. Multi-robot animated previews automatically merge each robot's backbone primitives to reduce Open3D registrations; merge_backbone_meshes can force or disable this behavior when measuring a particular workload.

Keyboard Controls

Playback and frame-stepping shortcuts apply to animated previews. Camera, snapshot and close shortcuts also work in show().

Key Action
Space Play or pause
→ / ← Step to the next or previous frame
H Go to the first frame
S Save a snapshot
R Reset the camera
C Capture camera parameters
L Load camera parameters
V Print camera parameters
Q / Esc Quit

soromox.rendering.open3d_renderer.Open3DRenderer

Open3DRenderer(robot: SoftRobot, config: RendererConfig | None = None, recompute_normals: bool = True, sphere_resolution: int = 32, base_offsets: Array | None = None, camera_margin_ratio: float = 0.05, merge_backbone_meshes: bool | None = None)

Bases: BaseSoftRobotRenderer


              flowchart TD
              soromox.rendering.open3d_renderer.Open3DRenderer[Open3DRenderer]
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

                              soromox.rendering.base.BaseSoftRobotRenderer --> soromox.rendering.open3d_renderer.Open3DRenderer
                


              click soromox.rendering.open3d_renderer.Open3DRenderer href "" "soromox.rendering.open3d_renderer.Open3DRenderer"
              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

Open3D visualization for any continuum soft robot.

Modern static views and image/video exports share materials, lighting and scene settings. Interactive playback uses the legacy visualizer for efficient mesh updates and warns about differences in shading.

Example
renderer = Open3DRenderer(robot)
renderer.show(q)
renderer.render_sequence(ts, q_ts, playback_speed=1.0)

Initialize Open3D renderer.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared scene, camera, color, geometry and output defaults.

None
robot SoftRobot

Robot system with forward_kinematics method

required
recompute_normals bool

Whether to recompute vertex normals per segment update

True
sphere_resolution int

Resolution for backbone spheres

32
base_offsets Array | None

Explicit base offsets of shape (N, 2) or (N, 3) for batched rendering

None
camera_margin_ratio float

Margin ratio for camera bounding box

0.05
merge_backbone_meshes bool | None

Whether to merge each robot's backbone primitives into one dynamic mesh. None selects merging automatically for multi-robot scenes while retaining the lower per-frame update cost of unmerged single-robot scenes.

None

is_3d property

is_3d: bool

Whether this renderer operates in 3D space.

Returns:

Name Type Description
is_3d bool

Always True for the Open3D renderer.

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

render_frame

render_frame(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, dynamic_spheres_positions: Array | None = None, dynamic_spheres_radii: Array | None = None, dynamics_spheres_colors: Array | None = None) -> ndarray

Render a single configuration with the modern renderer and return RGB.

Parameters:

Name Type Description Default
q Array

Robot configuration of shape (DOF,) or batched (N, DOF).

required
base_offsets Array | None

Optional base offsets of shape (N, ⅔) for batched layouts.

None
color_config RendererColorConfig | None

Optional shared renderer color configuration.

None
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.)

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
static_spheres_positions Array | None

Optional static sphere centers, shape (M, 3).

None
static_spheres_radii Array | None

Optional static sphere radii, length M.

None
static_spheres_colors Array | None

Optional static sphere colors, shape (M, ¾).

None
dynamic_spheres_positions Array | None

Optional dynamic sphere trajectories, shape (K, T, 3).

None
dynamic_spheres_radii Array | None

Optional dynamic sphere radii, length K.

None
dynamics_spheres_colors Array | None

Optional dynamic sphere colors, shape (K, ¾).

None

Returns:

Name Type Description
img ndarray

Rendered RGB image of shape (height, width, 3), dtype uint8.

show

show(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, dynamic_spheres_positions: Array | None = None, dynamic_spheres_radii: Array | None = None, dynamics_spheres_colors: Array | None = None) -> None

Display a fixed configuration with modern materials, lighting and shadows.

Mouse controls orbit, pan and zoom. R resets the camera; C/L save and restore it; S saves a modern snapshot; V prints the view; Q/Esc closes.

Parameters:

Name Type Description Default
q Array

Robot configuration of shape (DOF,) or batched (N, DOF).

required
base_offsets Array | None

Optional base offsets of shape (N, ⅔) for batched layouts.

None
color_config RendererColorConfig | None

Optional shared renderer color configuration.

None
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.)

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
static_spheres_positions Array | None

Optional static sphere centers, shape (M, 3).

None
static_spheres_radii Array | None

Optional static sphere radii, length M.

None
static_spheres_colors Array | None

Optional static sphere colors, shape (M, ¾).

None
dynamic_spheres_positions Array | None

Optional dynamic sphere trajectories, shape (K, T, 3).

None
dynamic_spheres_radii Array | None

Optional dynamic sphere radii, length K.

None
dynamics_spheres_colors Array | None

Optional dynamic sphere colors, shape (K, ¾).

None

Returns:

Type Description
None

None

render_sequence

render_sequence(ts: Array, q_ts: Array, *, playback_speed: float = 1.0, autoplay: bool = True, loop: bool = False, record_path: str | None = None, record_every_n: int = 1, record_prefix: str = 'frame_', video_config: VideoEncodingConfig | None = None, close_when_recording_done: bool = False, camera_config: CameraConfig | None = None, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, dynamic_spheres_positions: Array | None = None, dynamic_spheres_radii: Array | None = None, dynamics_spheres_colors: Array | None = None, window_name: str = 'Robot Animation (Open3D)') -> None

Preview a trajectory, or export it with the modern renderer.

With record_path, export all selected frames synchronously and return. Without it, open the legacy interactive preview. autoplay, loop, window_name and close_when_recording_done affect no exported frames; the latter is retained for existing callers, since export always returns. Video uses constant FPS derived from median timestamp spacing and playback_speed. record_every_n subsamples images and video, reducing video FPS by the same factor to preserve playback speed.

Parameters:

Name Type Description Default
ts Array

Time stamps of shape (T,).

required
q_ts Array

Configurations of shape (T, DOF) or batched (N, T, DOF).

required
playback_speed float

Playback speed multiplier (>0).

1.0
autoplay bool

Start playback immediately. If False, wait for space bar to play.

True
loop bool

Whether to loop the animation when it reaches the end.

False
record_path str | None

Optional path to save frames or video (extension determines mode).

None
record_every_n int

Export every n-th frame for both images and video.

1
record_prefix str

Filename prefix for recorded frames.

'frame_'
video_config VideoEncodingConfig | None

Optional ffmpeg encoding configuration for video output.

None
close_when_recording_done bool

Retained for compatibility; export always returns.

False
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.). Note: For interactive viewing, user can adjust camera with mouse.

None
base_offsets Array | None

Optional base offsets of shape (N, ⅔) for batched layouts.

None
color_config RendererColorConfig | None

Optional shared renderer color configuration.

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
static_spheres_positions Array | None

Optional static sphere centers, shape (M, 3).

None
static_spheres_radii Array | None

Optional static sphere radii, length M.

None
static_spheres_colors Array | None

Optional static sphere colors, shape (M, ¾).

None
dynamic_spheres_positions Array | None

Optional dynamic sphere trajectories, shape (K, T, 3).

None
dynamic_spheres_radii Array | None

Optional dynamic sphere radii, length K.

None
dynamics_spheres_colors Array | None

Optional dynamic sphere colors, shape (K, ¾).

None
window_name str

Title for the viewer window.

'Robot Animation (Open3D)'

Returns:

Type Description
None

None

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.

References

Zhou, Q. Y., Park, J., & Koltun, V. (2018). Open3D: A modern library for 3D data processing. arXiv preprint arXiv:1801.09847.

Open3D documentation

Viser Renderer

ViserRenderer provides browser-based spatial visualization with live state streaming, playback controls, multi-robot scenes, lighting, helper geometry, plot panels, and synchronized video or snapshot capture. As with Open3D, backbone_style selects discrete or swept robot geometry.

GUI Plots and Live Mode

ViserRenderer.render_sequence() can add Plotly panels with:

  • plot_configurations=True
  • plot_actuator_positions=True
  • custom_plots={"My Plot": (figure, aspect)}

Plot panels require Plotly and a single trajectory with shape (T, DOF). Live visualization is available through start_live_mode(), either with a callback that supplies states or by pushing states to the returned controller.

Visual Quality

Viser consumes the shared config.scene lighting, materials, shadows and scenery settings. Static output uses PBR GLB meshes; playback and live views use efficiently updated meshes with approximate materials. Geometry sampling is configured through config.geometry. sphere_resolution is a Viser-specific mesh tessellation control. See backend support for exposure, tone-mapping and material limitations.

soromox.rendering.viser_renderer.ViserRenderer

ViserRenderer(robot: SoftRobot, config: RendererConfig | None = None, host: str = '0.0.0.0', port: int = 8080, sphere_resolution: int = 3, base_offsets: Array | None = None, auto_start: bool = True, open_browser: bool = True)

Bases: BaseSoftRobotRenderer


              flowchart TD
              soromox.rendering.viser_renderer.ViserRenderer[ViserRenderer]
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

                              soromox.rendering.base.BaseSoftRobotRenderer --> soromox.rendering.viser_renderer.ViserRenderer
                


              click soromox.rendering.viser_renderer.ViserRenderer href "" "soromox.rendering.viser_renderer.ViserRenderer"
              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

Viser-based web visualization for soft robots.

Provides interactive 3D visualization accessible via web browser with: - Real-time animation playback with GUI controls - Live mode for streaming robot states - Multiple robot overlay - Dynamic spheres for setpoints/obstacles - Embedded plot panels - Video export via FFmpeg

Example
renderer = ViserRenderer(robot, port=8080)
renderer.show(q)
renderer.render_sequence(ts, q_ts, playback_speed=1.0, loop=True)

Initialize Viser renderer.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared scene, camera, color, geometry and output defaults.

None
robot SoftRobot

SoftRobot system with forward_kinematics method

required
host str

Server bind address (0.0.0.0 for all interfaces)

'0.0.0.0'
port int

Server port number

8080
sphere_resolution int

Icosphere subdivision level (1=low, 2=medium, 3=good, 4=high)

3
base_offsets Array | None

Explicit base position offsets (N, 3)

None
auto_start bool

Start server immediately

True
open_browser bool

Open browser automatically when show() is called

True

is_3d property

is_3d: bool

Always True for Viser (3D only).

server property

server: ViserServer

Access underlying Viser server.

url property

url: str

URL to access the visualization.

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

start

start() -> None

Start the Viser server.

stop

stop() -> None

Stop the Viser server.

render_frame

render_frame(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, capture_client_idx: int = 0) -> ndarray

Render single configuration and capture as image.

Note: Requires at least one connected client to capture.

Parameters:

Name Type Description Default
q Array

Robot configuration (DOF,) or batched (N, DOF)

required
base_offsets Array | None

Base position offsets (N, 3)

None
color_config RendererColorConfig | None

Shared renderer color configuration

None
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.)

None
render_actuators bool

If True, render actuator visual layers.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
static_spheres_positions Array | None

Static sphere positions (M, 3)

None
static_spheres_radii Array | None

Static sphere radii (M,)

None
static_spheres_colors Array | None

Static sphere colors (M, 3)

None
capture_client_idx int

Index of client to capture from

0

Returns:

Type Description
ndarray

RGB image as numpy array (height, width, 3), dtype uint8

show

show(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, blocking: bool = True) -> None

Display single frame interactively.

Opens browser automatically and optionally blocks.

Parameters:

Name Type Description Default
q Array

Robot configuration (DOF,) or batched (N, DOF)

required
base_offsets Array | None

Base position offsets (N, 3)

None
color_config RendererColorConfig | None

Shared renderer color configuration

None
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.)

None
render_actuators bool

If True, render actuator visual layers.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
static_spheres_positions Array | None

Static sphere positions (M, 3)

None
static_spheres_radii Array | None

Static sphere radii (M,)

None
static_spheres_colors Array | None

Static sphere colors (M, 3)

None
blocking bool

If True, block until user closes browser

True

render_sequence

render_sequence(ts: Array, q_ts: Array, *, playback_speed: float = 1.0, autoplay: bool = True, loop: bool = False, record_path: str | None = None, snapshot_paths: Mapping[int, str | Path] | None = None, record_every_n: int = 1, stop_when_recording_done: bool = False, record_client_timeout: float = 10.0, record_frame_timeout: float = 10.0, video_config: VideoEncodingConfig | None = None, camera_config: CameraConfig | None = None, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None, multi_robot_layout: Literal['grid', 'overlay'] = 'grid', static_spheres_positions: Array | None = None, static_spheres_radii: Array | None = None, static_spheres_colors: Array | None = None, dynamic_spheres_positions: Array | None = None, dynamic_spheres_radii: Array | None = None, dynamic_spheres_colors: Array | None = None, blocking: bool = True, plot_configurations: bool = False, plot_actuator_positions: bool = False, custom_plots: dict[str, tuple] | None = None, robot_name: str = 'Robot') -> None

Render animated trajectory with full visualization options.

Parameters:

Name Type Description Default
ts Array

Time stamps (T,)

required
q_ts Array

Configurations (T, DOF) or batched (N, T, DOF)

required
playback_speed float

Speed multiplier

1.0
autoplay bool

Start playing immediately

True
loop bool

Loop animation

False
record_path str | None

Path to save video (mp4, mov)

None
snapshot_paths Mapping[int, str | Path] | None

Mapping from zero-based frame indices to PNG paths. Requested snapshots use the same synchronized browser render as video.

None
record_every_n int

Record every N frames

1
stop_when_recording_done bool

If True, return after recording one non-looping pass through the sequence.

False
record_client_timeout float

Seconds to wait for a browser client before video recording fails.

10.0
record_frame_timeout float

Seconds to wait for each browser render before video recording fails.

10.0
video_config VideoEncodingConfig | None

FFmpeg encoding settings

None
camera_config CameraConfig | None

Camera configuration (fov, position, look_at, etc.)

None
base_offsets Array | None

Base position offsets (N, ⅔)

None
color_config RendererColorConfig | None

Shared renderer color configuration

None
render_actuators bool

If True, render actuator visual layers.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None
multi_robot_layout Literal['grid', 'overlay']

"grid" for side-by-side, "overlay" for same position

'grid'
static_spheres_positions Array | None

Static sphere positions

None
static_spheres_radii Array | None

Static sphere radii

None
static_spheres_colors Array | None

Static sphere colors

None
dynamic_spheres_positions Array | None

Time-varying sphere positions

None
dynamic_spheres_radii Array | None

Time-varying sphere radii

None
dynamic_spheres_colors Array | None

Time-varying sphere colors

None
blocking bool

If True, block until viewer closes

True
plot_configurations bool

If True, add configuration vs time plot to GUI

False
plot_actuator_positions bool

If True, add actuator coordinate plot to GUI

False
custom_plots dict[str, tuple] | None

Dictionary mapping plot names to (figure, aspect) tuples for custom plotly figures to add to the GUI

None
robot_name str

Name for plot titles

'Robot'

add_gui_plotly

add_gui_plotly(name: str, figure: Figure, aspect: float = 1.0) -> Any

Add a plotly figure to the GUI.

Parameters:

Name Type Description Default
name str

Unique name for the plot

required
figure Figure

Plotly figure object

required
aspect float

Aspect ratio (width/height)

1.0

Returns:

Type Description
Any

Viser plotly handle

create_configuration_plot

create_configuration_plot(ts: Array | ndarray, q_ts: Array | ndarray, robot_name: str = 'Robot') -> Figure

Create a plotly figure showing configurations over time.

Parameters:

Name Type Description Default
ts Array | ndarray

Time array (T,)

required
q_ts Array | ndarray

Configuration array (T, DOF)

required
robot_name str

Name for the plot title

'Robot'

Returns:

Type Description
Figure

Plotly figure

create_actuator_position_plot

create_actuator_position_plot(ts: Array | ndarray, q_ts: Array | ndarray, robot: SoftRobot, robot_name: str = 'Robot') -> Figure

Create a plotly figure showing actuator coordinates over time.

Parameters:

Name Type Description Default
ts Array | ndarray

Time array (T,)

required
q_ts Array | ndarray

Configuration array (T, DOF)

required
robot SoftRobot

Robot instance with an actuator_coordinates method

required
robot_name str

Name for the plot title

'Robot'

Returns:

Type Description
Figure

Plotly figure

start_live_mode

start_live_mode(callback: Callable[[float], ndarray] | None = None, dt: float = 0.033) -> LiveModeController

Start live visualization mode.

Two usage patterns:

Callback mode (renderer pulls):

def get_state(t):
    return compute_robot_state(t)

controller = renderer.start_live_mode(callback=get_state)

Stream mode (user pushes):

controller = renderer.start_live_mode()
for q in simulation_loop():
    controller.push_state(q)

Parameters:

Name Type Description Default
callback Callable[[float], ndarray] | None

Optional state provider function (time) -> q

None
dt float

Time step for callback mode in seconds

0.033

Returns:

Type Description
LiveModeController

LiveModeController for managing the live session

add_dynamic_sphere

add_dynamic_sphere(name: str, position: ndarray, radius: float, color: tuple[float, float, float] = (0.2, 0.2, 0.8), opacity: float = 1.0) -> Any

Add a dynamic sphere to the scene.

Parameters:

Name Type Description Default
name str

Unique identifier for the sphere

required
position ndarray

Initial position (3,)

required
radius float

Sphere radius

required
color tuple[float, float, float]

RGB color (0-1)

(0.2, 0.2, 0.8)
opacity float

Opacity (0-1)

1.0

Returns:

Type Description
Any

Viser sphere handle

update_dynamic_sphere

update_dynamic_sphere(name: str, position: ndarray | None = None, radius: float | None = None, color: tuple[float, float, float] | None = None) -> None

Update properties of a dynamic sphere.

Parameters:

Name Type Description Default
name str

Sphere identifier

required
position ndarray | None

New position (3,)

None
radius float | None

New radius

None
color tuple[float, float, float] | None

New RGB color

None

remove_dynamic_sphere

remove_dynamic_sphere(name: str) -> None

Remove a dynamic sphere from the scene.

Parameters:

Name Type Description Default
name str

Sphere identifier

required

add_custom_primitive

add_custom_primitive(name: str, primitive_type: Literal['sphere', 'box', 'cylinder', 'mesh'], **kwargs: Any) -> Any

Add a custom primitive to the scene for extensibility.

Parameters:

Name Type Description Default
name str

Unique identifier

required
primitive_type Literal['sphere', 'box', 'cylinder', 'mesh']

Type of primitive

required
**kwargs Any

Primitive-specific parameters

{}

Returns:

Type Description
Any

Viser scene handle

render_to_video

render_to_video(ts: Array, q_ts: Array, output_path: str, *, width: int | None = None, height: int | None = None, fps: float | None = None, video_config: VideoEncodingConfig | None = None, camera_position: tuple[float, float, float] | None = None, camera_target: tuple[float, float, float] | None = None, **render_kwargs: Any) -> None

Render sequence directly to video file.

This method renders each frame and writes to video using FFmpeg. Requires at least one connected client for capture.

Parameters:

Name Type Description Default
ts Array

Time stamps

required
q_ts Array

Configurations

required
output_path str

Output video path (.mp4, .mov)

required
width int | None

Frame width (default: self.width)

None
height int | None

Frame height (default: self.height)

None
fps float | None

Output FPS (if None, derived from ts)

None
video_config VideoEncodingConfig | None

FFmpeg settings

None
camera_position tuple[float, float, float] | None

Fixed camera position

None
camera_target tuple[float, float, float] | None

Camera look-at target

None
**render_kwargs Any

Additional render_sequence arguments

{}

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.

References

Yi, B., Kim, C. M., Kerr, J., Wu, G., Feng, R., Zhang, A., Kulhanek, J., Choi, H., Ma, Y., Tancik, M., & Kanazawa, A. (2025). Viser: Imperative, Web-based 3D Visualization in Python. arXiv preprint arXiv:2507.22885.

OpenCV Planar Renderer

OpenCVPlanarRenderer provides lightweight single-frame rendering and fast video export for planar robots. Both OpenCV backends use a white canvas and ignore scene backgrounds, ground planes, backdrops, lighting and effects. Robot colors, geometry, output settings and the planar pixel projection apply.

soromox.rendering.opencv_planar_renderer.OpenCVPlanarRenderer

OpenCVPlanarRenderer(robot: SoftRobot, config: RendererConfig | None = None, length_scale: float = 2.0, origin_uv: tuple[int, int] | None = None)

Bases: BaseOpenCVRenderer


              flowchart TD
              soromox.rendering.opencv_planar_renderer.OpenCVPlanarRenderer[OpenCVPlanarRenderer]
              soromox.rendering.opencv_base.BaseOpenCVRenderer[BaseOpenCVRenderer]
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

                              soromox.rendering.opencv_base.BaseOpenCVRenderer --> soromox.rendering.opencv_planar_renderer.OpenCVPlanarRenderer
                                soromox.rendering.base.BaseSoftRobotRenderer --> soromox.rendering.opencv_base.BaseOpenCVRenderer
                



              click soromox.rendering.opencv_planar_renderer.OpenCVPlanarRenderer href "" "soromox.rendering.opencv_planar_renderer.OpenCVPlanarRenderer"
              click soromox.rendering.opencv_base.BaseOpenCVRenderer href "" "soromox.rendering.opencv_base.BaseOpenCVRenderer"
              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

OpenCV visualization for planar soft robots.

Renders the backbone curve with optional segment-aware thickness when per-segment radii are available.

Example
renderer = OpenCVPlanarRenderer(robot)
image = renderer.render_frame(q)
renderer.show(q)

Initialize OpenCV renderer for planar robots.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared robot color, geometry and output defaults. Scene appearance is ignored; the canvas is white.

None
robot SoftRobot

Planar robot instance

required
length_scale float

Scale factor for robot in image (robot occupies height/length_scale)

2.0
origin_uv tuple[int, int] | None

Pixel coordinates of world origin (None = center of image)

None

is_3d property

is_3d: bool

Planar robots are 2D.

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

render_frame

render_frame(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None) -> ndarray

Render single configuration to BGR image array.

Parameters:

Name Type Description Default
q Array

Robot configuration array of shape (DOF,) for a single robot.

required
base_offsets Array | None

Optional positional offset with shape (2,) or (3,). The z component is ignored for this planar renderer.

None
color_config RendererColorConfig | None

Complete robot-color override.

None
camera_config CameraConfig | None

Camera override; the planar pixel projection is unchanged.

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None

Returns:

Name Type Description
img ndarray

BGR image of shape (height, width, 3), dtype uint8.

show

show(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None, render_actuators: bool = True, actuator_inputs: Array | None = None) -> None

Display single frame in OpenCV window.

Parameters:

Name Type Description Default
q Array

Robot configuration array of shape (DOF,).

required
base_offsets Array | None

Optional positional offset with shape (2,) or (3,).

None
color_config RendererColorConfig | None

Complete robot-color override.

None
camera_config CameraConfig | None

Camera override; the planar pixel projection is unchanged.

None
render_actuators bool

Whether to render actuator visual layers if available.

True
actuator_inputs Array | None

Optional actuator inputs for scalar-colored layers.

None

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

render_sequence

render_sequence(ts: Array, q_ts: Array, *, record_path: str, playback_speed: float = 1.0, video_config: VideoEncodingConfig | None = None, base_offsets: Array | None = None, camera_config: CameraConfig | None = None, color_config: RendererColorConfig | None = None) -> None

Render animated sequence to video file using ffmpeg.

Falls back to OpenCV VideoWriter if ffmpeg is unavailable.

Parameters:

Name Type Description Default
ts Array

Time stamps of shape (T,)

required
q_ts Array

Configurations of shape (T, DOF)

required
record_path str

Path to save video file

required
playback_speed float

Playback speed multiplier (>0)

1.0
video_config VideoEncodingConfig | None

Complete video encoding override.

None
base_offsets Array | None

Optional positional offset for every exported frame.

None
camera_config CameraConfig | None

Camera override, approximated by the planar projection.

None
color_config RendererColorConfig | None

Complete sRGB robot color override.

None

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.

OpenCV Planar HSA Renderer

OpenCVPlanarHSARenderer extends the planar OpenCV backend with HSA-specific geometry. Its system-level usage is documented with the Planar HSA model.

soromox.rendering.planar_hsa.opencv_renderer.OpenCVPlanarHSARenderer

OpenCVPlanarHSARenderer(robot: PlanarHSA, config: RendererConfig | None = None, rod_thickness: int = 10)

Bases: BaseOpenCVRenderer


              flowchart TD
              soromox.rendering.planar_hsa.opencv_renderer.OpenCVPlanarHSARenderer[OpenCVPlanarHSARenderer]
              soromox.rendering.opencv_base.BaseOpenCVRenderer[BaseOpenCVRenderer]
              soromox.rendering.base.BaseSoftRobotRenderer[BaseSoftRobotRenderer]

                              soromox.rendering.opencv_base.BaseOpenCVRenderer --> soromox.rendering.planar_hsa.opencv_renderer.OpenCVPlanarHSARenderer
                                soromox.rendering.base.BaseSoftRobotRenderer --> soromox.rendering.opencv_base.BaseOpenCVRenderer
                



              click soromox.rendering.planar_hsa.opencv_renderer.OpenCVPlanarHSARenderer href "" "soromox.rendering.planar_hsa.opencv_renderer.OpenCVPlanarHSARenderer"
              click soromox.rendering.opencv_base.BaseOpenCVRenderer href "" "soromox.rendering.opencv_base.BaseOpenCVRenderer"
              click soromox.rendering.base.BaseSoftRobotRenderer href "" "soromox.rendering.base.BaseSoftRobotRenderer"
            

OpenCV visualization for Planar HSA robots.

Renders the virtual backbone, rods, and platforms with custom colors. This is a specialized renderer that uses HSA-specific forward kinematics.

Example
renderer = OpenCVPlanarHSARenderer(robot)
image = renderer.render_frame(q)
renderer.show(q)

Initialize OpenCV renderer for Planar HSA.

Parameters:

Name Type Description Default
config RendererConfig | None

Shared robot color, geometry and output defaults. Scene appearance is ignored; the canvas is white.

None
robot PlanarHSA

PlanarHSA robot instance

required
rod_thickness int

Line thickness for rods

10

is_3d property

is_3d: bool

Planar HSA is 2D.

is_planar property

is_planar: bool

Return True for planar (SE(2)) robots.

render_frame

render_frame(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None) -> ndarray

Render single configuration to BGR image array.

Parameters:

Name Type Description Default
color_config RendererColorConfig | None

Complete sRGB robot color override.

None
camera_config CameraConfig | None

Camera override; the planar pixel projection is unchanged.

None
q Array

Robot configuration array

required
base_offsets Array | None

Optional positional offset with shape (2,) or (3,). The z component is ignored for this planar renderer.

None

Returns:

Type Description
ndarray

BGR image as numpy array of shape (height, width, 3), dtype uint8

show

show(q: Array, *, base_offsets: Array | None = None, color_config: RendererColorConfig | None = None, camera_config: CameraConfig | None = None) -> None

Display single frame in OpenCV window.

Parameters:

Name Type Description Default
q Array

Robot configuration.

required
color_config RendererColorConfig | None

Complete robot color override.

None
camera_config CameraConfig | None

Camera override, approximated by the planar projection.

None
base_offsets Array | None

Optional positional offset with shape (2,) or (3,).

None

compute_backbone_curve

compute_backbone_curve(q: Array) -> Array

Compute backbone points from configuration.

Parameters:

Name Type Description Default
q Array

Robot configuration array

required

Returns:

Type Description
Array

Array of shape (num_points, 3) for 3D or (num_points, 2) for 2D

compute_backbone_poses

compute_backbone_poses(q: Array) -> Array

Compute full FK poses at the configured backbone sample points.

compute_actuator_visual_layers

compute_actuator_visual_layers(q: Array, *, actuator_inputs: Array | None = None) -> tuple[ActuatorVisualLayer, ...]

Compute renderer-facing actuator visual layers for one robot.

compute_actuator_visual_layers_batched

compute_actuator_visual_layers_batched(q_batch: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[BatchedActuatorVisualLayer, ...]

Compute actuator visual layers for multiple robots with base offsets.

compute_actuator_visual_layers_trajectory

compute_actuator_visual_layers_trajectory(q_ts: Array, base_offsets: Array, *, actuator_inputs: Array | ndarray | None = None) -> tuple[TrajectoryActuatorVisualLayer, ...]

Compute actuator visual layers for (N, T, DOF) trajectories.

render_sequence

render_sequence(ts: Array, q_ts: Array, *, record_path: str, playback_speed: float = 1.0, video_config: VideoEncodingConfig | None = None, base_offsets: Array | None = None, camera_config: CameraConfig | None = None, color_config: RendererColorConfig | None = None) -> None

Render animated sequence to video file using ffmpeg.

Falls back to OpenCV VideoWriter if ffmpeg is unavailable.

Parameters:

Name Type Description Default
ts Array

Time stamps of shape (T,)

required
q_ts Array

Configurations of shape (T, DOF)

required
record_path str

Path to save video file

required
playback_speed float

Playback speed multiplier (>0)

1.0
video_config VideoEncodingConfig | None

Complete video encoding override.

None
base_offsets Array | None

Optional positional offset for every exported frame.

None
camera_config CameraConfig | None

Camera override, approximated by the planar projection.

None
color_config RendererColorConfig | None

Complete sRGB robot color override.

None

resolve_backbone_colors

resolve_backbone_colors(num_robots: int, *, color_config: RendererColorConfig | None = None, cache: bool = True) -> ResolvedBackboneColors

Resolve backbone colors using the shared config hierarchy.

get_color_legend

get_color_legend(*, num_robots: int = 1, color_config: RendererColorConfig | None = None) -> ColorLegend

Return a lightweight color legend for the current configuration.

clear_color_cache

clear_color_cache() -> None

Clear cached color resolutions.

compute_backbone_curves_batched

compute_backbone_curves_batched(q_batch: Array, base_offsets: Array) -> Array

Compute backbone curves for multiple robots with base offsets.

Vectorizes :meth:compute_backbone_curve over configurations. Each curve uses the robot's public abscissa-batched kinematics method.

Parameters:

Name Type Description Default
q_batch Array

Configurations of shape (N, DOF) - batch-first

required
base_offsets Array

Base position offsets of shape (N, 2) or (N, 3)

required

Returns:

Type Description
Array

Array of shape (N, num_points, dim) - batch-first

compute_backbone_curves_and_frames_batched

compute_backbone_curves_and_frames_batched(q_batch: Array, base_offsets: Array) -> tuple[Array, Array]

Compute 3D backbone positions and material frames for multiple robots.

The frame columns are the local material-frame axes in world coordinates. Positional base offsets translate the curves without rotating the frames.