supereight2
Loading...
Searching...
No Matches
type_util.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Smart Robotics Lab, Imperial College London, Technical University of Munich
3 * SPDX-FileCopyrightText: 2021 Nils Funk
4 * SPDX-FileCopyrightText: 2021 Sotiris Papatheodorou
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef SE_TYPE_UTIL_HPP
9#define SE_TYPE_UTIL_HPP
10
11#include <Eigen/StdVector>
12#include <se/common/rgb.hpp>
13
14EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2f)
15EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3f)
16EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector2d)
17EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Vector3d)
18
19EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix2f)
20EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix3f)
21EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix4f)
22EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix2d)
23EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix3d)
24EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::Matrix4d)
25
26namespace se {
27
43typedef uint64_t key_t;
46
47typedef unsigned int idx_t;
48
49typedef float field_t;
50
51typedef Eigen::Matrix<field_t, 3, 1> field_vec_t;
52
54
55typedef int timestamp_t;
56
57typedef RGB colour_t;
58
60typedef uint16_t id_t;
62inline constexpr id_t g_no_id = 0;
65inline constexpr id_t g_not_mapped = -1;
66
67
72static inline RGB id_colour(const id_t id)
73{
74 switch (id) {
75 case g_not_mapped:
76 return {0x00, 0x00, 0x00};
77 case g_no_id:
78 return {0xFF, 0xFF, 0xFF};
79 default: {
80 // Inspired from the following and naively modified for 16-bit integers.
81 // https://stackoverflow.com/questions/664014/what-integer-hash-function-are-good-that-accepts-an-integer-hash-key/12996028#12996028
82 const uint8_t r = ((id >> 8) ^ id) * 0x45d9f3b;
83 const uint8_t g = ((id >> 8) ^ r) * 0x45d9f3b;
84 const uint8_t b = ((id >> 8) ^ g) * 0x45d9f3b;
85 return {r, g, b};
86 }
87 }
88}
89
90} // namespace se
91
92#endif // SE_TYPE_UTIL_HPP
Definition image.hpp:19
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14
float field_t
The type of the stored field (e.g. TSDF, ESDF or occupancy)
Definition type_util.hpp:49
static RGB id_colour(const id_t id)
Function that generates a unique color based on the id received.
Definition type_util.hpp:72
Eigen::Matrix< field_t, 3, 1 > field_vec_t
Definition type_util.hpp:51
int timestamp_t
The type of the time stamp.
Definition type_util.hpp:55
uint64_t code_t
The type of the Morton code.
Definition type_util.hpp:44
unsigned int idx_t
Child or voxel index type.
Definition type_util.hpp:47
RGB colour_t
The type of the colour.
Definition type_util.hpp:57
uint16_t id_t
The type used to represent identifiers.
Definition type_util.hpp:60
constexpr id_t g_not_mapped
Used to distinguish a region that's unmapped from a region without an identifier.
Definition type_util.hpp:65
constexpr id_t g_no_id
Indicates the absence of an identifier.
Definition type_util.hpp:62
se::field_t weight_t
The type of the field type weight.
Definition type_util.hpp:53
uint64_t scale_t
The type of the scale in the morton code.
Definition type_util.hpp:45
uint64_t key_t
key = 1 bit buffer + 57 bits of morton code + 6 bits of scale information The maxium scale is limited...
Definition type_util.hpp:43
A colour represented as a Red-Green-Blue tuple with 8-bits per channel.
Definition rgb.hpp:18