Rerun C++ SDK
Loading...
Searching...
No Matches
coordinate_frame.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/coordinate_frame.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/transform_frame_id.hpp"
10#include "../result.hpp"
11
12#include <cstdint>
13#include <optional>
14#include <utility>
15#include <vector>
16
17namespace rerun::archetypes {
18 /// **Archetype**: Specifies the coordinate frame for an entity.
19 ///
20 /// **Experimental:** Transform frames are still in early development!
21 ///
22 /// If not specified, the coordinate frame uses an implicit frame derived from the entity path.
23 /// The implicit frame's name is `tf#/your/entity/path` and has an identity transform connection to its parent path.
24 ///
25 /// To learn more about transforms see [Spaces & Transforms](https://rerun.io/docs/concepts/spaces-and-transforms) in the reference.
26 ///
27 /// ## Example
28 ///
29 /// ### Change coordinate frame to different built-in frames
30 /// ![image](https://static.rerun.io/coordinate_frame_builtin_frame/71f941f35cf73c299c6ea7fbc4487a140db8e8f8/full.png)
31 ///
32 /// ```cpp
33 /// #include <rerun.hpp>
34 ///
35 /// int main() {
36 /// const auto rec = rerun::RecordingStream("rerun_example_transform3d_hierarchy");
37 /// rec.spawn().exit_on_failure();
38 ///
39 /// rec.set_time_sequence("time", 0);
40 /// rec.log(
41 /// "red_box",
42 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
43 /// ).with_colors({rerun::Color(255, 0, 0)}),
44 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
45 /// rerun::Transform3D::from_translation({2.0f, 0.0f, 0.0f})
46 /// );
47 /// rec.log(
48 /// "blue_box",
49 /// rerun::Boxes3D::from_half_sizes({{0.5f, 0.5f, 0.5f}}
50 /// ).with_colors({rerun::Color(0, 0, 255)}),
51 /// // Use Transform3D to place the box, so we actually change the underlying coordinate frame and not just the box's pose.
52 /// rerun::Transform3D::from_translation({-2.0f, 0.0f, 0.0f})
53 /// );
54 /// rec.log("point", rerun::Points3D({{0.0f, 0.0f, 0.0f}}).with_radii({0.5f}));
55 ///
56 /// // Change where the point is located by cycling through its coordinate frame.
57 /// const char* frame_ids[] = {"tf#/red_box", "tf#/blue_box"};
58 /// for (int t = 0; t <2; t++) {
59 /// rec.set_time_sequence("time", t + 1); // leave it untouched at t==0.
60 /// rec.log("point", rerun::CoordinateFrame(frame_ids[t]));
61 /// }
62 /// }
63 /// ```
64 ///
65 /// ⚠ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
66 ///
68 /// The coordinate frame to use for the current entity.
69 std::optional<ComponentBatch> frame_id;
70
71 public:
72 /// The name of the archetype as used in `ComponentDescriptor`s.
73 static constexpr const char ArchetypeName[] = "rerun.archetypes.CoordinateFrame";
74
75 /// `ComponentDescriptor` for the `frame_id` field.
77 ArchetypeName, "CoordinateFrame:frame_id",
79 );
80
81 public:
82 CoordinateFrame() = default;
83 CoordinateFrame(CoordinateFrame&& other) = default;
84 CoordinateFrame(const CoordinateFrame& other) = default;
85 CoordinateFrame& operator=(const CoordinateFrame& other) = default;
86 CoordinateFrame& operator=(CoordinateFrame&& other) = default;
87
89 : frame_id(ComponentBatch::from_loggable(std::move(_frame_id), Descriptor_frame_id)
90 .value_or_throw()) {}
91
92 /// Update only some specific fields of a `CoordinateFrame`.
94 return CoordinateFrame();
95 }
96
97 /// Clear all the fields of a `CoordinateFrame`.
99
100 /// The coordinate frame to use for the current entity.
102 frame_id =
103 ComponentBatch::from_loggable(_frame_id, Descriptor_frame_id).value_or_throw();
104 return std::move(*this);
105 }
106
107 /// This method makes it possible to pack multiple `frame_id` in a single component batch.
108 ///
109 /// This only makes sense when used in conjunction with `columns`. `with_frame_id` should
110 /// be used when logging a single row's worth of data.
113 ) && {
114 frame_id =
115 ComponentBatch::from_loggable(_frame_id, Descriptor_frame_id).value_or_throw();
116 return std::move(*this);
117 }
118
119 /// Partitions the component data into multiple sub-batches.
120 ///
121 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
122 /// instead, via `ComponentBatch::partitioned`.
123 ///
124 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
125 ///
126 /// The specified `lengths` must sum to the total length of the component batch.
128
129 /// Partitions the component data into unit-length sub-batches.
130 ///
131 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
132 /// where `n` is automatically guessed.
134 };
135
136} // namespace rerun::archetypes
137
138namespace rerun {
139 /// \private
140 template <typename T>
141 struct AsComponents;
142
143 /// \private
144 template <>
145 struct AsComponents<archetypes::CoordinateFrame> {
146 /// Serialize all set component batches.
147 static Result<Collection<ComponentBatch>> as_batches(
148 const archetypes::CoordinateFrame& archetype
149 );
150 };
151} // namespace rerun
Generic collection of elements that are roughly contiguous in memory.
Definition collection.hpp:49
A class for representing either a usable value, or an error.
Definition result.hpp:14
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:76
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Arrow-encoded data of a single batch of components together with a component descriptor.
Definition component_batch.hpp:28
static Result< ComponentBatch > from_loggable(const rerun::Collection< T > &components, const ComponentDescriptor &descriptor)
Creates a new component batch from a collection of component instances.
Definition component_batch.hpp:46
A ComponentDescriptor fully describes the semantics of a column of data.
Definition component_descriptor.hpp:16
The Loggable trait is used by all built-in implementation of rerun::AsComponents to serialize a colle...
Definition loggable.hpp:11
Archetype: Specifies the coordinate frame for an entity.
Definition coordinate_frame.hpp:67
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition coordinate_frame.hpp:73
static CoordinateFrame update_fields()
Update only some specific fields of a CoordinateFrame.
Definition coordinate_frame.hpp:93
CoordinateFrame with_frame_id(const rerun::components::TransformFrameId &_frame_id) &&
The coordinate frame to use for the current entity.
Definition coordinate_frame.hpp:101
std::optional< ComponentBatch > frame_id
The coordinate frame to use for the current entity.
Definition coordinate_frame.hpp:69
static CoordinateFrame clear_fields()
Clear all the fields of a CoordinateFrame.
static constexpr auto Descriptor_frame_id
ComponentDescriptor for the frame_id field.
Definition coordinate_frame.hpp:76
CoordinateFrame with_many_frame_id(const Collection< rerun::components::TransformFrameId > &_frame_id) &&
This method makes it possible to pack multiple frame_id in a single component batch.
Definition coordinate_frame.hpp:111
Component: A string identifier for a transform frame.
Definition transform_frame_id.hpp:27