scanner_interface.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_SCANNER_H
17 #define PSEN_SCAN_V2_STANDALONE_SCANNER_H
18 
19 #include <stdexcept>
20 #include <future>
21 #include <functional>
22 
25 
27 {
40 class IScanner
41 {
42 public:
44  using LaserScanCallback = std::function<void(const LaserScan&)>;
45 
46 public:
47  IScanner(const ScannerConfiguration& scanner_config, const LaserScanCallback& laser_scan_callback);
48  virtual ~IScanner() = default;
49 
50 public:
52  virtual std::future<void> start() = 0;
54  virtual std::future<void> stop() = 0;
55 
56 protected:
58  [[deprecated("use const ScannerConfiguration& config() const instead")]] const ScannerConfiguration&
59  getConfig() const;
60  const ScannerConfiguration& config() const;
61 
63  [[deprecated("use const LaserScanCallback& laserScanCallback() const instead")]] const LaserScanCallback&
64  getLaserScanCallback() const;
65  const LaserScanCallback& laserScanCallback() const;
66 
67 private:
70 };
71 
72 inline IScanner::IScanner(const ScannerConfiguration& scanner_config, const LaserScanCallback& laser_scan_callback)
73  : config_(scanner_config), laser_scan_callback_(laser_scan_callback)
74 {
75  if (!laser_scan_callback)
76  {
77  throw std::invalid_argument("Laserscan-callback must not be null");
78  }
79 }
80 
82 {
83  return config_;
84 }
85 
87 {
88  return laser_scan_callback_;
89 }
90 
92 {
93  return this->config();
94 }
95 
97 {
98  return this->laserScanCallback();
99 }
100 
101 } // namespace psen_scan_v2_standalone
102 
103 #endif // PSEN_SCAN_V2_STANDALONE_SCANNER_H
const ScannerConfiguration & config() const
const ScannerConfiguration config_
const LaserScanCallback & laserScanCallback() const
virtual std::future< void > stop()=0
Stops the scanner.
IScanner(const ScannerConfiguration &scanner_config, const LaserScanCallback &laser_scan_callback)
Higher level data type storing the configuration details of the scanner like scanner IP...
virtual std::future< void > start()=0
Starts the scanner.
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
const LaserScanCallback & getLaserScanCallback() const
std::function< void(const LaserScan &)> LaserScanCallback
Represents the user-provided callback for processing incoming scan data.
const LaserScanCallback laser_scan_callback_
const ScannerConfiguration & getConfig() const
This is the API definition for external interaction with the scanner driver.


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Nov 5 2022 02:13:36