Rerun C++ SDK
Loading...
Searching...
No Matches
grid_map.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/build/re_type_definitions/rerun/archetypes/grid_map.def.rs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../component_batch.hpp"
8#include "../component_column.hpp"
9#include "../components/cell_size.hpp"
10#include "../components/colormap.hpp"
11#include "../components/draw_order.hpp"
12#include "../components/image_buffer.hpp"
13#include "../components/image_format.hpp"
14#include "../components/opacity.hpp"
15#include "../components/rotation_axis_angle.hpp"
16#include "../components/rotation_quat.hpp"
17#include "../components/translation3d.hpp"
18#include "../result.hpp"
19
20#include <cstdint>
21#include <optional>
22#include <utility>
23#include <vector>
24
25namespace rerun::archetypes {
26 /// **Archetype**: A 2D grid map stored as raster data in an image buffer, with a cell size in scene units and pose.
27 ///
28 /// This archetype is intended for robotics applications like occupancy maps or navigation costmaps.
29 ///
30 /// ## Example
31 ///
32 /// ### Simple occupancy grid map
33 /// ```cpp
34 /// #include <rerun.hpp>
35 ///
36 /// #include <vector>
37 ///
38 /// int main(int argc, char* argv[]) {
39 /// const auto rec = rerun::RecordingStream("rerun_example_grid_map");
40 /// rec.spawn().exit_on_failure();
41 ///
42 /// const size_t width = 64;
43 /// const size_t height = 64;
44 /// const float cell_size = 0.1f;
45 ///
46 /// // Create a synthetic image with ROS `nav_msgs/OccupancyGrid` cell value conventions:
47 /// // -1 (255) unknown, 0 free, 100 occupied.
48 /// std::vector<uint8_t> grid(width * height, 255);
49 /// for (size_t y = 8; y <56; ++y) {
50 /// for (size_t x = 8; x <56; ++x) {
51 /// grid[y * width + x] = 0;
52 /// }
53 /// }
54 /// for (size_t y = 20; y <44; ++y) {
55 /// for (size_t x = 20; x <44; ++x) {
56 /// grid[y * width + x] = 100;
57 /// }
58 /// }
59 ///
60 /// rec.log(
61 /// "world/map",
62 /// rerun::archetypes::GridMap()
63 /// .with_data(rerun::ImageBuffer(grid))
64 /// .with_format(rerun::components::ImageFormat(
65 /// {width, height},
66 /// rerun::ColorModel::L,
67 /// rerun::ChannelDatatype::U8
68 /// ))
69 /// .with_cell_size(cell_size)
70 /// .with_translation(
71 /// {-(static_cast<float>(width) * cell_size) / 2.0f,
72 /// -(static_cast<float>(height) * cell_size) / 2.0f,
73 /// 0.0f}
74 /// )
75 /// .with_colormap(rerun::Colormap::RvizMap)
76 /// );
77 /// }
78 /// ```
79 struct GridMap {
80 /// The raw grid data.
81 std::optional<ComponentBatch> data;
82
83 /// The format of the grid's image data.
84 std::optional<ComponentBatch> format;
85
86 /// The scene unit size of a single grid cell (e.g. m / pixel).
87 ///
88 /// Defaults to 0.01 scene units per pixel.
89 std::optional<ComponentBatch> cell_size;
90
91 /// Translation of the lower-left corner of the grid map in space.
92 ///
93 /// Together with `components::RotationAxisAngle` or `components::RotationQuat`, this defines the pose of the
94 /// lower-left image corner relative to the map's parent coordinate frame.
95 ///
96 /// If not set, the lower-left image corner is placed at origin of the map's parent coordinate frame.
97 std::optional<ComponentBatch> translation;
98
99 /// Rotation of the lower-left corner of the grid map in space via axis + angle.
100 ///
101 /// Together with `components::Translation3D`, this defines the pose of the
102 /// lower-left image corner relative to the map's parent coordinate frame.
103 ///
104 /// Note: either this or `components::RotationQuat` can be set to specify the grid map's rotation, but not both.
105 /// If both this and `components::RotationQuat` are set, this is ignored in favor of the quaternion.
106 std::optional<ComponentBatch> rotation_axis_angle;
107
108 /// Rotation of the lower-left corner of the grid map in space via quaternion.
109 ///
110 /// Together with `components::Translation3D`, this defines the pose of the
111 /// lower-left image corner relative to the map's parent coordinate frame.
112 std::optional<ComponentBatch> quaternion;
113
114 /// Opacity of the grid map texture after all image decoding and colormap application.
115 ///
116 /// Defaults to 1.0 (fully opaque).
117 std::optional<ComponentBatch> opacity;
118
119 /// Optional draw order for layering multiple grid maps that overlap in space.
120 ///
121 /// Higher values are drawn on top of lower values.
122 std::optional<ComponentBatch> draw_order;
123
124 /// Colormap to use for rendering single-channel grid maps.
125 ///
126 /// If not set, the grid map is shown using the underlying `components::ImageFormat`
127 /// interpretation.
128 std::optional<ComponentBatch> colormap;
129
130 public:
131 /// The name of the archetype as used in `ComponentDescriptor`s.
132 static constexpr const char ArchetypeName[] = "rerun.archetypes.GridMap";
133
134 /// `ComponentDescriptor` for the `data` field.
135 static constexpr auto Descriptor_data = ComponentDescriptor(
137 );
138 /// `ComponentDescriptor` for the `format` field.
139 static constexpr auto Descriptor_format = ComponentDescriptor(
141 );
142 /// `ComponentDescriptor` for the `cell_size` field.
145 );
146 /// `ComponentDescriptor` for the `translation` field.
148 ArchetypeName, "GridMap:translation",
150 );
151 /// `ComponentDescriptor` for the `rotation_axis_angle` field.
153 ArchetypeName, "GridMap:rotation_axis_angle",
155 );
156 /// `ComponentDescriptor` for the `quaternion` field.
158 ArchetypeName, "GridMap:quaternion",
160 );
161 /// `ComponentDescriptor` for the `opacity` field.
164 );
165 /// `ComponentDescriptor` for the `draw_order` field.
167 ArchetypeName, "GridMap:draw_order",
169 );
170 /// `ComponentDescriptor` for the `colormap` field.
173 );
174
175 public:
176 GridMap() = default;
177 GridMap(GridMap&& other) = default;
178 GridMap(const GridMap& other) = default;
179 GridMap& operator=(const GridMap& other) = default;
180 GridMap& operator=(GridMap&& other) = default;
181
182 /// Update only some specific fields of a `GridMap`.
184 return GridMap();
185 }
186
187 /// Clear all the fields of a `GridMap`.
189
190 /// The raw grid data.
192 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
193 return std::move(*this);
194 }
195
196 /// This method makes it possible to pack multiple `data` in a single component batch.
197 ///
198 /// This only makes sense when used in conjunction with `columns`. `with_data` should
199 /// be used when logging a single row's worth of data.
201 data = ComponentBatch::from_loggable(_data, Descriptor_data).value_or_throw();
202 return std::move(*this);
203 }
204
205 /// The format of the grid's image data.
207 format = ComponentBatch::from_loggable(_format, Descriptor_format).value_or_throw();
208 return std::move(*this);
209 }
210
211 /// This method makes it possible to pack multiple `format` in a single component batch.
212 ///
213 /// This only makes sense when used in conjunction with `columns`. `with_format` should
214 /// be used when logging a single row's worth of data.
216 format = ComponentBatch::from_loggable(_format, Descriptor_format).value_or_throw();
217 return std::move(*this);
218 }
219
220 /// The scene unit size of a single grid cell (e.g. m / pixel).
221 ///
222 /// Defaults to 0.01 scene units per pixel.
224 cell_size =
225 ComponentBatch::from_loggable(_cell_size, Descriptor_cell_size).value_or_throw();
226 return std::move(*this);
227 }
228
229 /// This method makes it possible to pack multiple `cell_size` in a single component batch.
230 ///
231 /// This only makes sense when used in conjunction with `columns`. `with_cell_size` should
232 /// be used when logging a single row's worth of data.
234 cell_size =
235 ComponentBatch::from_loggable(_cell_size, Descriptor_cell_size).value_or_throw();
236 return std::move(*this);
237 }
238
239 /// Translation of the lower-left corner of the grid map in space.
240 ///
241 /// Together with `components::RotationAxisAngle` or `components::RotationQuat`, this defines the pose of the
242 /// lower-left image corner relative to the map's parent coordinate frame.
243 ///
244 /// If not set, the lower-left image corner is placed at origin of the map's parent coordinate frame.
247 .value_or_throw();
248 return std::move(*this);
249 }
250
251 /// This method makes it possible to pack multiple `translation` in a single component batch.
252 ///
253 /// This only makes sense when used in conjunction with `columns`. `with_translation` should
254 /// be used when logging a single row's worth of data.
257 ) && {
259 .value_or_throw();
260 return std::move(*this);
261 }
262
263 /// Rotation of the lower-left corner of the grid map in space via axis + angle.
264 ///
265 /// Together with `components::Translation3D`, this defines the pose of the
266 /// lower-left image corner relative to the map's parent coordinate frame.
267 ///
268 /// Note: either this or `components::RotationQuat` can be set to specify the grid map's rotation, but not both.
269 /// If both this and `components::RotationQuat` are set, this is ignored in favor of the quaternion.
271 const rerun::components::RotationAxisAngle& _rotation_axis_angle
272 ) && {
275 .value_or_throw();
276 return std::move(*this);
277 }
278
279 /// This method makes it possible to pack multiple `rotation_axis_angle` in a single component batch.
280 ///
281 /// This only makes sense when used in conjunction with `columns`. `with_rotation_axis_angle` should
282 /// be used when logging a single row's worth of data.
284 const Collection<rerun::components::RotationAxisAngle>& _rotation_axis_angle
285 ) && {
288 .value_or_throw();
289 return std::move(*this);
290 }
291
292 /// Rotation of the lower-left corner of the grid map in space via quaternion.
293 ///
294 /// Together with `components::Translation3D`, this defines the pose of the
295 /// lower-left image corner relative to the map's parent coordinate frame.
297 quaternion =
298 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
299 return std::move(*this);
300 }
301
302 /// This method makes it possible to pack multiple `quaternion` in a single component batch.
303 ///
304 /// This only makes sense when used in conjunction with `columns`. `with_quaternion` should
305 /// be used when logging a single row's worth of data.
307 ) && {
308 quaternion =
309 ComponentBatch::from_loggable(_quaternion, Descriptor_quaternion).value_or_throw();
310 return std::move(*this);
311 }
312
313 /// Opacity of the grid map texture after all image decoding and colormap application.
314 ///
315 /// Defaults to 1.0 (fully opaque).
317 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
318 return std::move(*this);
319 }
320
321 /// This method makes it possible to pack multiple `opacity` in a single component batch.
322 ///
323 /// This only makes sense when used in conjunction with `columns`. `with_opacity` should
324 /// be used when logging a single row's worth of data.
326 opacity = ComponentBatch::from_loggable(_opacity, Descriptor_opacity).value_or_throw();
327 return std::move(*this);
328 }
329
330 /// Optional draw order for layering multiple grid maps that overlap in space.
331 ///
332 /// Higher values are drawn on top of lower values.
334 draw_order =
335 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
336 return std::move(*this);
337 }
338
339 /// This method makes it possible to pack multiple `draw_order` in a single component batch.
340 ///
341 /// This only makes sense when used in conjunction with `columns`. `with_draw_order` should
342 /// be used when logging a single row's worth of data.
344 ) && {
345 draw_order =
346 ComponentBatch::from_loggable(_draw_order, Descriptor_draw_order).value_or_throw();
347 return std::move(*this);
348 }
349
350 /// Colormap to use for rendering single-channel grid maps.
351 ///
352 /// If not set, the grid map is shown using the underlying `components::ImageFormat`
353 /// interpretation.
355 colormap =
356 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
357 return std::move(*this);
358 }
359
360 /// This method makes it possible to pack multiple `colormap` in a single component batch.
361 ///
362 /// This only makes sense when used in conjunction with `columns`. `with_colormap` should
363 /// be used when logging a single row's worth of data.
365 colormap =
366 ComponentBatch::from_loggable(_colormap, Descriptor_colormap).value_or_throw();
367 return std::move(*this);
368 }
369
370 /// Partitions the component data into multiple sub-batches.
371 ///
372 /// Specifically, this transforms the existing `ComponentBatch` data into `ComponentColumn`s
373 /// instead, via `ComponentBatch::partitioned`.
374 ///
375 /// This makes it possible to use `RecordingStream::send_columns` to send columnar data directly into Rerun.
376 ///
377 /// The specified `lengths` must sum to the total length of the component batch.
379
380 /// Partitions the component data into unit-length sub-batches.
381 ///
382 /// This is semantically similar to calling `columns` with `std::vector<uint32_t>(n, 1)`,
383 /// where `n` is automatically guessed.
385 };
386
387} // namespace rerun::archetypes
388
389namespace rerun {
390 /// \private
391 template <typename T>
392 struct AsComponents;
393
394 /// \private
395 template <>
396 struct AsComponents<archetypes::GridMap> {
397 /// Serialize all set component batches.
398 static Result<Collection<ComponentBatch>> as_batches(const archetypes::GridMap& archetype);
399 };
400} // 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:90
Colormap
Component: Colormap for mapping scalar values within a given range to a color.
Definition colormap.hpp:28
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:26
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: A 2D grid map stored as raster data in an image buffer, with a cell size in scene units an...
Definition grid_map.hpp:79
GridMap with_many_rotation_axis_angle(const Collection< rerun::components::RotationAxisAngle > &_rotation_axis_angle) &&
This method makes it possible to pack multiple rotation_axis_angle in a single component batch.
Definition grid_map.hpp:283
GridMap with_translation(const rerun::components::Translation3D &_translation) &&
Translation of the lower-left corner of the grid map in space.
Definition grid_map.hpp:245
std::optional< ComponentBatch > quaternion
Rotation of the lower-left corner of the grid map in space via quaternion.
Definition grid_map.hpp:112
static constexpr auto Descriptor_rotation_axis_angle
ComponentDescriptor for the rotation_axis_angle field.
Definition grid_map.hpp:152
std::optional< ComponentBatch > rotation_axis_angle
Rotation of the lower-left corner of the grid map in space via axis + angle.
Definition grid_map.hpp:106
static GridMap update_fields()
Update only some specific fields of a GridMap.
Definition grid_map.hpp:183
GridMap with_many_colormap(const Collection< rerun::components::Colormap > &_colormap) &&
This method makes it possible to pack multiple colormap in a single component batch.
Definition grid_map.hpp:364
GridMap with_many_quaternion(const Collection< rerun::components::RotationQuat > &_quaternion) &&
This method makes it possible to pack multiple quaternion in a single component batch.
Definition grid_map.hpp:306
std::optional< ComponentBatch > cell_size
The scene unit size of a single grid cell (e.g.
Definition grid_map.hpp:89
GridMap with_many_translation(const Collection< rerun::components::Translation3D > &_translation) &&
This method makes it possible to pack multiple translation in a single component batch.
Definition grid_map.hpp:255
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition grid_map.hpp:132
std::optional< ComponentBatch > colormap
Colormap to use for rendering single-channel grid maps.
Definition grid_map.hpp:128
static constexpr auto Descriptor_translation
ComponentDescriptor for the translation field.
Definition grid_map.hpp:147
Collection< ComponentColumn > columns()
Partitions the component data into unit-length sub-batches.
GridMap with_many_opacity(const Collection< rerun::components::Opacity > &_opacity) &&
This method makes it possible to pack multiple opacity in a single component batch.
Definition grid_map.hpp:325
std::optional< ComponentBatch > format
The format of the grid's image data.
Definition grid_map.hpp:84
GridMap with_quaternion(const rerun::components::RotationQuat &_quaternion) &&
Rotation of the lower-left corner of the grid map in space via quaternion.
Definition grid_map.hpp:296
std::optional< ComponentBatch > translation
Translation of the lower-left corner of the grid map in space.
Definition grid_map.hpp:97
GridMap with_many_cell_size(const Collection< rerun::components::CellSize > &_cell_size) &&
This method makes it possible to pack multiple cell_size in a single component batch.
Definition grid_map.hpp:233
GridMap with_many_format(const Collection< rerun::components::ImageFormat > &_format) &&
This method makes it possible to pack multiple format in a single component batch.
Definition grid_map.hpp:215
static constexpr auto Descriptor_format
ComponentDescriptor for the format field.
Definition grid_map.hpp:139
std::optional< ComponentBatch > opacity
Opacity of the grid map texture after all image decoding and colormap application.
Definition grid_map.hpp:117
GridMap with_draw_order(const rerun::components::DrawOrder &_draw_order) &&
Optional draw order for layering multiple grid maps that overlap in space.
Definition grid_map.hpp:333
Collection< ComponentColumn > columns(const Collection< uint32_t > &lengths_)
Partitions the component data into multiple sub-batches.
GridMap with_colormap(const rerun::components::Colormap &_colormap) &&
Colormap to use for rendering single-channel grid maps.
Definition grid_map.hpp:354
static constexpr auto Descriptor_quaternion
ComponentDescriptor for the quaternion field.
Definition grid_map.hpp:157
static constexpr auto Descriptor_draw_order
ComponentDescriptor for the draw_order field.
Definition grid_map.hpp:166
GridMap with_many_data(const Collection< rerun::components::ImageBuffer > &_data) &&
This method makes it possible to pack multiple data in a single component batch.
Definition grid_map.hpp:200
GridMap with_rotation_axis_angle(const rerun::components::RotationAxisAngle &_rotation_axis_angle) &&
Rotation of the lower-left corner of the grid map in space via axis + angle.
Definition grid_map.hpp:270
GridMap with_many_draw_order(const Collection< rerun::components::DrawOrder > &_draw_order) &&
This method makes it possible to pack multiple draw_order in a single component batch.
Definition grid_map.hpp:343
std::optional< ComponentBatch > data
The raw grid data.
Definition grid_map.hpp:81
GridMap with_format(const rerun::components::ImageFormat &_format) &&
The format of the grid's image data.
Definition grid_map.hpp:206
GridMap with_data(const rerun::components::ImageBuffer &_data) &&
The raw grid data.
Definition grid_map.hpp:191
static constexpr auto Descriptor_opacity
ComponentDescriptor for the opacity field.
Definition grid_map.hpp:162
static GridMap clear_fields()
Clear all the fields of a GridMap.
std::optional< ComponentBatch > draw_order
Optional draw order for layering multiple grid maps that overlap in space.
Definition grid_map.hpp:122
GridMap with_opacity(const rerun::components::Opacity &_opacity) &&
Opacity of the grid map texture after all image decoding and colormap application.
Definition grid_map.hpp:316
static constexpr auto Descriptor_colormap
ComponentDescriptor for the colormap field.
Definition grid_map.hpp:171
static constexpr auto Descriptor_data
ComponentDescriptor for the data field.
Definition grid_map.hpp:135
static constexpr auto Descriptor_cell_size
ComponentDescriptor for the cell_size field.
Definition grid_map.hpp:143
GridMap with_cell_size(const rerun::components::CellSize &_cell_size) &&
The scene unit size of a single grid cell (e.g.
Definition grid_map.hpp:223
Component: The metric size of one grid cell in local scene units.
Definition cell_size.hpp:16
Component: Draw order of 2D elements.
Definition draw_order.hpp:19
Component: A buffer that is known to store image data.
Definition image_buffer.hpp:18
Component: The metadata describing the contents of a components::ImageBuffer.
Definition image_format.hpp:14
Component: Degree of transparency ranging from 0.0 (fully transparent) to 1.0 (fully opaque).
Definition opacity.hpp:17
Component: 3D rotation represented by a rotation around a given axis.
Definition rotation_axis_angle.hpp:17
Component: A 3D rotation expressed as a quaternion.
Definition rotation_quat.hpp:18
Component: A translation vector in 3D space.
Definition translation3d.hpp:15