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


cob_sick_lms1xx
Author(s): Konrad Banachowicz
autogenerated on Thu Aug 27 2015 12:45:50