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 #define NUM_ACTIVE_SECTORS (3)
00024
00025 using namespace std;
00026 using namespace SickToolbox;
00027
00028 int main (int argc, char *argv[]) {
00029
00030
00031 string sick_ip_addr(DEFAULT_SICK_IP_ADDRESS);
00032
00033
00034 if(argc > 2 || (argc == 2 && strcasecmp(argv[1],"--help") == 0)) {
00035 cerr << "Usage: ld_multi_sector [SICK IP ADDRESS]" << endl
00036 << "Ex. ld_multi_sector 192.168.1.11" << endl;
00037 return -1;
00038 }
00039
00040
00041 if(argc == 2) {
00042 sick_ip_addr = argv[1];
00043 }
00044
00045
00046
00047
00048
00049 double sector_start_angs[NUM_ACTIVE_SECTORS] = {45,270,345};
00050 double sector_stop_angs[NUM_ACTIVE_SECTORS] = {90,315,15};
00051
00052
00053 double range_values[SickLD::SICK_MAX_NUM_MEASUREMENTS] = {0};
00054 unsigned int reflect_values[SickLD::SICK_MAX_NUM_MEASUREMENTS] = {0};
00055
00056
00057 unsigned int num_values[NUM_ACTIVE_SECTORS] = {0};
00058 unsigned int data_offsets[NUM_ACTIVE_SECTORS] = {0};
00059 unsigned int sector_ids[NUM_ACTIVE_SECTORS] = {0};
00060
00061
00062 SickLD sick_ld(sick_ip_addr);
00063
00064
00065 try {
00066 sick_ld.Initialize();
00067 }
00068
00069 catch(...) {
00070 cerr << "Initialize failed! Are you using the correct IP address?" << endl;
00071 return -1;
00072 }
00073
00074 try {
00075
00076
00077 sick_ld.SetSickTempScanAreas(sector_start_angs,sector_stop_angs,NUM_ACTIVE_SECTORS);
00078
00079
00080 sick_ld.PrintSickSectorConfig();
00081
00082
00083 for (unsigned int i = 0; i < 10; i++) {
00084
00085
00086 sick_ld.GetSickMeasurements(range_values,reflect_values,num_values,sector_ids,data_offsets);
00087
00088
00089 for (unsigned int i = 0; i < NUM_ACTIVE_SECTORS; i++) {
00090
00091 cout << "\t[Sector ID: " << sector_ids[i]
00092 << ", Num Meas: " << num_values[i]
00093 << ", 1st Range Val: " << range_values[data_offsets[i]]
00094 << ", 1st Reflect Val: " << reflect_values[data_offsets[i]]
00095 << "]" << endl;
00096
00097 }
00098 cout << endl;
00099
00100 }
00101
00102 }
00103
00104
00105 catch(...) {
00106 cerr << "An error occurred!" << endl;
00107 }
00108
00109
00110
00111
00112 try {
00113 sick_ld.Uninitialize();
00114 }
00115
00116 catch(...) {
00117 cerr << "Uninitialize failed!" << endl;
00118 return -1;
00119 }
00120
00121
00122 return 0;
00123
00124 }