Visual Servoing Platform  version 3.6.1 under development (2024-06-12)
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 
104 class VISP_EXPORT vpSickLDMRS : public vpLaserScanner
105 {
106 public:
108  {
109  MagicWordC2 = 0xAFFEC0C2
111  };
112  enum DataType
113  {
114  MeasuredData = 0x2202
116  };
117  vpSickLDMRS();
118 
121  : vpLaserScanner(sick), socket_fd(-1), body(nullptr), vAngle(), time_offset(0), isFirstMeasure(true),
122  maxlen_body(104000)
123  {
124  *this = sick;
125  };
126  virtual ~vpSickLDMRS() vp_override;
127 
129  vpSickLDMRS &operator=(const vpSickLDMRS &sick)
130  {
131  if (this != &sick) {
132  socket_fd = sick.socket_fd;
133  vAngle = sick.vAngle;
134  time_offset = sick.time_offset;
135  isFirstMeasure = sick.isFirstMeasure;
136  maxlen_body = sick.maxlen_body;
137  if (body)
138  delete[] body;
139  body = new unsigned char[104000];
140  memcpy(body, sick.body, maxlen_body);
141  }
142  return (*this);
143  };
144 
145  bool setup(const std::string &ip, int port);
146  bool setup();
147  bool measure(vpLaserScan laserscan[4]);
148 
149 protected:
150 #if defined(_WIN32)
151  SOCKET socket_fd;
152 #else
154 #endif
155  unsigned char *body;
156  vpColVector vAngle; // constant vertical angle for each layer
157  double time_offset;
159  size_t maxlen_body;
160 };
162 #endif
163 
164 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:171
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.
Driver for the Sick LD-MRS laser scanner.
Definition: vpSickLDMRS.h:105
bool isFirstMeasure
Definition: vpSickLDMRS.h:158
unsigned char * body
Definition: vpSickLDMRS.h:155
size_t maxlen_body
Definition: vpSickLDMRS.h:159
vpColVector vAngle
Definition: vpSickLDMRS.h:156
double time_offset
Definition: vpSickLDMRS.h:157
vpSickLDMRS(const vpSickLDMRS &sick)
Definition: vpSickLDMRS.h:120