test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include "lms1xx.h"
19 
20 #include <iostream>
21 #include <unistd.h>
22 
23 int main()
24 {
25  LMS1xx laser;
26  scanData data;
27 
28  laser.connect("192.168.1.2");
29  if(!laser.isConnected())
30  {
31  std::cout << "connection failend" << std::endl;
32  return 0;
33  }
34 
35  std::cout << "Connected to laser" << std::endl;
36 
37  std::cout << "Loging in ..." << std::endl;
38  laser.login();
39 
40  laser.stopMeas();
41 
42  std::cout << "Geting scan configuration ..." << ::std::endl;
43  scanCfg c = laser.getScanCfg();
44 
45  //std::cout << "Scanning Frequency : " << c.scaningFrequency/100.0 << "Hz AngleResolution : " << c.angleResolution/10000.0 << "deg " << std::endl;
46 
47  c.angleResolution = 5000;
48  c.scaningFrequency = 5000;
49 
50  laser.setScanCfg(c);
51 
52  scanDataCfg cc;
53  cc.deviceName = false;
54  cc.encoder = 0;
55  cc.outputChannel = 3;
56  cc.remission = true;
57  cc.resolution = 0;
58  cc.position = false;
59  cc.outputInterval = 1;
60 
61  laser.setScanDataCfg(cc);
62 
63  int ret = 0;
64  std::cout << "Start measurements ..." << std::endl;
65  laser.startMeas();
66 
67  std::cout << "Wait for ready status ..." << std::endl;
68  ret = 0;
69  while (ret != 7)
70  {
71  ret = laser.queryStatus();
72  std::cout << "status : " << ret << std::endl;
73  sleep(1);
74  }
75  std::cout << "Laser ready" << std::endl;
76 
77  std::cout << "Start continuous data transmission ..." << std::endl;
78  laser.scanContinous(1);
79 
80  for(int i =0; i < 3; i++)
81  {
82  std::cout << "Receive data sample ..." << std::endl;
83  laser.getData(data);
84  }
85 
86  std::cout << "Stop continuous data transmission ..." << std::endl;
87  laser.scanContinous(0);
88 
89  laser.stopMeas();
90 
91  std::cout << "Disconnect from laser" << std::endl;
92  laser.disconnect();
93 
94  return 0;
95 }
void setScanDataCfg(const scanDataCfg &cfg)
Set scan data configuration. Set format of scan message returned by device.
Definition: lms1xx.cpp:167
scanCfg getScanCfg() const
Get current scan configuration. Get scan configuration :
Definition: lms1xx.cpp:134
status_t queryStatus()
Get current status of LMS1xx device.
Definition: lms1xx.cpp:100
void login()
Log into LMS1xx unit. Increase privilege level, giving ability to change device configuration.
Definition: lms1xx.cpp:119
void stopMeas()
Stop measurements. After receiving this command LMS1xx unit stop spinning laser and measuring...
Definition: lms1xx.cpp:85
Structure containing single scan message.
int main()
Definition: test.cpp:23
Structure containing scan configuration.
void setScanCfg(const scanCfg &cfg)
Set scan configuration. Get scan configuration :
Definition: lms1xx.cpp:154
void scanContinous(int start)
Start or stop continuous data acquisition. After reception of this command device start or stop conti...
Definition: lms1xx.cpp:181
void startMeas()
Start measurements. After receiving this command LMS1xx unit starts spinning laser and measuring...
Definition: lms1xx.cpp:70
bool isConnected()
Get status of connection.
Definition: lms1xx.cpp:66
void disconnect()
Disconnect from LMS1xx device.
Definition: lms1xx.cpp:59
void connect(std::string host, int port=2111)
Connect to LMS1xx.
Definition: lms1xx.cpp:40
bool getData(scanData &data)
Receive single scan message.
Definition: lms1xx.cpp:203
Structure containing scan data configuration.
Class responsible for communicating with LMS1xx device.
Definition: lms1xx.h:189


cob_sick_lms1xx
Author(s): Konrad Banachowicz
autogenerated on Wed Apr 7 2021 02:11:49