main.cc
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 /* Use the namespace */
00023 using namespace std;
00024 using namespace SickToolbox;
00025 
00026 int main (int argc, char *argv[]) {
00027 
00028   /* A string for the IP address */
00029   string sick_ip_addr(DEFAULT_SICK_IP_ADDRESS);
00030 
00031   /* Check the num of args */
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   /* Assign the IP address */
00039   if(argc == 2) {
00040     sick_ip_addr = argv[1];
00041   }
00042 
00043   /* Define the data buffers */
00044   double values[SickLD::SICK_MAX_NUM_MEASUREMENTS] = {0};
00045   unsigned int num_values = 0;
00046 
00047   /* Define the bounds for a single sector */
00048   double sector_start_ang = 90;
00049   double sector_stop_ang = 270;
00050 
00051   /* Define the object */
00052   SickLD sick_ld(sick_ip_addr);
00053 
00054   /*
00055    * Initialize the Sick LD
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     /* Set the desired sector configuration */
00069     sick_ld.SetSickTempScanAreas(&sector_start_ang,&sector_stop_ang,1);
00070     
00071     /* Print the sector configuration */
00072     sick_ld.PrintSickSectorConfig();
00073     
00074     /* Acquire some range measurements */
00075     for (unsigned int i = 0; i < 10; i++) {
00076 
00077       /* Here we only want the range values so the second arg is NULL */
00078       sick_ld.GetSickMeasurements(values,NULL,&num_values);
00079       cout << "\t  Num. Values: " << num_values << endl;    
00080       
00081     }
00082 
00083   }
00084 
00085   /* Catch any exceptions */
00086   catch(...) {
00087     cerr << "An error occurred!" << endl;
00088   }
00089 
00090   /*
00091    * Uninitialize the device
00092    */
00093   try {
00094     sick_ld.Uninitialize();
00095   }
00096   
00097   catch(...) {
00098     cerr << "Uninitialize failed!" << endl;
00099     return -1;
00100   }
00101   
00102   /* Success !*/
00103   return 0;
00104   
00105 }


sicktoolbox
Author(s): Jason Derenick , Thomas Miller
autogenerated on Sun May 5 2019 02:28:23