Data visualization¶
Operators can open a live view of any running node in the Neuraverse UI and watch what it publishes: camera frames as video, audio as a waveform, segmentation masks over the source image, everything else as JSON. After this page you will know what your node gets for free, which output types are excluded, how to expose extra topics, and where the Python SDK deliberately has no public API.
What you get without writing code¶
Every message you hand to self.publish(port, msg) on a visualizable output port is streamed to the UI while a viewer has the node open. The SDK does this by wrapping the publish path itself, so it works no matter which transport carries your dataflow. A failure in the visualization bridge is swallowed and never breaks publish().
How a port is rendered depends only on the rosType you declared for it in the schema:
Output rosType |
Streamed to the UI as |
|---|---|
sensor_msgs/msg/CompressedImage |
video track (frames as published) |
sensor_msgs/msg/Image |
video track (frames as published) |
instance_segmentation_ros_msgs/msg/SegmentationResult |
video track (rendered image: greyscale map, masks/boxes over the source image) |
instance_segmentation_ros_msgs/msg/SegmentedInstanceArray |
video track (rendered image: greyscale map, masks/boxes over the source image) |
nav_msgs/msg/OccupancyGrid |
video track (rendered image: greyscale map, masks/boxes over the source image) |
audio_common_msgs/msg/AudioData |
video track (live waveform) |
audio_msgs/msg/AudioData |
video track (live waveform) |
| any other message type | JSON on the data channel (throttled) |
Two more things happen automatically:
- Late viewers see the current value. The SDK keeps the last message published per output port. When a viewer opens the panel between two publishes, that cached value is sent first instead of an empty panel.
- Extra topics are throttled. Messages the SDK reads from a ROS 2 topic it subscribes to itself (see Exposing extra topics) are rate-limited before they reach the UI, except image and audio frames. Messages that go through
self.publish()are forwarded as published, with no rate limit, so keep the publish rate of an output people will watch reasonable.
The image tutorial is the simplest example: GrayscaleNode publishes a sensor_msgs/msg/CompressedImage on image_out and shows up as a video stream with no extra code. See Tutorial 2: Image node.
Output types that are never visualized¶
Some message types produce oversized or meaningless output in a browser panel. Output ports with these types are left out of the visualization picker entirely:
| Not visualized (no stream is created for these output types) |
|---|
sensor_msgs/msg/CameraInfo |
sensor_msgs/msg/Imu |
sensor_msgs/msg/LaserScan |
sensor_msgs/msg/MagneticField |
sensor_msgs/msg/NavSatFix |
sensor_msgs/msg/PointCloud2 |
tf2_msgs/msg/TFMessage |
If you need to inspect such data, add a second output port with a summarised type (for example a std_msgs/msg/String with a short description) and publish to it alongside the raw message.
Exposing extra topics¶
By default the picker lists exactly your output ports, keyed by port name. Override on_get_data_visualization_topics() when the node also publishes on a ROS 2 topic that is not one of its declared ports (for example a driver that owns its own rclpy publisher). The SDK subscribes to such topics itself while a viewer is watching. The override lives on your node class:
from neuraverse_sdk.models.node_models import NodeVisualizationsTopic, NodeVisualizationsTopics
def on_get_data_visualization_topics(self) -> NodeVisualizationsTopics:
return NodeVisualizationsTopics(
topics={
"raw_camera": NodeVisualizationsTopic(
topic_name="/camera/image_raw",
visualization_type="sensor_msgs/msg/Image",
),
}
)
| Field | Meaning |
|---|---|
dict key ("raw_camera") |
The name shown in the picker. Pick one that does not collide with an output port name; on a collision the output port wins. |
topic_name |
The ROS 2 topic the SDK subscribes to. |
visualization_type |
The ROS message type on that topic, written as pkg/msg/Type. Rendering follows the same table as above. |
topics must be a dict, not a list
NodeVisualizationsTopics(topics=...) takes a mapping {name: NodeVisualizationsTopic}. If you pass a list, the SDK fails while enumerating the node's topics, logs a warning, and drops the whole node from the visualization picker, including its regular output ports. Nothing else breaks, so the mistake is easy to miss. Older templates used the list form; correct them.
The default implementation returns NodeVisualizationsTopics(topics={}), so a node that only uses its declared ports needs no override.
Segmentation backgrounds¶
A segmentation stream (SegmentationResult or SegmentedInstanceArray) is drawn as masks over a source image. That source image comes from your node's image input ports: while a viewer watches a segmentation output, every self.get_data(port) call on an input port of type sensor_msgs/msg/Image or sensor_msgs/msg/CompressedImage feeds the background automatically. A detector that reads a camera port and publishes masks therefore needs no visualization code at all. Supported input encodings are compressed images plus raw rgb8, bgr8 and 8UC3.
Python has no public push API
The Python SDK exposes no method to push a frame into a visualization from node code. You may see nodes call getattr(self, "_viz_bg_push", None) or _viz_image_push behind a guard. Those attributes are private plumbing that the SDK injects only while a viewer is watching, and they are cleared on stop. Relying on them is unsupported; they can be renamed or removed without notice. This is a known parity gap with the C++ SDK, which has pushBackgroundFrame.
If your node builds its source image in-process, so the image never passes through get_data(), route it through a declared port instead: publish the image on an output port of type sensor_msgs/msg/CompressedImage and it appears as its own video stream next to the masks.
Reacting to a viewer¶
Two optional hooks let a node react when someone starts or stops watching. Both default to no-ops.
| Hook | When it runs | Typical use |
|---|---|---|
on_start_data_visualization(topic_names: list[str]) |
A viewer opened the panel; topic_names lists the picker names being watched. |
Raise a camera's publish rate, start a diagnostic publisher. |
on_stop_data_visualization() |
The viewer closed the panel. | Restore the normal rate, stop the diagnostic publisher. |
Keep these hooks quick and do not raise from them; they run inside the request that opens or closes the panel. Stopping the node does not call on_stop_data_visualization(): a viewer that is still watching keeps seeing the last cached frame, marked as cached, until they close the panel.
Service configuration¶
Nothing about the media transport is configured per node. The UI supplies the room and the credentials for each session; your service_config.yaml only carries two fallbacks:
| Key | Default | Meaning |
|---|---|---|
livekit_url |
"" |
Server URL used when the session request does not carry one. |
viz_sources_ready_timeout_s |
10.0 |
How long a session start waits for its video sources before wiring the publish bridge anyway. On timeout a warning is logged and the first frames may drop. |
Both keys are listed with all other settings in the service_config.yaml reference.
C++ nodes get the same zero-code behaviour: every visualizable output streams to the UI, topics the node does not publish itself are picked up by a ROS subscription, and the last value per port is cached for late viewers.
Mock Runner
The Mock Runner does not stream visualizations. The previews in its sidebar are the mock's own rendering of injected and published values, not the UI visualization described here. Test visualization against a real engine.
Checklist¶
| Goal | Action |
|---|---|
| Show an image, audio or JSON output live | Nothing. Declare the correct rosType in the schema and call self.publish(). |
| Show a topic the node publishes outside its ports | Override on_get_data_visualization_topics() and return a dict of NodeVisualizationsTopic. |
| Show masks over the camera image | Read the camera through an image input port with self.get_data(); publish the segmentation on an output port. |
| Push an in-process frame | Not available in Python. Publish the frame on a declared CompressedImage output port. |
| Save CPU when nobody is watching | Lower rates in on_stop_data_visualization(), raise them in on_start_data_visualization(). |
| Inspect a point cloud, IMU or TF output | Not possible in the picker. Add a summarising output port with a simple type. |