setConfig.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
38 #include <iostream>
39 
40 #include <boost/lexical_cast.hpp>
41 
42 #include <lms1xx/lms1xx.h>
43 
44 void print_usage() {
45 
46  std::cout << " Usage : " << std::endl;
47  std::cout << " set_config ip resolution rate " << std::endl;
48  std::cout << " Exqample : " << std::endl;
49  std::cout << " set_config 192.168.1.2 0.25 50 " << std::endl;
50 }
51 
52 int main(int argc, char** argv) {
53 
54  LMS1xx laser;
55  scanCfg sCfg;
56 
57  if(argc < 4) {
58  print_usage();
59  return 0;
60  }
61 
62  laser.connect(argv[1]);
63 
64  if(!laser.isConnected()) {
65  std::cout << "Unable to connect to device at address : " << argv[1] << std::endl;
66  return 0;
67  }
68 
69  sCfg.angleResolution = (int)(boost::lexical_cast<double>(std::string(argv[2])) * 10000);
70  sCfg.scaningFrequency = boost::lexical_cast<int>(std::string(argv[3])) * 100;
71 
72  laser.login();
73  laser.setScanCfg(sCfg);
74  laser.saveConfig();
75 
76  sCfg = laser.getScanCfg();
77 
78  std::cout << "Configuration set to : " << std::endl;
79  std::cout << "resolution : " << (double)sCfg.angleResolution/10000.0 << std::endl;
80  std::cout << "frequency : " << (double)sCfg.scaningFrequency/100.0 << std::endl;
81 
82  laser.disconnect();
83 
84  return 0;
85 }
scanCfg getScanCfg() const
Get current scan configuration. Get scan configuration :
Definition: lms1xx.cpp:138
int main(int argc, char **argv)
Definition: lms1xx_node.cpp:40
void login()
Log into LMS1xx unit. Increase privilege level, giving ability to change device configuration.
Definition: lms1xx.cpp:123
Structure containing scan configuration.
void setScanCfg(const scanCfg &cfg)
Set scan configuration. Get scan configuration :
Definition: lms1xx.cpp:158
bool isConnected()
Get status of connection.
Definition: lms1xx.cpp:70
void disconnect()
Disconnect from LMS1xx device.
Definition: lms1xx.cpp:63
void connect(std::string host, int port=2111)
Connect to LMS1xx.
Definition: lms1xx.cpp:44
void saveConfig()
Save data permanently. Parameters are saved in the EEPROM of the LMS and will also be available after...
Definition: lms1xx.cpp:371
Class responsible for communicating with LMS1xx device.
Definition: lms1xx.h:195


lms1xx
Author(s): Konrad Banachowicz
autogenerated on Mon Mar 2 2015 01:32:13