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
psen_scan_v2_standalone::IScanner::getLaserScanCallback
const LaserScanCallback & getLaserScanCallback() const
Definition: scanner_interface.h:96
psen_scan_v2_standalone::IScanner::getConfig
const ScannerConfiguration & getConfig() const
Definition: scanner_interface.h:91
scanner_configuration.h
psen_scan_v2_standalone::IScanner::laser_scan_callback_
const LaserScanCallback laser_scan_callback_
Definition: scanner_interface.h:69
psen_scan_v2_standalone::IScanner::config
const ScannerConfiguration & config() const
Definition: scanner_interface.h:81
psen_scan_v2_standalone::IScanner::~IScanner
virtual ~IScanner()=default
psen_scan_v2_standalone::IScanner::config_
const ScannerConfiguration config_
Definition: scanner_interface.h:68
psen_scan_v2_standalone::LaserScan
This class represents a single laser scan in the <tf_prefix> target frame.
Definition: laserscan.h:47
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::IScanner::LaserScanCallback
std::function< void(const LaserScan &)> LaserScanCallback
Represents the user-provided callback for processing incoming scan data.
Definition: scanner_interface.h:44
psen_scan_v2_standalone::IScanner::laserScanCallback
const LaserScanCallback & laserScanCallback() const
Definition: scanner_interface.h:86
psen_scan_v2_standalone::IScanner::start
virtual std::future< void > start()=0
Starts the scanner.
psen_scan_v2_standalone::IScanner::IScanner
IScanner(const ScannerConfiguration &scanner_config, const LaserScanCallback &laser_scan_callback)
Definition: scanner_interface.h:72
laserscan.h
psen_scan_v2_standalone::IScanner::stop
virtual std::future< void > stop()=0
Stops the scanner.
psen_scan_v2_standalone::IScanner
This is the API definition for external interaction with the scanner driver.
Definition: scanner_interface.h:40
psen_scan_v2_standalone::ScannerConfiguration
Higher level data type storing the configuration details of the scanner like scanner IP,...
Definition: scanner_configuration.h:34


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