Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpSickLDMRS.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Sick LD-MRS laser driver.
33  *
34 *****************************************************************************/
35 
42 #ifndef vpSickLDMRS_h
43 #define vpSickLDMRS_h
44 
45 #include <visp3/core/vpConfig.h>
46 
47 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
48 
49 #include <arpa/inet.h>
50 #include <iostream>
51 #include <string.h>
52 #include <vector>
53 
54 #include <visp3/core/vpColVector.h>
55 #include <visp3/core/vpException.h>
56 #include <visp3/sensor/vpLaserScan.h>
57 #include <visp3/sensor/vpLaserScanner.h>
58 #include <visp3/sensor/vpScanPoint.h>
59 
60 BEGIN_VISP_NAMESPACE
108 class VISP_EXPORT vpSickLDMRS : public vpLaserScanner
109 {
110 public:
111  enum MagicWord
112  {
113  MagicWordC2 = 0xAFFEC0C2
115  };
116  enum DataType
117  {
118  MeasuredData = 0x2202
120  };
121  vpSickLDMRS();
122 
124  vpSickLDMRS(const vpSickLDMRS &sick)
125  : vpLaserScanner(sick), socket_fd(-1), body(nullptr), vAngle(), time_offset(0), isFirstMeasure(true),
126  maxlen_body(104000)
127  {
128  *this = sick;
129  };
130  virtual ~vpSickLDMRS() VP_OVERRIDE;
131 
133  vpSickLDMRS &operator=(const vpSickLDMRS &sick)
134  {
135  if (this != &sick) {
136  socket_fd = sick.socket_fd;
137  vAngle = sick.vAngle;
138  time_offset = sick.time_offset;
139  isFirstMeasure = sick.isFirstMeasure;
140  maxlen_body = sick.maxlen_body;
141  if (body)
142  delete[] body;
143  body = new unsigned char[104000];
144  memcpy(body, sick.body, maxlen_body);
145  }
146  return (*this);
147  };
148 
149  bool setup(const std::string &ip, int port);
150  bool setup();
151  bool measure(vpLaserScan laserscan[4]);
152 
153 protected:
154 #if defined(_WIN32)
155  SOCKET socket_fd;
156 #else
157  int socket_fd;
158 #endif
159  unsigned char *body;
160  vpColVector vAngle; // constant vertical angle for each layer
161  double time_offset;
162  bool isFirstMeasure;
163  size_t maxlen_body;
164 };
165 END_VISP_NAMESPACE
166 #endif
167 
168 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Implements a laser scan data structure that contains especially the list of scanned points that have ...
Definition: vpLaserScan.h:65
Class that defines a generic laser scanner.