-
Notifications
You must be signed in to change notification settings - Fork 13
/
LMS1xx.h
305 lines (261 loc) · 6.23 KB
/
LMS1xx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
* LMS1xx.h
*
* Created on: 09-08-2010
* Author: Konrad Banachowicz
***************************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307 USA *
* *
***************************************************************************/
#ifndef LMS1XX_H_
#define LMS1XX_H_
#include <string>
#include <stdint.h>
/*!
* @class scanCfg
* @brief Structure containing scan configuration.
*
* @author Konrad Banachowicz
*/
typedef struct _scanCfg {
/*!
* @brief Scanning frequency.
* 1/100 Hz
*/
int scaningFrequency;
/*!
* @brief Scanning resolution.
* 1/10000 degree
*/
int angleResolution;
/*!
* @brief Start angle.
* 1/10000 degree
*/
int startAngle;
/*!
* @brief Stop angle.
* 1/10000 degree
*/
int stopAngle;
} scanCfg;
/*!
* @class scanDataCfg
* @brief Structure containing scan data configuration.
*
* @author Konrad Banachowicz
*/
typedef struct _scanDataCfg {
/*!
* @brief Output channels.
* Defines which output channel is activated.
*/
int outputChannel;
/*!
* @brief Remission.
* Defines whether remission values are output.
*/
bool remission;
/*!
* @brief Remission resolution.
* Defines whether the remission values are output with 8-bit or 16bit resolution.
*/
int resolution;
/*!
* @brief Encoders channels.
* Defines which output channel is activated.
*/
int encoder;
/*!
* @brief Position.
* Defines whether position values are output.
*/
bool position;
/*!
* @brief Device name.
* Determines whether the device name is to be output.
*/
bool deviceName;
bool timestamp;
/*!
* @brief Output interval.
* Defines which scan is output.
*
* 01 every scan\n
* 02 every 2nd scan\n
* ...\n
* 50000 every 50000th scan
*/
int outputInterval;
} scanDataCfg;
/*!
* @class scanData
* @brief Structure containing single scan message.
*
* @author Konrad Banachowicz
*/
typedef struct _scanData {
/*!
* @brief Number of samples in dist1.
*
*/
int dist_len1;
/*!
* @brief Radial distance for the first reflected pulse
*
*/
uint16_t dist1[1082];
/*!
* @brief Number of samples in dist2.
*
*/
int dist_len2;
/*!
* @brief Radial distance for the second reflected pulse
*
*/
uint16_t dist2[1082];
/*!
* @brief Number of samples in rssi1.
*
*/
int rssi_len1;
/*!
* @brief Remission values for the first reflected pulse
*
*/
uint16_t rssi1[1082];
/*!
* @brief Number of samples in rssi2.
*
*/
int rssi_len2;
/*!
* @brief Remission values for the second reflected pulse
*
*/
uint16_t rssi2[1082];
} scanData;
typedef enum {
undefined = 0,
initialisation = 1,
configuration = 2,
idle = 3,
rotated = 4,
in_preparation = 5,
ready = 6,
ready_for_measurement = 7
} status_t;
/*!
* @class LMS1xx
* @brief Class responsible for communicating with LMS1xx device.
*
* @author Konrad Banachowicz
*/
class LMS1xx {
public:
LMS1xx();
virtual ~LMS1xx();
/*!
* @brief Connect to LMS1xx.
* @param host LMS1xx host name or ip address.
* @param port LMS1xx port number.
*/
void connect(std::string host, int port = 2111);
/*!
* @brief Disconnect from LMS1xx device.
*/
void disconnect();
/*!
* @brief Get status of connection.
* @returns connected or not.
*/
bool isConnected();
/*!
* @brief Start measurements.
* After receiving this command LMS1xx unit starts spinning laser and measuring.
*/
void startMeas();
/*!
* @brief Stop measurements.
* After receiving this command LMS1xx unit stop spinning laser and measuring.
*/
void stopMeas();
/*!
* @brief Get current status of LMS1xx device.
* @returns status of LMS1xx device.
*/
status_t queryStatus();
/*!
* @brief Log into LMS1xx unit.
* Increase privilege level, giving ability to change device configuration.
*/
void login();
/*!
* @brief Get current scan configuration.
* Get scan configuration :
* - scanning frequency.
* - scanning resolution.
* - start angle.
* - stop angle.
* @returns scanCfg structure.
*/
scanCfg getScanCfg() const;
/*!
* @brief Set scan configuration.
* Get scan configuration :
* - scanning frequency.
* - scanning resolution.
* - start angle.
* - stop angle.
* @param cfg structure containing scan configuration.
*/
void setScanCfg(const scanCfg &cfg);
/*!
* @brief Set scan data configuration.
* Set format of scan message returned by device.
* @param cfg structure containing scan data configuration.
*/
void setScanDataCfg(const scanDataCfg &cfg);
/*!
* @brief Start or stop continuous data acquisition.
* After reception of this command device start or stop continuous data stream containing scan messages.
* @param start 1 : start 0 : stop
*/
void scanContinous(int start);
/*!
* @brief Receive single scan message.
*
* @param data pointer to scanData buffer structure.
*/
void getData(scanData& data);
/*!
* @brief Save data permanently.
* Parameters are saved in the EEPROM of the LMS and will also be available after the device is switched off and on again.
*
*/
void saveConfig();
/*!
* @brief The device is returned to the measurement mode after configuration.
*
*/
void startDevice();
private:
bool connected;
bool debug;
int sockDesc;
};
#endif /* LMS1XX_H_ */