test.cpp
Go to the documentation of this file.
00001 /*
00002  * test.cpp
00003  *
00004  *  Created on: 09-08-2010
00005  *  Author: Konrad Banachowicz
00006  ***************************************************************************
00007  *   This library is free software; you can redistribute it and/or         *
00008  *   modify it under the terms of the GNU Lesser General Public            *
00009  *   License as published by the Free Software Foundation; either          *
00010  *   version 2.1 of the License, or (at your option) any later version.    *
00011  *                                                                         *
00012  *   This library is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00015  *   Lesser General Public License for more details.                       *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU Lesser General Public      *
00018  *   License along with this library; if not, write to the Free Software   *
00019  *   Foundation, Inc., 59 Temple Place,                                    *
00020  *   Suite 330, Boston, MA  02111-1307  USA                                *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include "LMS1xx.h"
00025 
00026 #include <iostream>
00027 
00028 int main()
00029 {
00030         LMS1xx laser;
00031         scanData data;
00032 
00033         laser.connect("192.168.1.2");
00034         if(!laser.isConnected())
00035         {
00036                 std::cout << "connection failend" << std::endl;
00037                 return 0;
00038         }
00039 
00040         std::cout << "Connected to laser" << std::endl;
00041 
00042         std::cout << "Loging in ..." << std::endl;
00043         laser.login();
00044 
00045         laser.stopMeas();
00046 
00047         std::cout << "Geting scan configuration ..." << ::std::endl;
00048         scanCfg c = laser.getScanCfg();
00049 
00050         //std::cout << "Scanning Frequency : " << c.scaningFrequency/100.0 << "Hz AngleResolution : " << c.angleResolution/10000.0 << "deg " << std::endl;
00051 
00052         c.angleResolution = 5000;
00053         c.scaningFrequency = 5000;
00054 
00055         laser.setScanCfg(c);
00056 
00057         scanDataCfg cc;
00058         cc.deviceName = false;
00059         cc.encoder = 0;
00060         cc.outputChannel = 3;
00061         cc.remission = true;
00062         cc.resolution = 0;
00063         cc.position = false;
00064         cc.outputInterval = 1;
00065 
00066         laser.setScanDataCfg(cc);
00067 
00068         int ret = 0;
00069         std::cout << "Start measurements ..." << std::endl;
00070         laser.startMeas();
00071 
00072         std::cout << "Wait for ready status ..." << std::endl;
00073         ret = 0;
00074         while (ret != 7)
00075         {
00076                 ret = laser.queryStatus();
00077                 std::cout << "status : " << ret << std::endl;
00078                 sleep(1);
00079         }
00080         std::cout << "Laser ready" << std::endl;
00081 
00082         std::cout << "Start continuous data transmission ..." << std::endl;
00083         laser.scanContinous(1);
00084 
00085         for(int i =0; i < 3; i++)
00086         {
00087                 std::cout << "Receive data sample ..." << std::endl;
00088                 laser.getData(data);
00089         }
00090 
00091         std::cout << "Stop continuous data transmission ..." << std::endl;
00092         laser.scanContinous(0);
00093 
00094         laser.stopMeas();
00095 
00096         std::cout << "Disconnect from laser" << std::endl;
00097         laser.disconnect();
00098 
00099         return 0;
00100 }


liblms1xx
Author(s): Konrad Banachowicz
autogenerated on Mon Oct 6 2014 04:02:58