Visual Servoing Platform  version 3.6.1 under development (2024-03-28)
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 #ifndef vpSickLDMRS_h
36 #define vpSickLDMRS_h
37 
38 #include <visp3/core/vpConfig.h>
39 
40 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
41 
42 #include <arpa/inet.h>
43 #include <iostream>
44 #include <string.h>
45 #include <vector>
46 
47 #include <visp3/core/vpColVector.h>
48 #include <visp3/core/vpException.h>
49 #include <visp3/sensor/vpLaserScan.h>
50 #include <visp3/sensor/vpLaserScanner.h>
51 #include <visp3/sensor/vpScanPoint.h>
52 
102 class VISP_EXPORT vpSickLDMRS : public vpLaserScanner
103 {
104 public:
106  {
107  MagicWordC2 = 0xAFFEC0C2
109  };
110  enum DataType
111  {
112  MeasuredData = 0x2202
114  };
115  vpSickLDMRS();
116 
119  : vpLaserScanner(sick), socket_fd(-1), body(nullptr), vAngle(), time_offset(0), isFirstMeasure(true),
120  maxlen_body(104000)
121  {
122  *this = sick;
123  };
124  virtual ~vpSickLDMRS() vp_override;
125 
127  vpSickLDMRS &operator=(const vpSickLDMRS &sick)
128  {
129  if (this != &sick) {
130  socket_fd = sick.socket_fd;
131  vAngle = sick.vAngle;
132  time_offset = sick.time_offset;
133  isFirstMeasure = sick.isFirstMeasure;
134  maxlen_body = sick.maxlen_body;
135  if (body)
136  delete[] body;
137  body = new unsigned char[104000];
138  memcpy(body, sick.body, maxlen_body);
139  }
140  return (*this);
141  };
142 
143  bool setup(const std::string &ip, int port);
144  bool setup();
145  bool measure(vpLaserScan laserscan[4]);
146 
147 protected:
148 #if defined(_WIN32)
149  SOCKET socket_fd;
150 #else
152 #endif
153  unsigned char *body;
154  vpColVector vAngle; // constant vertical angle for each layer
155  double time_offset;
157  size_t maxlen_body;
158 };
159 
160 #endif
161 
162 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Implements a laser scan data structure that contains especially the list of scanned points that have ...
Definition: vpLaserScan.h:62
Class that defines a generic laser scanner.
Driver for the Sick LD-MRS laser scanner.
Definition: vpSickLDMRS.h:103
bool isFirstMeasure
Definition: vpSickLDMRS.h:156
unsigned char * body
Definition: vpSickLDMRS.h:153
size_t maxlen_body
Definition: vpSickLDMRS.h:157
vpColVector vAngle
Definition: vpSickLDMRS.h:154
double time_offset
Definition: vpSickLDMRS.h:155
vpSickLDMRS(const vpSickLDMRS &sick)
Definition: vpSickLDMRS.h:118