scan_range.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef PSEN_SCAN_V2_STANDALONE_SCAN_RANGE_H
17 #define PSEN_SCAN_V2_STANDALONE_SCAN_RANGE_H
18 
19 #include <stdexcept>
20 
22 
24 {
30 template <int16_t min_allowed_angle, int16_t max_allowed_angle>
32 {
33  static_assert(min_allowed_angle < max_allowed_angle, "MIN-angle limit smaller than MAX-angle limit.");
34 
35 public:
42  constexpr ScanRangeTemplated(const util::TenthOfDegree& start_angle, const util::TenthOfDegree& end_angle);
43 
45  [[deprecated("use const util::TenthOfDegree& start() const instead")]] const util::TenthOfDegree& getStart() const;
46  const util::TenthOfDegree& start() const;
47 
49  [[deprecated("use const util::TenthOfDegree& end() const const instead")]] const util::TenthOfDegree& getEnd() const;
50  const util::TenthOfDegree& end() const;
51 
52 public:
54 
55 private:
56  ScanRangeTemplated() = default;
57 
58 private:
61 };
62 
63 template <int16_t min_angle_raw, int16_t max_angle_raw>
65  const util::TenthOfDegree& end_angle)
66  : start_angle_(start_angle), end_angle_(end_angle)
67 {
68  const util::TenthOfDegree min_angle{ min_angle_raw };
69  const util::TenthOfDegree max_angle{ max_angle_raw };
70 
71  if (start_angle < min_angle || start_angle > max_angle)
72  {
73  throw std::out_of_range("Start angle out of range");
74  }
75 
76  if (end_angle < min_angle || end_angle > max_angle)
77  {
78  throw std::out_of_range("End angle out of range");
79  }
80 
81  if (start_angle >= end_angle)
82  {
83  throw std::invalid_argument("Start angle must be smaller than end angle");
84  }
85 }
86 
87 template <int16_t min_angle, int16_t max_angle>
89 {
91 }
92 
93 template <int16_t min_angle, int16_t max_angle>
95 {
96  return start_angle_;
97 }
98 
99 template <int16_t min_angle, int16_t max_angle>
101 {
102  return end_angle_;
103 }
104 
105 template <int16_t min_angle, int16_t max_angle>
107 {
108  return this->start();
109 }
110 
111 template <int16_t min_angle, int16_t max_angle>
113 {
114  return this->end();
115 }
116 
118 
119 } // namespace psen_scan_v2_standalone
120 
121 #endif // PSEN_SCAN_V2_STANDALONE_SCAN_RANGE_H
psen_scan_v2_standalone::ScanRangeTemplated::getEnd
const util::TenthOfDegree & getEnd() const
Definition: scan_range.h:112
psen_scan_v2_standalone::ScanRangeTemplated::getStart
const util::TenthOfDegree & getStart() const
Definition: scan_range.h:106
psen_scan_v2_standalone::ScanRangeTemplated::ScanRangeTemplated
ScanRangeTemplated()=default
psen_scan_v2_standalone::ScanRangeTemplated::start
const util::TenthOfDegree & start() const
Definition: scan_range.h:94
psen_scan_v2_standalone::ScanRangeTemplated::end_angle_
util::TenthOfDegree end_angle_
Definition: scan_range.h:60
tenth_of_degree.h
psen_scan_v2_standalone::ScanRangeTemplated::end
const util::TenthOfDegree & end() const
Definition: scan_range.h:100
psen_scan_v2_standalone::ScanRangeTemplated::start_angle_
util::TenthOfDegree start_angle_
Definition: scan_range.h:59
start
ROSCPP_DECL void start()
psen_scan_v2_standalone
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
psen_scan_v2_standalone::ScanRangeTemplated
Higher level data type storing the range in which the scanner takes measurements.
Definition: scan_range.h:31
psen_scan_v2_standalone::util::TenthOfDegree
Helper class representing angles in tenth of degree.
Definition: tenth_of_degree.h:34
psen_scan_v2_standalone::ScanRangeTemplated::createInvalidScanRange
static constexpr ScanRangeTemplated< min_allowed_angle, max_allowed_angle > createInvalidScanRange()
Definition: scan_range.h:88


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12