The log API sends data to Rerun one row at a time, as your code produces it.
This page covers the other ways to send data: whole columns at once, partial updates, dataframes and tables, your own data types, and clearing data that is no longer valid.
Send entire columns at once
The log API is designed to extract data from your running code as it's being generated. It is, by nature, row-oriented.
If you already have data stored in something more column-oriented, it can be both a lot easier and more efficient to send it to Rerun in that form directly.
This is what the send_columns API is for: it lets you efficiently update the state of an entity over time, sending data for multiple index and component columns in a single operation.
To learn more about the concepts behind the columnar APIs, and the Rerun data model in general, refer to this page.
Choosing log vs send_columns
Each log call has a fixed overhead per call.
For many small rows (for example a scalar at 1 kHz, or a long history of poses), this per-call overhead dominates, and send_columns is much faster.
- Use
send_columns(orsend_dataframe) for bulk or historical data that you already have in arrays or tables. - Use
logfor live data that is produced one sample at a time. The micro-batcher groups these rows into chunks in the background.
How columns are formed
In Python, Archetype.columns(**fields) builds one column per field you pass.
This section uses Python.
In Rust and C++, you set the fields with the builder methods and pass the row lengths to .columns(lengths) (or use columns_of_unit_batches() in Rust and .columns() in C++ for one element per row).
- One row per element by default.
rr.Scalars.columns(scalars=[1.0, 2.0, 3.0])gives three rows, one value each. The number of rows must match the length of the index columns. - Several instances per row: use
.partition(lengths).rr.Points3D.columns(positions=positions).partition(lengths=[2, 4, 3])gives three rows with 2, 4, and 3 points. The lengths must sum to the total number of elements. - Send only some fields. You don't need to pass every field: only the components you pass are sent. The others keep their latest value, or their default.
- Log constant fields once.
If a field does not change over time (for example the format of an image, or the color of a point cloud), log it once with
rr.log(…, static=True)and send only the changing fields withsend_columns. - Images: reshape the image stack to
(N, -1)with auint8view, so each row is one image buffer:rr.Image.columns(buffer=images.view(np.uint8).reshape(len(times), -1)). Log the image format once as static, as in the image example below.
Columns reference
Columns examples
Updating a scalar over time, in a single operation
Consider this snippet, using the row-oriented log API:
"""
Update a scalar over time.
See also the `scalar_column_updates` example, which achieves the same
thing in a single operation.
"""
from __future__ import annotations
import math
import rerun as rr
rr.init("rerun_example_scalar_row_updates", spawn=True)
for step in range(64):
rr.set_time("step", sequence=step)
rr.log("scalars", rr.Scalars(math.sin(step / 10.0)))
which can be translated to the column-oriented send_columns API as such:
"""
Update a scalar over time, in a single operation.
This is semantically equivalent to the `scalar_row_updates` example,
albeit much faster.
"""
from __future__ import annotations
import numpy as np
import rerun as rr
rr.init("rerun_example_scalar_column_updates", spawn=True)
times = np.arange(0, 64)
scalars = np.sin(times / 10.0)
rr.send_columns(
"scalars",
indexes=[rr.TimeColumn("step", sequence=times)],
columns=rr.Scalars.columns(scalars=scalars),
)
Updating a point cloud over time, in a single operation
Consider this snippet, using the row-oriented log API:
"""
Update a point cloud over time.
See also the `points3d_column_updates` example, which achieves the same
thing in a single operation.
"""
import numpy as np
import rerun as rr
rr.init("rerun_example_points3d_row_updates", spawn=True)
# Prepare a point cloud that evolves over 5 timesteps, changing the
# number of points in the process.
times = np.arange(10, 15, 1.0)
# fmt: off
positions = [
[[1.0, 0.0, 1.0], [0.5, 0.5, 2.0]],
[[1.5, -0.5, 1.5], [1.0, 1.0, 2.5], [-0.5, 1.5, 1.0], [-1.5, 0.0, 2.0]],
[[2.0, 0.0, 2.0], [1.5, -1.5, 3.0], [0.0, -2.0, 2.5], [1.0, -1.0, 3.5]],
[[-2.0, 0.0, 2.0], [-1.5, 1.5, 3.0], [-1.0, 1.0, 3.5]],
[[1.0, -1.0, 1.0], [2.0, -2.0, 2.0], [3.0, -1.0, 3.0], [2.0, 0.0, 4.0]],
]
# fmt: on
# At each timestep, all points in the cloud share the same but changing
# color and radius.
colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF]
radii = [0.05, 0.01, 0.2, 0.1, 0.3]
for i in range(5):
rr.set_time("time", duration=10 + i)
rr.log(
"points", rr.Points3D(positions[i], colors=colors[i], radii=radii[i])
)
which can be translated to the column-oriented send_columns API as such:
"""
Update a point cloud over time, in a single operation.
This is semantically equivalent to the `points3d_row_updates` example,
albeit much faster.
"""
from __future__ import annotations
import numpy as np
import rerun as rr
rr.init("rerun_example_points3d_column_updates", spawn=True)
# Prepare a point cloud that evolves over 5 timesteps, changing the
# number of points in the process.
times = np.arange(10, 15, 1.0)
# fmt: off
positions = [
[1.0, 0.0, 1.0], [0.5, 0.5, 2.0],
[1.5, -0.5, 1.5], [1.0, 1.0, 2.5], [-0.5, 1.5, 1.0], [-1.5, 0.0, 2.0],
[2.0, 0.0, 2.0], [1.5, -1.5, 3.0], [0.0, -2.0, 2.5], [1.0, -1.0, 3.5],
[-2.0, 0.0, 2.0], [-1.5, 1.5, 3.0], [-1.0, 1.0, 3.5],
[1.0, -1.0, 1.0], [2.0, -2.0, 2.0], [3.0, -1.0, 3.0], [2.0, 0.0, 4.0],
]
# fmt: on
# At each timestep, all points in the cloud share the same but changing
# color and radius.
colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF]
radii = [0.05, 0.01, 0.2, 0.1, 0.3]
rr.send_columns(
"points",
indexes=[rr.TimeColumn("time", duration=times)],
columns=[
*rr.Points3D.columns(positions=positions).partition(
lengths=[2, 4, 4, 3, 4]
),
*rr.Points3D.columns(colors=colors, radii=radii),
],
)
Each row in the component column can be a batch of data, e.g. a batch of positions. This lets you log the evolution of a point cloud over time efficiently.
Updating a fixed number of arrows over time, in a single operation
Consider this snippet, using the row-oriented log API:
"""
Update a set of vectors over time.
See also the `arrows3d_column_updates` example, which achieves the same
thing in a single operation.
"""
import numpy as np
import rerun as rr
rr.init("rerun_example_arrows3d_row_updates", spawn=True)
# Prepare a fixed sequence of arrows over 5 timesteps.
# Origins stay constant, vectors change magnitude and direction, and each
# timestep has a unique color.
times = np.arange(10, 15, 1.0)
# At each time step, all arrows maintain their origin.
origins = np.linspace((-1, -1, 0), (1, 1, 0), 5)
vectors = [np.linspace((-1, -1, 0), (1, 1, i), 5) for i in range(5)]
# At each timestep, all arrows share the same but changing color.
colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF]
for i in range(5):
rr.set_time("time", duration=10 + i)
rr.log(
"arrows",
rr.Arrows3D(vectors=vectors[i], origins=origins, colors=colors[i]),
)
which can be translated to the column-oriented send_columns API as such:
"""
Update a set of vectors over time, in a single operation.
This is semantically equivalent to the `arrows3d_row_updates` example,
albeit much faster.
"""
import numpy as np
import rerun as rr
rr.init("rerun_example_arrows3d_column_updates", spawn=True)
# Prepare a fixed sequence of arrows over 5 timesteps.
# Origins stay constant, vectors change magnitude and direction, and each
# timestep has a unique color.
times = np.arange(10, 15, 1.0)
# At each time step, all arrows maintain their origin.
origins = [np.linspace((-1, -1, 0), (1, 1, 0), 5)] * 5
vectors = [np.linspace((-1, -1, 0), (1, 1, i), 5) for i in range(5)]
# At each timestep, all arrows share the same but changing color.
colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF, 0xFFFF00FF, 0x00FFFFFF]
rr.send_columns(
"arrows",
indexes=[rr.TimeColumn("time", duration=times)],
columns=[
*rr.Arrows3D.columns(origins=origins, vectors=vectors, colors=colors)
],
)
Updating a transform over time, in a single operation
Consider this snippet, using the row-oriented log API:
"""
Update a transform over time.
See also the `transform3d_column_updates` example, which achieves the same
thing in a single operation.
"""
import math
import rerun as rr
def truncated_radians(deg: float) -> float:
return float(int(math.radians(deg) * 1000.0)) / 1000.0
rr.init("rerun_example_transform3d_row_updates", spawn=True)
rr.set_time("tick", sequence=0)
rr.log(
"box",
rr.Boxes3D(
half_sizes=[4.0, 2.0, 1.0], fill_mode=rr.components.FillMode.Solid
),
rr.TransformAxes3D(10.0),
)
for t in range(100):
rr.set_time("tick", sequence=t + 1)
rr.log(
"box",
rr.Transform3D(
translation=[0, 0, t / 10.0],
rotation_axis_angle=rr.RotationAxisAngle(
axis=[0.0, 1.0, 0.0], radians=truncated_radians(t * 4)
),
),
)
which can be translated to the column-oriented send_columns API as such:
"""
Update a transform over time, in a single operation.
This is semantically equivalent to the `transform3d_row_updates` example,
albeit much faster.
"""
import math
import rerun as rr
def truncated_radians(deg: float) -> float:
return float(int(math.radians(deg) * 1000.0)) / 1000.0
rr.init("rerun_example_transform3d_column_updates", spawn=True)
rr.set_time("tick", sequence=0)
rr.log(
"box",
rr.Boxes3D(
half_sizes=[4.0, 2.0, 1.0], fill_mode=rr.components.FillMode.Solid
),
rr.TransformAxes3D(10.0),
)
rr.send_columns(
"box",
indexes=[rr.TimeColumn("tick", sequence=range(1, 101))],
columns=rr.Transform3D.columns(
translation=[[0, 0, t / 10.0] for t in range(100)],
rotation_axis_angle=[
rr.RotationAxisAngle(
axis=[0.0, 1.0, 0.0], radians=truncated_radians(t * 4)
)
for t in range(100)
],
),
)
Updating an image over time, in a single operation
Consider this snippet, using the row-oriented log API:
"""
Update an image over time.
See also the `image_column_updates` example, which achieves the same
thing in a single operation.
"""
import numpy as np
import rerun as rr
rr.init("rerun_example_image_row_updates", spawn=True)
for t in range(20):
rr.set_time("time", sequence=t)
image = np.zeros((200, 300, 3), dtype=np.uint8)
image[:, :, 2] = 255
image[50:150, (t * 10) : (t * 10 + 100)] = (0, 255, 255)
rr.log("image", rr.Image(image))
which can be translated to the column-oriented send_columns API as such:
"""
Update an image over time, in a single operation.
This is semantically equivalent to the `image_row_updates` example,
albeit much faster.
"""
import numpy as np
import rerun as rr
rr.init("rerun_example_image_column_updates", spawn=True)
# Timeline on which the images are distributed.
times = np.arange(0, 20)
# Create a batch of images with a moving rectangle.
width, height = 300, 200
images = np.zeros((len(times), height, width, 3), dtype=np.uint8)
images[:, :, :, 2] = 255
for t in times:
images[t, 50:150, (t * 10) : (t * 10 + 100), 1] = 255
# Log the ImageFormat and indicator once, as static.
format = rr.components.ImageFormat(
width=width, height=height, color_model="RGB", channel_datatype="U8"
)
rr.log("images", rr.Image.from_fields(format=format), static=True)
# Send all images at once.
rr.send_columns(
"images",
indexes=[rr.TimeColumn("step", sequence=times)],
# Reshape the images so `Image` can tell that this is several blobs.
#
# Note that the `Image` consumes arrays of bytes, so we should ensure
# that we take a uint8 view of it. This way, this also works when
# working with datatypes other than `U8`.
columns=rr.Image.columns(
buffer=images.view(np.uint8).reshape(len(times), -1)
),
)
Updating custom user-defined values over time, in a single operation
User-defined data can also benefit from the column-oriented APIs.
Consider this snippet, using the row-oriented log API:
"""
Update custom user-defined values over time.
See also the `any_values_column_updates` example, which achieves the same
thing in a single operation.
"""
from __future__ import annotations
import math
import rerun as rr
rr.init("rerun_example_any_values_row_updates", spawn=True)
for step in range(64):
rr.set_time("step", sequence=step)
rr.log(
"/", rr.AnyValues(sin=math.sin(step / 10.0), cos=math.cos(step / 10.0))
)
which can be translated to the column-oriented send_columns API as such:
"""
Update custom user-defined values over time, in a single operation.
This is semantically equivalent to the `any_values_row_updates` example,
albeit much faster.
"""
from __future__ import annotations
import numpy as np
import rerun as rr
rr.init("rerun_example_any_values_column_updates", spawn=True)
timestamps = np.arange(0, 64)
rr.send_columns(
"/",
indexes=[rr.TimeColumn("step", sequence=timestamps)],
columns=rr.AnyValues.columns(
sin=np.sin(timestamps / 10.0), cos=np.cos(timestamps / 10.0)
),
)
Send partial updates over time
Rerun allows you to log only the data that has changed in-between frames (or whatever atomic unit your timeline is using), i.e. you can think of this as a sort of diffs or delta encodings.
This is a natural consequence of how Rerun ingests, stores and finally queries data: every log call is a partial update. Consider this simple snippet:
"""Log some very simple points."""
import rerun as rr
rr.init("rerun_example_points3d", spawn=True)
rr.log("points", rr.Points3D([[0, 0, 0], [1, 1, 1]]))
Here, only the positions of the points have been specified but, looking at the complete definition for Points3D, we can see that it has quite a few more components available:
Required:
Position3DRecommended & Optional:
Radius,Color,Text,ShowLabels,PointShading,ClassId,KeypointId
Log only what changed
The SDK does not deduplicate: if you log the same value again, it is stored again. To save bandwidth and memory, skip values that did not change yourself. The Viewer uses latest-at semantics: each component keeps its last logged value until you log a new one, so values you skip carry forward.
if not np.array_equal(colors, last_colors):
rr.log("points", rr.Points3D.from_fields(colors=colors))
last_colors = colors.copy() # Copy, in case `colors` is updated in place.
rr.log("points", rr.Points3D.from_fields(positions=positions))The Python, Rust, and C++ SDKs all let you choose which components of an archetype are logged, and when, as the examples below show.
Partial update examples
Update specific properties of a point cloud over time
"""Update specific properties of a point cloud over time."""
import rerun as rr
rr.init("rerun_example_points3d_partial_updates", spawn=True)
positions = [[i, 0, 0] for i in range(10)]
rr.set_time("frame", sequence=0)
rr.log("points", rr.Points3D(positions))
for i in range(10):
colors = [[20, 200, 20] if n < i else [200, 20, 20] for n in range(10)]
radii = [0.6 if n < i else 0.2 for n in range(10)]
# Update only the colors and radii, leaving everything else as-is.
rr.set_time("frame", sequence=i)
rr.log("points", rr.Points3D.from_fields(radii=radii, colors=colors))
# Update the positions and radii, and clear everything else in the process.
rr.set_time("frame", sequence=20)
rr.log(
"points",
rr.Points3D.from_fields(clear_unset=True, positions=positions, radii=0.3),
)
Update specific properties of a transform over time
"""Update specific properties of a transform over time."""
import math
import rerun as rr
def truncated_radians(deg: float) -> float:
return float(int(math.radians(deg) * 1000.0)) / 1000.0
rr.init("rerun_example_transform3d_partial_updates", spawn=True)
# Set up a 3D box.
rr.log(
"box",
rr.Boxes3D(
half_sizes=[4.0, 2.0, 1.0], fill_mode=rr.components.FillMode.Solid
),
)
# Update only the rotation of the box.
for deg in range(46):
rad = truncated_radians(deg * 4)
rr.log(
"box",
rr.Transform3D.from_fields(
rotation_axis_angle=rr.RotationAxisAngle(
axis=[0.0, 1.0, 0.0], radians=rad
),
),
)
# Update only the position of the box.
for t in range(51):
rr.log(
"box",
rr.Transform3D.from_fields(translation=[0, 0, t / 10.0]),
)
# Update only the rotation of the box.
for deg in range(46):
rad = truncated_radians((deg + 45) * 4)
rr.log(
"box",
rr.Transform3D.from_fields(
rotation_axis_angle=rr.RotationAxisAngle(
axis=[0.0, 1.0, 0.0], radians=rad
),
),
)
# Clear all of the box's attributes.
rr.log(
"box",
rr.Transform3D.from_fields(clear_unset=True),
)
Update specific parts of a 3D mesh over time
"""Log a colored triangle, then update its vertices' positions each frame."""
import numpy as np
import rerun as rr
rr.init("rerun_example_mesh3d_partial_updates", spawn=True)
vertex_positions = np.array(
[[-1.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], dtype=np.float32
)
# Log the initial state of our triangle
rr.set_time("frame", sequence=0)
rr.log(
"triangle",
rr.Mesh3D(
vertex_positions=vertex_positions,
vertex_normals=[0.0, 0.0, 1.0],
vertex_colors=[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
),
)
# Only update its vertices' positions each frame:
for i in range(1, 300):
factor = np.abs(np.sin(i * 0.04))
rr.set_time("frame", sequence=i)
rr.log(
"triangle",
rr.Mesh3D.from_fields(vertex_positions=vertex_positions * factor),
)
Send dataframes to a recording
If your data is already in a table, you can log the whole table in a single call instead of logging it row by row or column by column.
In Python, rr.send_dataframe logs a table into the active recording, so it's saved with the rest of your data and can be shown next to your other views.
It accepts:
- a pyarrow
Table,RecordBatch, orRecordBatchReader, - a datafusion
DataFrame, - any other object that implements the Arrow C stream interface (
__arrow_c_stream__). Recent versions of pandas and polars implement it, so you can pass their dataframes directly. With older versions, convert first, e.g. withpa.Table.from_pandas(df)ordf.to_arrow()(polars).
Pass the timeline columns as index and the desired entity path for the remaining columns as entity_path:
"""Log an entire table, in a single operation."""
from __future__ import annotations
import numpy as np
import pandas as pd
import rerun as rr
rr.init("rerun_example_send_dataframe", spawn=True)
steps = np.arange(0, 64)
df = pd.DataFrame({
"step": steps,
"sin": np.sin(steps / 10.0),
"cos": np.cos(steps / 10.0),
})
rr.send_dataframe(df, index="step", entity_path="/trig")
Each remaining column becomes a component of that entity, which you can display in a DataframeView.
Like send_columns, this ignores any timeline values set with rr.set_time and bypasses the micro-batcher: only the timelines in the table are added.
To control component types or spread columns across several entities, see Chunks.
Dataframe reference
Send tables to Rerun
This section shows how to send tabular data (dataframes encoded as Arrow record batches) to the Rerun Viewer, where you can view and interact with it.
These tables are listed in the Sources panel, next to your recordings.
To persist a table on a Rerun DB server instead, see Catalog tables.
To log a table as part of a recording, use rr.send_dataframe.
Overview
The send_table API sends tabular data to the Rerun Viewer.
This is useful for:
- Debugging data processing pipelines
- Presenting structured data in a readable format
- Sorting and filtering tables interactively
Prerequisites
- Rerun SDK (Python)
- PyArrow library
- Pandas
- NumPy
Which can be installed via:
pip install rerun-sdk[notebook] pyarrow pandas numpyBasic usage
Connecting to the Viewer
from rerun.experimental import ViewerClient
# Connect to a running Rerun Viewer
client = ViewerClient.connect(url="rerun+http://127.0.0.1:9876/proxy")Sending a simple table
import pyarrow as pa
# Create a record batch from a Python dictionary
record_batch = pa.RecordBatch.from_pydict({
"id": [1, 2, 3],
"url": [
"https://www.rerun.io",
"https://github.com/rerun-io/rerun",
"https://crates.io/crates/rerun",
],
})
# Send the table to the viewer with an identifier
client.send_table("My Table", record_batch)Using with Pandas dataframes
You can also send Pandas dataframes by converting them to a record batch:
import numpy as np
import pandas as pd
# Create a sample DataFrame
dates = pd.date_range("20230101", periods=6)
df = pd.DataFrame(
np.random.default_rng(0).standard_normal((6, 4)),
index=dates,
columns=list("ABCD"),
)
# Convert to record batch and send to the viewer.
client.send_table("Pandas DataFrame", pa.RecordBatch.from_pandas(df))Using in Jupyter notebooks
Rerun provides special support for Jupyter notebooks, see Embed Rerun in notebooks.
Note that this API makes use of rr.notebook.Viewer:
import os
import pyarrow as pa
import rerun as rr
# Embed the widget JavaScript directly in the notebook instead of fetching it from app.rerun.io
os.environ["RERUN_NOTEBOOK_ASSET"] = "inline"
# Create and display the viewer
viewer = rr.notebook.Viewer(width="auto", height="auto")
viewer.display()
# Send table directly to the inline viewer
viewer.send_table(
"My Table",
pa.RecordBatch.from_pydict({"Column A": [1, 2, 3], "Column B": ["https://www.rerun.io", "Hello", "World"]}),
)Current limitations
As this is an experimental API, there are several limitations to be aware of:
- Multiple record batches (or a DataFusion DataFrame) can be passed, but they are merged into a single record batch before sending
- Tables can't be saved to or loaded from files (unlike
.rrdfiles for recordings) - Only the Python SDK can send tables; the Rust and C++ SDKs cannot
Table references
For complete examples of using send_table, please refer to:
Send custom data
Rerun comes with many pre-built Types that you can use out of the box. As long as your own data can be decomposed into Rerun components or can be serialized with Apache Arrow, you can log it directly without needing to recompile Rerun.
For Python and Rust we have helpers for this, called AnyValues, allowing you to easily attach custom values to any entity.
For C++ a similar thing can be accomplished without the helpers.
You find the documentation for these helpers here:
"""Log arbitrary data."""
import rerun as rr
rr.init("rerun_example_any_values", spawn=True)
rr.log(
"any_values",
rr
.AnyValues(
# Using arbitrary Arrow data.
homepage="https://www.rerun.io",
repository="https://github.com/rerun-io/rerun",
)
# Using Rerun's builtin components.
.with_component_override(
"confidence", rr.components.ScalarBatch._COMPONENT_TYPE, [1.2, 3.4, 5.6]
)
.with_component_override(
"description", rr.components.TextBatch._COMPONENT_TYPE, "Bla bla bla…"
),
)
If your values should be grouped together and that grouping isn't referred to from many places that need to stay aligned we have a helper for this called DynamicArchetype, which adds some structural grouping to multiple values.
DynamicArchetype stores the values under an archetype name of your choice.
The confidence field of MyArchetype becomes the column MyArchetype:confidence.
AnyValues stores no archetype name, so the same field becomes the column confidence.
You find the documentation for these helpers here:
"""Log arbitrary archetype data."""
import rerun as rr
rr.init("rerun_example_dynamic_archetype", spawn=True)
rr.log(
"new_archetype",
rr
.DynamicArchetype(
archetype="MyArchetype",
components={
# Using arbitrary Arrow data.
"homepage": "https://www.rerun.io",
"repository": "https://github.com/rerun-io/rerun",
},
)
# Using Rerun's builtin components.
.with_component_override(
"confidence", rr.components.ScalarBatch._COMPONENT_TYPE, [1.2, 3.4, 5.6]
)
.with_component_override(
"description", rr.components.TextBatch._COMPONENT_TYPE, "Bla bla bla…"
),
)
You can also make your own type loggable by implementing the AsComponents Python protocol or Rust trait, which means implementing the function, as_component_batches().
Logging custom data
Use DynamicArchetype to send data with custom component names alongside regular Rerun data.
Flat arrays and Arrow StructArrays are both supported.
The example below logs scalar and nested data to an entity named /plot.
This is how its components appear in the Viewer:
# Custom scalar batch with a cos using a custom component name.
*rr.DynamicArchetype.columns(
archetype="custom",
components={"my_custom_scalar": np.cos(times / 10.0)},
),
# Nested custom scalar batch with a sigmoid inside a struct.
*rr.DynamicArchetype.columns(
archetype="custom",
components={"my_nested_scalar": make_sigmoid_struct_array(64)},
),Remapping to a Rerun archetype
Let's start with a simple example where you have your own point cloud class that is perfectly representable as a Rerun archetype.
@dataclass
class LabeledPoints:
points: np.ndarray
labels: list[str]If you implement as_component_batches() on LabeledPoints, you can pass it directly to rr.log. The simplest possible way is to use the matching Rerun archetype’s as_component_batches method.
import rerun as rr # pip install rerun-sdk
@dataclass
class LabeledPoints:
points: np.ndarray
labels: list[str]
def as_component_batches(self) -> list[rr.DescribedComponentBatch]:
return rr.Points3D(
positions=self.points, labels=self.labels
).as_component_batches()
Then pass it to rr.log like any archetype:
# Somewhere deep in your code
classified = my_points_classifier()
rr.log("points/classified", classified)Custom archetypes and components
You can also define and log your own custom archetypes and components completely from user code, without rebuilding Rerun.
In this example we extend the Rerun Points3D archetype with a custom confidence component and user-defined archetype.
This is what it looks like in the dataframe view:
"""Shows how to implement custom archetypes and components."""
from __future__ import annotations
import argparse
from typing import Any
import numpy as np
import numpy.typing as npt
import pyarrow as pa
import rerun as rr
class ConfidenceBatch(rr.ComponentBatchMixin): # type: ignore[misc]
"""A batch of confidence data."""
def __init__(self: Any, confidence: npt.ArrayLike) -> None:
self.confidence = confidence
def as_arrow_array(self) -> pa.Array:
"""The arrow batch representing the custom component."""
return pa.array(self.confidence, type=pa.float32())
class CustomPoints3D(rr.AsComponents): # type: ignore[misc]
"""A custom archetype extending the builtin `Points3D` with extra data."""
def __init__(
self: Any, positions: npt.ArrayLike, confidences: npt.ArrayLike
) -> None:
self.points3d = rr.Points3D(positions)
self.confidences = ConfidenceBatch(confidences).described(
rr.ComponentDescriptor(
"user.CustomPoints3D:confidences",
archetype="user.CustomPoints3D",
component_type="user.Confidence",
)
)
def as_component_batches(self) -> list[rr.DescribedComponentBatch]:
return [
# The components from Points3D
*self.points3d.as_component_batches(),
# Custom confidence data
self.confidences,
]
def log_custom_data() -> None:
lin = np.linspace(-5, 5, 3)
z, y, x = np.meshgrid(lin, lin, lin, indexing="ij")
point_grid = np.vstack([x.flatten(), y.flatten(), z.flatten()]).T
rr.log(
"left/my_confident_point_cloud",
CustomPoints3D(
positions=point_grid,
confidences=[42],
),
)
rr.log(
"right/my_polarized_point_cloud",
CustomPoints3D(
positions=point_grid, confidences=np.arange(0, len(point_grid))
),
)
def main() -> None:
parser = argparse.ArgumentParser(
description="Logs rich data using the Rerun SDK."
)
rr.script_add_args(parser)
args = parser.parse_args()
rr.script_setup(args, "rerun_example_custom_data")
log_custom_data()
rr.script_teardown(args)
if __name__ == "__main__":
main()
The point clouds still show up in a 3D view, because CustomPoints3D also logs the components of the built-in Points3D.
Creating/augmenting visualizations from custom data
All components can be mapped to arbitrary slots of visualizers. For general information on component mapping see component mappings, for the common case of plotting see plot any scalar
Log custom C++ types without copying
In C++, every archetype field takes a rerun::Collection.
A collection either borrows your data (no copy) or owns it (a copy in an internal std::vector).
Borrowed vs owned data
- Borrowed: the collection only stores a pointer and a length.
The data must stay alive and unchanged for as long as the collection (or the archetype that holds it) exists.
When you create the archetype inside the
logcall, this means untillogreturns. - Owned: the data is moved or copied into the collection, so it can outlive your source.
The built-in adapters follow this rule for std::vector<T> of a Rerun type:
an lvalue is borrowed, a temporary (or std::moved vector) is owned.
Containers of other types are converted with a copy.
std::vector<rerun::Position3D> points = make_points();
rec.log("borrowed", rerun::Points3D(points)); // No copy: `points` outlives the call.
rec.log("owned", rerun::Points3D(std::move(points))); // Moved into the collection.You can also be explicit with rerun::Collection<T>::borrow(ptr, count) (or the shorthand rerun::borrow(ptr, count)) and rerun::Collection<T>::take_ownership(std::move(vec)).
OpenCV images
Borrow the pixel buffer of a cv::Mat directly:
cv::Mat img = cv::imread("image.png", cv::IMREAD_COLOR); // 8-bit BGR
rec.log(
"image",
rerun::Image(
rerun::borrow(img.data, img.total() * img.elemSize()),
rerun::WidthHeight(static_cast<uint32_t>(img.cols), static_cast<uint32_t>(img.rows)),
rerun::ColorModel::BGR
)
);The cv::Mat must be continuous in memory (img.isContinuous()).
Clone it first if it is a view into a larger image.
Eigen
Eigen::Vector3f has the same memory layout as rerun::Position3D (three floats), so you can borrow it.
A 3×N column-major Eigen::Matrix3Xf stores its points the same way:
Eigen::Matrix3Xf points = …; // One point per column.
rec.log(
"points",
rerun::Points3D(rerun::Collection<rerun::Position3D>::borrow(
static_cast<const void*>(points.data()),
static_cast<size_t>(points.cols())
))
);The void* overload skips the compile-time layout checks, so only use it when you know the layout matches.
For transforms, rerun::Vec3D and rerun::Mat3x3 (column-major, like Eigen) can be built from a pointer:
Eigen::Vector3f translation = …;
Eigen::Matrix3f rotation = …;
rec.log("camera", rerun::Transform3D(rerun::Vec3D(translation.data()), rerun::Mat3x3(rotation.data())));Your own types: CollectionAdapter
To log your own container type directly, specialize rerun::CollectionAdapter<TElement, TContainer>.
Borrow when the input is an lvalue, and copy when it is a temporary:
template <>
struct rerun::CollectionAdapter<rerun::Position3D, MyContainer<MyVec3>> {
// Non-temporary: borrow binary-compatible data, no copy.
Collection<rerun::Position3D> operator()(const MyContainer<MyVec3>& container) {
return Collection<rerun::Position3D>::borrow(container.data, container.size);
}
// Temporary: the pointer would dangle, so copy.
Collection<rerun::Position3D> operator()(MyContainer<MyVec3>&& container) {
std::vector<rerun::Position3D> components(container.size);
for (size_t i = 0; i < container.size; ++i) {
components[i] = rerun::Position3D(container.data[i].x, container.data[i].y, container.data[i].z);
}
return Collection<rerun::Position3D>::take_ownership(std::move(components));
}
};
// Now this works:
rec.log("my_points", rerun::Points3D(my_points));Always implement the && overload.
Without it, a temporary can bind to the const& overload, and the collection borrows memory that is freed before it is used.
Collection::borrow(const T*, …) checks at compile time that T has the same size as the Rerun type and no stricter alignment.
C++ type adapter examples
Clear out data using tombstones
In order to create coherent views of streaming data, the Rerun Viewer shows the latest values for each visible entity at the current timepoint. But some data may not be valid for the entire recording even if there are no updated values. This section shows how to tell Rerun that something you've logged should no longer be shown.
Log entities as cleared
The most straight forward option is to explicitly log that an entity has been cleared. Rerun allows you to do this by logging a special Clear to any path. The timepoint at which the Clear is logged is the time point after which that entity will no longer be visible in your views.
For example, if you have an object tracking application, your code might look something like this:
for frame in sensors.read():
# Associate the following logs with `frame == frame.id`
rr.set_time("frame", sequence=frame.id)
# Do the actual tracking update
tracker.update(frame)
if tracker.is_lost:
# Clear everything on `tracked/{tracker.id}` and its child entity
# that happened on or before `frame == frame.id`
rr.log(f"tracked/{tracker.id}", rr.Clear())
rr.log(f"tracked/{tracker.id}/cm", rr.Clear())
else:
# Log data to the main entity and a child entity
rr.log(
f"tracked/{tracker.id}",
rr.Boxes2D(array=tracker.bounds, array_format=rr.Box2DFormat.XYXY),
)
rr.log(f"tracked/{tracker.id}/cm", rr.Points2D(tracker.cm))Clarify data meaning
In some cases, the best approach may be to rethink how you log data to better express what is actually happening. Take the following example where update frequencies don't match:
for frame in sensors.read():
# Associate the following logs with `frame = frame.id`
rr.set_time("frame", sequence=frame.id)
# Log every image that comes in
rr.log("input/image", rr.Image(frame.image))
if frame.id % 10 == 0:
# Run detection every 10 frames
detection = detector.detect(frame)
# Woops! These detections will not update at the
# same frequency as the input data and thus look strange
rr.log(
"input/detections",
rr.Boxes2D(
array=detection.bounds, array_format=rr.Box2DFormat.XYXY
),
)You could fix this example by logging rr.Clear, but in this case it makes more sense to change what you log to better express what is happening. Re-logging the image to another namespace on only the frames where the detection runs makes it explicit which frame was used as the input to the detector. This will create a second view in the Viewer that always allows you to see the frame that was used for the current detection input.
Here is an example fix, where DetectorModel stands in for your detection model:
class Detector(DetectorModel):
def detect(self, frame: Frame) -> Detection:
downscaled = self.downscale(frame.image)
# Log the downscaled image, with the detections as a child entity
rr.log("detections/source", rr.Image(downscaled))
result = self.model(downscaled)
detection = self.post_process(result)
# Log the detections together with the downscaled image
# Image and detections will update at the same frequency
rr.log(
"detections/source/boxes",
rr.Boxes2D(
array=detection.bounds, array_format=rr.Box2DFormat.XYXY
),
)
return detection
detector = Detector()
for frame in sensors.read():
# Associate the following logs with `frame = frame.id`
rr.set_time("frame", sequence=frame.id)
# Log every image that comes in
rr.log("input/image", rr.Image(frame.image))
if frame.id % 10 == 0:
# Run detection every 10 frames
# Logging of detections now happens inside the detector
detected = detector.detect(frame)Log data with spans instead of timepoints
In some cases you already know how long a piece of data will be valid at the time of logging.
Rerun does not support associating logged data with spans like (from_timepoint, to_timepoint) or (timepoint, time-to-live) (#3008).
Workaround by manually clearing entities
The workaround is to manually clear data when it is no longer valid.
# Associate the following data with `start_time` on the `time` timeline
rr.set_time("time", duration=start_time)
# Log the data as usual
rr.log("short_lived", rr.Tensor(one_second_tensor))
# Associate the following clear with `start_time + 1.0` on the `time` timeline
rr.set_time("time", duration=start_time + 1.0)
rr.log("short_lived", rr.Clear())
# Set the time back so other data isn't accidentally logged in the future.
rr.set_time("time", duration=start_time)Deleting data
A Clear does not delete anything.
It is a tombstone: new data that hides older data from that time on.
The cleared data stays in the recording, can still be seen at earlier times, and still uses memory.
There is no API to delete the data of a single entity from a recording. Instead, you can:
Close a whole recording in the Viewer, from the Sources panel. From code, use the experimental
rerun.experimental.ViewerClient.close(…)on a running Viewer, e.g.ViewerClient.connect().close("current").Drop entities from a file with the Rerun CLI:
rerun rrd filter --drop-entity /camera/raw input.rrd > output.rrdLimit memory use of the Viewer with
--memory-limit: when the limit is reached, the Viewer drops the oldest data.







