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

Archetype: One or more double-precision scalar values, e.g. More...

#include <rerun/archetypes/scalars.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

 Scalars (Scalars &&other)=default
 
 Scalars (const Scalars &other)=default
 
Scalarsoperator= (const Scalars &other)=default
 
Scalarsoperator= (Scalars &&other)=default
 
 Scalars (Collection< rerun::components::Scalar > _scalars)
 
Scalars with_scalars (const Collection< rerun::components::Scalar > &_scalars) &&
 The scalar values to log.
 
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 Scalars update_fields ()
 Update only some specific fields of a Scalars.
 
static Scalars clear_fields ()
 Clear all the fields of a Scalars.
 

Public Attributes

std::optional< ComponentBatchscalars
 The scalar values to log.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.ScalarsIndicator"
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.Scalars"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_scalars
 ComponentDescriptor for the scalars field.
 

Detailed Description

Archetype: One or more double-precision scalar values, e.g.

for use for time-series plots.

The current timeline value will be used for the time/X-axis, hence scalars should not be static. Number of scalars per timestamp is expected to be the same over time.

When used to produce a plot, this archetype is used to provide the data that is referenced by archetypes::SeriesLines or archetypes::SeriesPoints. 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::Scalars(sin(static_cast<double>(step) / 10.0)));
}
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60
Archetype: One or more double-precision scalar values, e.g.
Definition scalars.hpp:81

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::Scalars(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 column from an array of sequence points, e.g.
Definition time_column.hpp:92
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.

Member Function Documentation

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::Scalars::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::Scalars::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_scalars

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

ComponentDescriptor for the scalars field.


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