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

Archetype: A state change, representing a transition of an entity into a new state. More...

#include <rerun/archetypes/state_change.hpp>

Public Member Functions

 StateChange (StateChange &&other)=default
 
 StateChange (const StateChange &other)=default
 
StateChangeoperator= (const StateChange &other)=default
 
StateChangeoperator= (StateChange &&other)=default
 
StateChange with_state (const Collection< rerun::components::Text > &_state) &&
 The new state values; each instance gets its own lane in the state timeline view.
 
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 StateChange update_fields ()
 Update only some specific fields of a StateChange.
 
static StateChange clear_fields ()
 Clear all the fields of a StateChange.
 

Public Attributes

std::optional< ComponentBatchstate
 The new state values; each instance gets its own lane in the state timeline view.
 

Static Public Attributes

static constexpr const char ArchetypeName [] = "rerun.archetypes.StateChange"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_state
 ComponentDescriptor for the state field.
 

Detailed Description

Archetype: A state change, representing a transition of an entity into a new state.

Useful for representing discrete state machines, mode transitions, or state changes over time. Each logged archetypes::StateChange marks a new state at the given time. A null state resets the state, showing a gap in the state timeline view.

The state timeline view displays these as horizontal colored lanes over time.

Example

State changes over time

image

#include <rerun.hpp>
int main(int argc, char* argv[]) {
const auto rec = rerun::RecordingStream("rerun_example_state_change");
rec.spawn().exit_on_failure();
rec.set_time_sequence("step", 0);
rec.log("door", rerun::StateChange().with_state({"open"}));
rec.set_time_sequence("step", 1);
rec.log("door", rerun::StateChange().with_state({"closed"}));
rec.set_time_sequence("step", 2);
rec.log("door", rerun::StateChange().with_state({"open"}));
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:73
Archetype: A state change, representing a transition of an entity into a new state.
Definition state_change.hpp:48
StateChange with_state(const Collection< rerun::components::Text > &_state) &&
The new state values; each instance gets its own lane in the state timeline view.
Definition state_change.hpp:89

Member Function Documentation

◆ with_state()

StateChange rerun::archetypes::StateChange::with_state ( const Collection< rerun::components::Text > &  _state) &&
inline

The new state values; each instance gets its own lane in the state timeline view.

A reset ends the previous state and shows a gap in the state timeline view until the next state. An empty string, a null array entry, and an empty state array (e.g. from clearing the field) all act as resets.

The length of the state array should not change over time.

◆ columns() [1/2]

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

◆ state

std::optional<ComponentBatch> rerun::archetypes::StateChange::state

The new state values; each instance gets its own lane in the state timeline view.

A reset ends the previous state and shows a gap in the state timeline view until the next state. An empty string, a null array entry, and an empty state array (e.g. from clearing the field) all act as resets.

The length of the state array should not change over time.

◆ Descriptor_state

constexpr auto rerun::archetypes::StateChange::Descriptor_state
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "StateChange:state", Loggable<rerun::components::Text>::ComponentType
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition state_change.hpp:60

ComponentDescriptor for the state field.


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