test.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 "lms1xx.h"
00019 
00020 #include <iostream>
00021 #include <unistd.h>
00022 
00023 int main()
00024 {
00025         LMS1xx laser;
00026         scanData data;
00027 
00028         laser.connect("192.168.1.2");
00029         if(!laser.isConnected())
00030         {
00031                 std::cout << "connection failend" << std::endl;
00032                 return 0;
00033         }
00034 
00035         std::cout << "Connected to laser" << std::endl;
00036 
00037         std::cout << "Loging in ..." << std::endl;
00038         laser.login();
00039 
00040         laser.stopMeas();
00041 
00042         std::cout << "Geting scan configuration ..." << ::std::endl;
00043         scanCfg c = laser.getScanCfg();
00044 
00045         //std::cout << "Scanning Frequency : " << c.scaningFrequency/100.0 << "Hz AngleResolution : " << c.angleResolution/10000.0 << "deg " << std::endl;
00046 
00047         c.angleResolution = 5000;
00048         c.scaningFrequency = 5000;
00049 
00050         laser.setScanCfg(c);
00051 
00052         scanDataCfg cc;
00053         cc.deviceName = false;
00054         cc.encoder = 0;
00055         cc.outputChannel = 3;
00056         cc.remission = true;
00057         cc.resolution = 0;
00058         cc.position = false;
00059         cc.outputInterval = 1;
00060 
00061         laser.setScanDataCfg(cc);
00062 
00063         int ret = 0;
00064         std::cout << "Start measurements ..." << std::endl;
00065         laser.startMeas();
00066 
00067         std::cout << "Wait for ready status ..." << std::endl;
00068         ret = 0;
00069         while (ret != 7)
00070         {
00071                 ret = laser.queryStatus();
00072                 std::cout << "status : " << ret << std::endl;
00073                 sleep(1);
00074         }
00075         std::cout << "Laser ready" << std::endl;
00076 
00077         std::cout << "Start continuous data transmission ..." << std::endl;
00078         laser.scanContinous(1);
00079 
00080         for(int i =0; i < 3; i++)
00081         {
00082                 std::cout << "Receive data sample ..." << std::endl;
00083                 laser.getData(data);
00084         }
00085 
00086         std::cout << "Stop continuous data transmission ..." << std::endl;
00087         laser.scanContinous(0);
00088 
00089         laser.stopMeas();
00090 
00091         std::cout << "Disconnect from laser" << std::endl;
00092         laser.disconnect();
00093 
00094         return 0;
00095 }


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