Go to the documentation of this file.00001 
00017 #include <stdlib.h>
00018 #include <string>
00019 #include <iostream>
00020 #include <sicktoolbox/SickLD.hh>
00021 
00022 
00023 using namespace std;
00024 using namespace SickToolbox;
00025 
00026 int main (int argc, char *argv[]) {
00027 
00028   
00029   string sick_ip_addr(DEFAULT_SICK_IP_ADDRESS);
00030 
00031   
00032   if(argc > 2 || (argc == 2 && strcasecmp(argv[1],"--help") == 0)) {
00033     cerr << "Usage: ld_single_sector [SICK IP ADDRESS]" << endl
00034               << "Ex. ld_single_sector 192.168.1.11" << endl;
00035     return -1;
00036   }
00037   
00038   
00039   if(argc == 2) {
00040     sick_ip_addr = argv[1];
00041   }
00042 
00043   
00044   double values[SickLD::SICK_MAX_NUM_MEASUREMENTS] = {0};
00045   unsigned int num_values = 0;
00046 
00047   
00048   double sector_start_ang = 90;
00049   double sector_stop_ang = 270;
00050 
00051   
00052   SickLD sick_ld(sick_ip_addr);
00053 
00054   
00055 
00056 
00057   try {
00058     sick_ld.Initialize();
00059   }
00060   
00061   catch(...) {
00062     cerr << "Initialize failed! Are you using the correct IP address?" << endl;
00063     return -1;
00064   }
00065   
00066   try {
00067 
00068     
00069     sick_ld.SetSickTempScanAreas(§or_start_ang,§or_stop_ang,1);
00070     
00071     
00072     sick_ld.PrintSickSectorConfig();
00073     
00074     
00075     for (unsigned int i = 0; i < 10; i++) {
00076 
00077       
00078       sick_ld.GetSickMeasurements(values,NULL,&num_values);
00079       cout << "\t  Num. Values: " << num_values << endl;    
00080       
00081     }
00082 
00083   }
00084 
00085   
00086   catch(...) {
00087     cerr << "An error occurred!" << endl;
00088   }
00089 
00090   
00091 
00092 
00093   try {
00094     sick_ld.Uninitialize();
00095   }
00096   
00097   catch(...) {
00098     cerr << "Uninitialize failed!" << endl;
00099     return -1;
00100   }
00101   
00102   
00103   return 0;
00104   
00105 }