diff --git a/crates/store/re_types/definitions/rerun/archetypes/points3d.fbs b/crates/store/re_types/definitions/rerun/archetypes/points3d.fbs index adff5311aa23..4e7798ae759e 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/points3d.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/points3d.fbs @@ -7,7 +7,7 @@ namespace rerun.archetypes; /// \example archetypes/points3d_simple !api title="Simple 3D points" image="https://static.rerun.io/point3d_simple/32fb3e9b65bea8bd7ffff95ad839f2f8a157a933/1200w.png" /// \example archetypes/points3d_random title="Randomly distributed 3D points with varying color and radius" image="https://static.rerun.io/point3d_random/7e94e1806d2c381943748abbb3bedb68d564de24/1200w.png" /// \example archetypes/points3d_ui_radius title="Log points with radii given in UI points" image="https://static.rerun.io/point3d_ui_radius/e051a65b4317438bcaea8d0eee016ac9460b5336/1200w.png" -/// \example archetypes/points3d_send_columns title="Send several point clouds with varying point count over time in a single call" image="https://static.rerun.io/points3d_send_columns/633b524a2ee439b0e3afc3f894f4927ce938a3ec/1200w.png" missing="rs" +/// \example archetypes/points3d_send_columns title="Send several point clouds with varying point count over time in a single call" image="https://static.rerun.io/points3d_send_columns/633b524a2ee439b0e3afc3f894f4927ce938a3ec/1200w.png" table Points3D ( "attr.rust.archetype_eager", "attr.cpp.archetype_eager", diff --git a/crates/store/re_types/definitions/rerun/archetypes/scalar.fbs b/crates/store/re_types/definitions/rerun/archetypes/scalar.fbs index 773a3a8a7331..f57edda42f2c 100644 --- a/crates/store/re_types/definitions/rerun/archetypes/scalar.fbs +++ b/crates/store/re_types/definitions/rerun/archetypes/scalar.fbs @@ -14,7 +14,7 @@ namespace rerun.archetypes; /// /// \example archetypes/scalar_simple title="Simple line plot" image="https://static.rerun.io/scalar_simple/8bcc92f56268739f8cd24d60d1fe72a655f62a46/1200w.png" /// \example archetypes/scalar_multiple_plots !api title="Multiple time series plots" image="https://static.rerun.io/scalar_multiple/15845c2a348f875248fbd694e03eabd922741c4c/1200w.png" -/// \example archetypes/scalar_send_columns !api title="Multiple scalars in a single `send_columns` call" image="https://static.rerun.io/scalar_send_columns/b4bf172256f521f4851dfec5c2c6e3143f5d6923/1200w.png" +/// \example archetypes/scalar_send_columns title="Multiple scalars in a single `send_columns` call" image="https://static.rerun.io/scalar_send_columns/b4bf172256f521f4851dfec5c2c6e3143f5d6923/1200w.png" table Scalar ( "attr.rust.archetype_eager", "attr.rust.derive": "PartialEq", diff --git a/crates/store/re_types/src/archetypes/scalar.rs b/crates/store/re_types/src/archetypes/scalar.rs index bb1428137481..c3b501249029 100644 --- a/crates/store/re_types/src/archetypes/scalar.rs +++ b/crates/store/re_types/src/archetypes/scalar.rs @@ -28,7 +28,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// this by logging both archetypes to the same path, or alternatively configuring /// the plot-specific archetypes through the blueprint. /// -/// ## Example +/// ## Examples /// /// ### Simple line plot /// ```ignore @@ -53,6 +53,40 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// /// /// +/// +/// ### Multiple scalars in a single `send_columns` call +/// ```ignore +/// use rerun::TimeColumn; +/// +/// fn main() -> Result<(), Box> { +/// let rec = rerun::RecordingStreamBuilder::new("rerun_example_scalar_send_columns").spawn()?; +/// +/// const STEPS: i64 = 64; +/// +/// let times = TimeColumn::new_sequence("step", 0..STEPS); +/// let scalars = (0..STEPS).map(|step| (step as f64 / 10.0).sin()); +/// +/// rec.send_columns_v2( +/// "scalars", +/// [times], +/// rerun::Scalar::update_fields() +/// .with_many_scalar(scalars) +/// .columns(std::iter::repeat(1).take(STEPS as _))? +/// .filter(|column| !column.descriptor.component_name.contains("Indicator")), +/// )?; +/// +/// Ok(()) +/// } +/// ``` +///
+/// +/// +/// +/// +/// +/// +/// +///
#[derive(Clone, Debug, PartialEq, Default)] pub struct Scalar { /// The scalar value to log. diff --git a/docs/snippets/INDEX.md b/docs/snippets/INDEX.md index 65af664f70b8..b5ae0ae1352a 100644 --- a/docs/snippets/INDEX.md +++ b/docs/snippets/INDEX.md @@ -147,7 +147,7 @@ _All snippets, organized by the [`Archetype`](https://rerun.io/docs/reference/ty | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `tutorials/timelines_example` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/tutorials/timelines_example.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/tutorials/timelines_example.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/tutorials/timelines_example.cpp) | | **[`Points3D`](https://rerun.io/docs/reference/types/archetypes/points3d)** | `views/spatial3d` | Use a blueprint to customize a Spatial3DView | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/views/spatial3d.py) | | | | **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/scalar_simple` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.cpp) | -| **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/scalar_send_columns` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.cpp) | +| **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/scalar_send_columns` | Use the `send_columns` API to send scalars over time in a single call | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/scalar_multiple_plots` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/series_line_style` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/archetypes/scalar)** | `archetypes/series_point_style` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.cpp) | @@ -248,7 +248,7 @@ _All snippets, organized by the [`Component`](https://rerun.io/docs/reference/ty | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_partial_updates` | Log different transforms with visualized coordinates axes | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_partial_updates.cpp) | | **[`RotationAxisAngle`](https://rerun.io/docs/reference/types/components/rotation_axis_angle)** | `archetypes/transform3d_simple` | Log different transforms between three arrows | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/transform3d_simple.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_simple` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_simple.cpp) | -| **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_send_columns` | | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.cpp) | +| **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_send_columns` | Use the `send_columns` API to send scalars over time in a single call | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_send_columns.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/scalar_multiple_plots` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/scalar_multiple_plots.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/series_line_style` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_line_style.cpp) | | **[`Scalar`](https://rerun.io/docs/reference/types/components/scalar)** | `archetypes/series_point_style` | Log a scalar over time | [🐍](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.py) | [🦀](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.rs) | [🌊](https://github.com/rerun-io/rerun/blob/main/docs/snippets/all/archetypes/series_point_style.cpp) | diff --git a/docs/snippets/all/archetypes/scalar_send_columns.py b/docs/snippets/all/archetypes/scalar_send_columns.py index 275a59c1694f..ec2f51e9e0f0 100644 --- a/docs/snippets/all/archetypes/scalar_send_columns.py +++ b/docs/snippets/all/archetypes/scalar_send_columns.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """Use the `send_columns` API to send scalars over time in a single call.""" from __future__ import annotations diff --git a/rerun_cpp/src/rerun/archetypes/scalar.hpp b/rerun_cpp/src/rerun/archetypes/scalar.hpp index 0007155f1863..fd6ce443a45e 100644 --- a/rerun_cpp/src/rerun/archetypes/scalar.hpp +++ b/rerun_cpp/src/rerun/archetypes/scalar.hpp @@ -24,7 +24,7 @@ namespace rerun::archetypes { /// this by logging both archetypes to the same path, or alternatively configuring /// the plot-specific archetypes through the blueprint. /// - /// ## Example + /// ## Examples /// /// ### Simple line plot /// ![image](https://static.rerun.io/scalar_simple/8bcc92f56268739f8cd24d60d1fe72a655f62a46/full.png) @@ -45,6 +45,37 @@ namespace rerun::archetypes { /// } /// } /// ``` + /// + /// ### Multiple scalars in a single `send_columns` call + /// ![image](https://static.rerun.io/scalar_send_columns/b4bf172256f521f4851dfec5c2c6e3143f5d6923/full.png) + /// + /// ```cpp + /// #include + /// #include + /// #include + /// + /// #include + /// + /// int main() { + /// const auto rec = rerun::RecordingStream("rerun_example_scalar_send_columns"); + /// rec.spawn().exit_on_failure(); + /// + /// // Native scalars & times. + /// std::vector scalar_data(64); + /// for (size_t i = 0; i <64; ++i) { + /// scalar_data[i] = sin(static_cast(i) / 10.0); + /// } + /// std::vector times(64); + /// std::iota(times.begin(), times.end(), 0); + /// + /// // Convert to rerun time / scalars + /// auto time_column = rerun::TimeColumn::from_sequence_points("step", std::move(times)); + /// auto scalar_data_collection = + /// rerun::Collection(std::move(scalar_data)); + /// + /// rec.send_columns("scalars", time_column, scalar_data_collection); + /// } + /// ``` struct Scalar { /// The scalar value to log. rerun::components::Scalar scalar; diff --git a/rerun_py/rerun_sdk/rerun/archetypes/scalar.py b/rerun_py/rerun_sdk/rerun/archetypes/scalar.py index 903a53043511..379bc6d5daf3 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/scalar.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/scalar.py @@ -31,8 +31,8 @@ class Scalar(Archetype): this by logging both archetypes to the same path, or alternatively configuring the plot-specific archetypes through the blueprint. - Example - ------- + Examples + -------- ### Simple line plot: ```python import math @@ -56,6 +56,34 @@ class Scalar(Archetype): + ### Multiple scalars in a single `send_columns` call: + ```python + from __future__ import annotations + + import numpy as np + import rerun as rr + + rr.init("rerun_example_scalar_send_columns", spawn=True) + + times = np.arange(0, 64) + scalars = np.sin(times / 10.0) + + rr.send_columns( + "scalars", + times=[rr.TimeSequenceColumn("step", times)], + components=[rr.components.ScalarBatch(scalars)], + ) + ``` +
+ + + + + + + +
+ """ def __init__(self: Any, scalar: datatypes.Float64Like):