set_config.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #include <iostream>
00019 
00020 #include <boost/lexical_cast.hpp>
00021 
00022 #include <lms1xx.h>
00023 
00024 void print_usage() {
00025 
00026         std::cout << " Usage : " << std::endl;
00027         std::cout << " set_config ip resolution rate " << std::endl;
00028         std::cout << " Exqample : " << std::endl;
00029         std::cout << " set_config 192.168.1.2 0.25 50 " << std::endl;
00030 }
00031 
00032 int main(int argc, char** argv) {
00033 
00034         LMS1xx laser;
00035         scanCfg sCfg;
00036 
00037         if(argc < 4) {
00038                 print_usage();
00039                 return 0;
00040         }
00041 
00042         laser.connect(argv[1]);
00043 
00044         if(!laser.isConnected()) {
00045                 std::cout << "Unable to connect to device at address : " << argv[1] << std::endl;
00046                 return 0;
00047         }
00048 
00049         sCfg.angleResolution = (int)(boost::lexical_cast<double>(std::string(argv[2])) * 10000);
00050         sCfg.scaningFrequency = boost::lexical_cast<int>(std::string(argv[3])) * 100;
00051 
00052         laser.login();
00053         laser.setScanCfg(sCfg);
00054         laser.saveConfig();
00055 
00056         sCfg = laser.getScanCfg();
00057 
00058         std::cout << "Configuration set to : " << std::endl;
00059         std::cout << "resolution : " << (double)sCfg.angleResolution/10000.0 << std::endl;
00060         std::cout << "frequency : " << (double)sCfg.scaningFrequency/100.0 << std::endl;
00061 
00062         laser.disconnect();
00063 
00064         return 0;
00065 }


cob_sick_lms1xx
Author(s): Konrad Banachowicz
autogenerated on Sat Jun 8 2019 21:02:21