Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::Scalar Struct Reference

Archetype: A double-precision scalar, e.g. More...

#include <rerun/archetypes/scalar.hpp>

Public Types

using IndicatorComponent = rerun::components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 Scalar (Scalar &&other)=default
 
 Scalar (const Scalar &other)=default
 
Scalaroperator= (const Scalar &other)=default
 
Scalaroperator= (Scalar &&other)=default
 
 Scalar (rerun::components::Scalar _scalar)
 
Scalar with_scalar (const rerun::components::Scalar &_scalar) &&
 The scalar value to log.
 
Scalar with_many_scalar (const Collection< rerun::components::Scalar > &_scalar) &&
 This method makes it possible to pack multiple scalar in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static Scalar update_fields ()
 Update only some specific fields of a Scalar.
 
static Scalar clear_fields ()
 Clear all the fields of a Scalar.
 

Public Attributes

std::optional< ComponentBatchscalar
 The scalar value to log.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.ScalarIndicator"
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.Scalar"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_scalar
 ComponentDescriptor for the scalar field.
 

Detailed Description

Archetype: A double-precision scalar, e.g.

for use for time-series plots.

The current timeline value will be used for the time/X-axis, hence scalars cannot be static.

When used to produce a plot, this archetype is used to provide the data that is referenced by archetypes::SeriesLine or archetypes::SeriesPoint. You can do this by logging both archetypes to the same path, or alternatively configuring the plot-specific archetypes through the blueprint.

Examples

Update a scalar over time

image

#include <cmath>
#include <rerun.hpp>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_scalar_row_updates");
rec.spawn().exit_on_failure();
for (int step = 0; step <64; ++step) {
rec.set_time_sequence("step", step);
rec.log("scalars", rerun::Scalar(sin(static_cast<double>(step) / 10.0)));
}
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Archetype: A double-precision scalar, e.g.
Definition scalar.hpp:80

Update a scalar over time, in a single operation

image

#include <cmath>
#include <numeric>
#include <vector>
#include <rerun.hpp>
int main() {
const auto rec = rerun::RecordingStream("rerun_example_scalar_column_updates");
rec.spawn().exit_on_failure();
// Native scalars & times.
std::vector<double> scalar_data(64);
for (size_t i = 0; i <64; ++i) {
scalar_data[i] = sin(static_cast<double>(i) / 10.0);
}
std::vector<int64_t> times(64);
std::iota(times.begin(), times.end(), 0);
// Serialize to columns and send.
rec.send_columns(
"scalars",
rerun::TimeColumn::from_sequence("step", std::move(times)),
rerun::Scalar().with_many_scalar(std::move(scalar_data)).columns()
);
}
static TimeColumn from_sequence(std::string timeline_name, Collection< int64_t > sequence_points, SortingStatus sorting_status=SortingStatus::Unknown)
Creates a time column from an array of sequence points.
Definition time_column.hpp:92
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
Scalar with_many_scalar(const Collection< rerun::components::Scalar > &_scalar) &&
This method makes it possible to pack multiple scalar in a single component batch.
Definition scalar.hpp:126

Member Function Documentation

◆ with_many_scalar()

Scalar rerun::archetypes::Scalar::with_many_scalar ( const Collection< rerun::components::Scalar > &  _scalar) &&
inline

This method makes it possible to pack multiple scalar in a single component batch.

This only makes sense when used in conjunction with columns. with_scalar should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::Scalar::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::Scalar::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ Descriptor_scalar

constexpr auto rerun::archetypes::Scalar::Descriptor_scalar
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "scalar", Loggable<rerun::components::Scalar>::Descriptor.component_name
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition scalar.hpp:90

ComponentDescriptor for the scalar field.


The documentation for this struct was generated from the following file: