laser_scan.hpp
Go to the documentation of this file.
1 // Copyright 2023 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef BELUGA_SENSOR_DATA_LASER_SCAN_HPP
16 #define BELUGA_SENSOR_DATA_LASER_SCAN_HPP
17 
18 #include <cmath>
19 
20 #include <ciabatta/ciabatta.hpp>
21 
22 #include <sophus/types.hpp>
23 
24 #include <range/v3/view/filter.hpp>
25 #include <range/v3/view/transform.hpp>
26 #include <range/v3/view/zip.hpp>
27 
33 namespace beluga {
34 
49 
58 template <typename Derived>
59 class BaseLaserScan : public ciabatta::ciabatta_top<Derived> {
60  public:
62  [[nodiscard]] auto points_in_cartesian_coordinates() const {
63  return this->self().points_in_polar_coordinates() | ranges::views::transform([](const auto& vector) {
64  using std::cos, std::sin;
66  vector.x() * cos(vector.y()), vector.x() * sin(vector.y())};
67  });
68  }
69 
71 
75  [[nodiscard]] auto points_in_polar_coordinates() const {
76  static_assert(std::is_floating_point_v<ranges::range_value_t<decltype(this->self().ranges())>>);
77  static_assert(std::is_floating_point_v<ranges::range_value_t<decltype(this->self().angles())>>);
78  return ranges::views::zip(this->self().ranges(), this->self().angles()) |
79  ranges::views::filter([this](const auto& tuple) {
80  const auto [range, theta] = tuple;
81  using std::isnan;
82  return !isnan(range) && range >= this->self().min_range() && range <= this->self().max_range();
83  }) |
84  ranges::views::transform([](const auto& tuple) {
85  const auto [range, theta] = tuple;
86  return Sophus::Vector2<typename Derived::Scalar>{range, theta};
87  });
88  }
89 };
90 
91 } // namespace beluga
92 
93 #endif
beluga::BaseLaserScan::points_in_polar_coordinates
auto points_in_polar_coordinates() const
View points in polar coordinates in sensor frame.
Definition: laser_scan.hpp:75
ciabatta.hpp
Sophus::Vector2
Vector< Scalar, 2, Options > Vector2
types.hpp
beluga::BaseLaserScan
Laser scan 2D base type.
Definition: laser_scan.hpp:59
beluga::BaseLaserScan::points_in_cartesian_coordinates
auto points_in_cartesian_coordinates() const
View points in cartesian coordinates in sensor frame.
Definition: laser_scan.hpp:62
beluga::views::zip
constexpr detail::zip_fn zip
Given N ranges, return a new range where the Mth element is a tuple of the Mth elements of all N rang...
Definition: zip.hpp:74
beluga
The main Beluga namespace.
Definition: 3d_embedding.hpp:21


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53