set_config.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 <iostream>
19 
20 #include <boost/lexical_cast.hpp>
21 
22 #include <lms1xx.h>
23 
24 void print_usage() {
25 
26  std::cout << " Usage : " << std::endl;
27  std::cout << " set_config ip resolution rate " << std::endl;
28  std::cout << " Exqample : " << std::endl;
29  std::cout << " set_config 192.168.1.2 0.25 50 " << std::endl;
30 }
31 
32 int main(int argc, char** argv) {
33 
34  LMS1xx laser;
35  scanCfg sCfg;
36 
37  if(argc < 4) {
38  print_usage();
39  return 0;
40  }
41 
42  laser.connect(argv[1]);
43 
44  if(!laser.isConnected()) {
45  std::cout << "Unable to connect to device at address : " << argv[1] << std::endl;
46  return 0;
47  }
48 
49  sCfg.angleResolution = (int)(boost::lexical_cast<double>(std::string(argv[2])) * 10000);
50  sCfg.scaningFrequency = boost::lexical_cast<int>(std::string(argv[3])) * 100;
51 
52  laser.login();
53  laser.setScanCfg(sCfg);
54  laser.saveConfig();
55 
56  sCfg = laser.getScanCfg();
57 
58  std::cout << "Configuration set to : " << std::endl;
59  std::cout << "resolution : " << (double)sCfg.angleResolution/10000.0 << std::endl;
60  std::cout << "frequency : " << (double)sCfg.scaningFrequency/100.0 << std::endl;
61 
62  laser.disconnect();
63 
64  return 0;
65 }
scanCfg getScanCfg() const
Get current scan configuration. Get scan configuration :
Definition: lms1xx.cpp:134
void login()
Log into LMS1xx unit. Increase privilege level, giving ability to change device configuration.
Definition: lms1xx.cpp:119
Structure containing scan configuration.
void setScanCfg(const scanCfg &cfg)
Set scan configuration. Get scan configuration :
Definition: lms1xx.cpp:154
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
void saveConfig()
Save data permanently. Parameters are saved in the EEPROM of the LMS and will also be available after...
Definition: lms1xx.cpp:441
int main(int argc, char **argv)
Definition: set_config.cpp:32
void print_usage()
Definition: set_config.cpp:24
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