main.cc
Go to the documentation of this file.
00001 
00016 #include <stdlib.h>
00017 #include <string>
00018 #include <iostream>
00019 #include <sicktoolbox/SickLMS1xx.hh>
00020 
00021 using namespace std;
00022 using namespace SickToolbox;
00023 
00024 int main(int argc, char* argv[])
00025 {
00026   
00027   /*
00028    * Instantiate an instance
00029    */
00030   SickLMS1xx sick_lms_1xx;
00031 
00032   /*
00033    * Initialize the Sick LMS 2xx
00034    */
00035   try {
00036     sick_lms_1xx.Initialize();
00037   }
00038 
00039   catch(...) {
00040     cerr << "Initialize failed! Are you using the correct IP address?" << endl;
00041     return -1;
00042   }
00043   
00044   try {
00045     unsigned int status = 1;
00046     unsigned int num_measurements = 0;
00047     unsigned int range_1_vals[SickLMS1xx::SICK_LMS_1XX_MAX_NUM_MEASUREMENTS];
00048     unsigned int range_2_vals[SickLMS1xx::SICK_LMS_1XX_MAX_NUM_MEASUREMENTS];
00049     //sick_lms_1xx.SetSickScanFreqAndRes(SickLMS1xx::SICK_LMS_1XX_SCAN_FREQ_25,
00050     //SickLMS1xx::SICK_LMS_1XX_SCAN_RES_25);
00051     //sick_lms_1xx.SetSickScanDataFormat(SickLMS1xx::SICK_LMS_1XX_DIST_DOUBLE_PULSE,
00052     //                                   SickLMS1xx::SICK_LMS_1XX_REFLECT_NONE);
00053     sick_lms_1xx.SetSickScanDataFormat(SickLMS1xx::SICK_LMS_1XX_SCAN_FORMAT_DIST_DOUBLE_PULSE_REFLECT_16BIT);
00054     for (int i = 0; i < 1000; i++) {
00055       sick_lms_1xx.GetSickMeasurements(range_1_vals,range_2_vals,range_1_vals,range_2_vals,num_measurements,&status);
00056       std::cout << i << ": " << num_measurements << " " << status << std::endl;
00057     }
00058   }
00059   
00060   catch(SickConfigException sick_exception) {
00061     std::cout << sick_exception.what() << std::endl;
00062   }
00063 
00064   catch(SickIOException sick_exception) {
00065     std::cout << sick_exception.what() << std::endl;
00066   }
00067 
00068   catch(SickTimeoutException sick_exception) {
00069     std::cout << sick_exception.what() << std::endl;
00070   }
00071   
00072   catch(...) {
00073     cerr << "An Error Occurred!" << endl;
00074     return -1;
00075   }
00076   
00077   
00078   /*
00079    * Uninitialize the device
00080    */
00081   try {
00082     sick_lms_1xx.Uninitialize();
00083   }
00084   
00085   catch(...) {
00086     cerr << "Uninitialize failed!" << endl;
00087     return -1;
00088   }
00089   
00090   /* Success! */
00091   return 0;
00092 
00093 }
00094     


sicktoolbox
Author(s): Jason Derenick , Thomas Miller
autogenerated on Thu Aug 27 2015 15:17:16