r2000_driver.h
Go to the documentation of this file.
1 // Copyright (c) 2014, Pepperl+Fuchs GmbH, Mannheim
2 // Copyright (c) 2014, Denis Dillenberger
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
10 //
11 // * Redistributions in binary form must reproduce the above copyright notice, this
12 // list of conditions and the following disclaimer in the documentation and/or
13 // other materials provided with the distribution.
14 //
15 // * Neither the name of Pepperl+Fuchs nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef R2000_DRIVER_H
31 #define R2000_DRIVER_H
32 
33 #include <string>
34 #include <vector>
35 #include <map>
36 #include <boost/optional.hpp>
39 
40 namespace pepperl_fuchs {
41 
42 class HttpCommandInterface;
43 class ScanDataReceiver;
44 
48 {
49 public:
51  R2000Driver();
52 
54  ~R2000Driver();
55 
59  bool connect(const std::string hostname, int port=80);
60 
62  void disconnect();
63 
65  bool isConnected() {return is_connected_; }
66 
69  bool startCapturingTCP();
70 
73  bool startCapturingUDP();
74 
77  bool stopCapturing();
78 
81  bool isCapturing();
82 
85  bool checkConnection();
86 
90 
93  const std::map< std::string, std::string >& getParameters();
94 
97  const std::map< std::string, std::string >& getParametersCached() const {return parameters_;}
98 
103  ScanData getScan();
104 
109 
111  std::size_t getScansAvailable() const;
112 
114  std::size_t getFullScansAvailable() const;
115 
118  bool setScanFrequency( unsigned int frequency );
119 
123  bool setSamplesPerScan( unsigned int samples );
124 
127  bool rebootDevice();
128 
132  bool resetParameters( const std::vector<std::string>& names );
133 
136  bool setParameter( const std::string& name, const std::string& value );
137 
139  void feedWatchdog(bool feed_always = false);
140 
141 private:
144 
147 
150 
153 
156 
159 
161  boost::optional<HandleInfo> handle_info_;
162 
165 
167  std::map< std::string, std::string > parameters_;
168 };
169 
170 } // NS pepperl_fuchs
171 
172 #endif // R2000_DRIVER_H
double watchdog_feed_time_
Last time the watchdog was fed.
Definition: r2000_driver.h:155
ScanDataReceiver * data_receiver_
Asynchronous data receiver.
Definition: r2000_driver.h:146
Driver for the laserscanner R2000 of Pepperl+Fuchs.
Definition: r2000_driver.h:47
const std::map< std::string, std::string > & getParametersCached() const
Definition: r2000_driver.h:97
Information about the HTTP/JSON protocol.
Definition: protocol_info.h:19
bool resetParameters(const std::vector< std::string > &names)
~R2000Driver()
Cleanly disconnect in case of destruction.
bool setSamplesPerScan(unsigned int samples)
std::size_t getScansAvailable() const
Get the total number of laserscans available (even scans which are not fully reveived yet) ...
const ProtocolInfo & getProtocolInfo()
Definition: r2000_driver.h:89
bool setScanFrequency(unsigned int frequency)
HttpCommandInterface * command_interface_
HTTP/JSON interface of the scanner.
Definition: r2000_driver.h:143
ProtocolInfo protocol_info_
Cached version of the protocol info.
Definition: r2000_driver.h:164
bool isConnected()
Return connection status.
Definition: r2000_driver.h:65
void feedWatchdog(bool feed_always=false)
Feed the watchdog with the current handle ID, to keep the data connection alive.
Normally contains one complete laserscan (a full rotation of the scanner head)
R2000Driver()
Initialize driver.
void disconnect()
Disconnect from the laserscanner and reset internal state.
Allows accessing the HTTP/JSON interface of the Pepperl+Fuchs Laserscanner R2000. ...
std::map< std::string, std::string > parameters_
Cached version of all parameter values.
Definition: r2000_driver.h:167
bool connect(const std::string hostname, int port=80)
bool setParameter(const std::string &name, const std::string &value)
bool is_connected_
Internal connection state.
Definition: r2000_driver.h:149
boost::optional< HandleInfo > handle_info_
Handle information about data connection.
Definition: r2000_driver.h:161
Receives data of the laser range finder via IP socket Receives the scanner data with asynchronous fun...
std::size_t getFullScansAvailable() const
Get the total number of fully received laserscans available.
bool is_capturing_
Internal capturing state.
Definition: r2000_driver.h:152
const std::map< std::string, std::string > & getParameters()
double food_timeout_
Feeding interval (in seconds)
Definition: r2000_driver.h:158


pepperl_fuchs_r2000
Author(s): Denis Dillenberger
autogenerated on Mon Jun 10 2019 14:12:48