UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
occupancy.hpp
1
42#ifndef UFO_MAP_OCCUPANCY_OCCUPANCY_HPP
43#define UFO_MAP_OCCUPANCY_OCCUPANCY_HPP
44
45// UFO
46#include <ufo/map/occupancy/state.hpp>
47
48// STL
49#include <cstdint>
50#include <type_traits>
51
52namespace ufo
53{
54template <class T = float>
55struct Occupancy;
56
57template <>
58struct Occupancy<float> {
59 using value_type = float;
60
61 value_type logit;
62 // First 4 bits indicate contains,
63 // bit #0 = unknown, #1 = free, #2 = occupied, and #4 = void region.
64 std::uint8_t data;
65};
66
67template <>
68struct Occupancy<std::uint8_t> {
69 using value_type = std::uint8_t;
70
71 value_type logit;
72 // First 4 bits indicate contains,
73 // bit #0 = unknown, #1 = free, #2 = occupied, and #4 = void region.
74 std::uint8_t data;
75};
76
77template <>
78struct Occupancy<OccupancyState> {
79 using value_type = OccupancyState;
80
81 // First 4 bits indicate contains,
82 // Bit #0 = unknown, #1 = free, #2 = occupied, and #3 = void region.
83 // Next 2 bits indicate state
84 std::uint8_t data;
85};
86
87namespace detail
88{
89template <class T>
90[[nodiscard]] constexpr auto occupancy(Occupancy<T> occupancy)
91{
92 // TODO: Implement
93}
94
95template <class T>
96[[nodiscard]] constexpr auto logit(Occupancy<T> occupancy)
97{
98 if constexpr (std::is_same_v<bool, T>) {
99 return (0b01110000u & occupancy.data) >> 4u;
100 } else {
101 return occupancy.logit;
102 }
103}
104
105template <class T>
106[[nodiscard]] constexpr bool containsUnknown(Occupancy<T> occupancy)
107{
108 return static_cast<bool>(0b00000001u & occupancy.data);
109}
110
111template <class T>
112[[nodiscard]] constexpr bool containsFree(Occupancy<T> occupancy)
113{
114 return static_cast<bool>(0b00000010u & occupancy.data);
115}
116
117template <class T>
118[[nodiscard]] constexpr bool containsOccupied(Occupancy<T> occupancy)
119{
120 return static_cast<bool>(0b00000100u & occupancy.data);
121}
122
123template <class T>
124[[nodiscard]] constexpr bool containsVoidRegion(Occupancy<T> occupancy)
125{
126 return static_cast<bool>(0b00001000u & occupancy.data);
127}
128
129template <class T>
130[[nodiscard]] constexpr bool unknown(Occupancy<T> occupancy, T min_threshold,
131 T max_threshold)
132{
133 // TODO: Implement
134}
135
136template <class T>
137[[nodiscard]] constexpr bool free(Occupancy<T> occupancy, T min_threshold,
138 T max_threshold)
139{
140 // TODO: Implement
141}
142
143template <class T>
144[[nodiscard]] bool occupied(Occupancy<T> occupancy, T threshold)
145{
146 // TODO: Implement
147}
148}; // namespace detail
149} // namespace ufo
150
151#endif // UFO_MAP_OCCUPANCY_OCCUPANCY_HPP
STL namespace.
All vision-related classes and functions.
Definition cloud.hpp:49