ld/ld_single_sector/src/main.cc
Go to the documentation of this file.
1 
17 #include <stdlib.h>
18 #include <string>
19 #include <iostream>
20 #include <sicktoolbox/SickLD.hh>
21 
22 /* Use the namespace */
23 using namespace std;
24 using namespace SickToolbox;
25 
26 int main (int argc, char *argv[]) {
27 
28  /* A string for the IP address */
29  string sick_ip_addr(DEFAULT_SICK_IP_ADDRESS);
30 
31  /* Check the num of args */
32  if(argc > 2 || (argc == 2 && strcasecmp(argv[1],"--help") == 0)) {
33  cerr << "Usage: ld_single_sector [SICK IP ADDRESS]" << endl
34  << "Ex. ld_single_sector 192.168.1.11" << endl;
35  return -1;
36  }
37 
38  /* Assign the IP address */
39  if(argc == 2) {
40  sick_ip_addr = argv[1];
41  }
42 
43  /* Define the data buffers */
44  double values[SickLD::SICK_MAX_NUM_MEASUREMENTS] = {0};
45  unsigned int num_values = 0;
46 
47  /* Define the bounds for a single sector */
48  double sector_start_ang = 90;
49  double sector_stop_ang = 270;
50 
51  /* Define the object */
52  SickLD sick_ld(sick_ip_addr);
53 
54  /*
55  * Initialize the Sick LD
56  */
57  try {
58  sick_ld.Initialize();
59  }
60 
61  catch(...) {
62  cerr << "Initialize failed! Are you using the correct IP address?" << endl;
63  return -1;
64  }
65 
66  try {
67 
68  /* Set the desired sector configuration */
69  sick_ld.SetSickTempScanAreas(&sector_start_ang,&sector_stop_ang,1);
70 
71  /* Print the sector configuration */
72  sick_ld.PrintSickSectorConfig();
73 
74  /* Acquire some range measurements */
75  for (unsigned int i = 0; i < 10; i++) {
76 
77  /* Here we only want the range values so the second arg is NULL */
78  sick_ld.GetSickMeasurements(values,NULL,&num_values);
79  cout << "\t Num. Values: " << num_values << endl;
80 
81  }
82 
83  }
84 
85  /* Catch any exceptions */
86  catch(...) {
87  cerr << "An error occurred!" << endl;
88  }
89 
90  /*
91  * Uninitialize the device
92  */
93  try {
94  sick_ld.Uninitialize();
95  }
96 
97  catch(...) {
98  cerr << "Uninitialize failed!" << endl;
99  return -1;
100  }
101 
102  /* Success !*/
103  return 0;
104 
105 }
Provides a simple driver interface for working with the Sick LD-OEM/Sick LD-LRS long-range models via...
Definition: SickLD.hh:56
void PrintSickSectorConfig() const
Print the Sick LD&#39;s sector configuration.
Definition: SickLD.cc:1652
#define DEFAULT_SICK_IP_ADDRESS
Default Sick LD INet 4 address.
Definition: SickLD.hh:21
void Initialize()
Initializes the driver and syncs it with Sick LD unit. Uses sector config given in flash...
Definition: SickLD.cc:91
void GetSickMeasurements(double *const range_measurements, unsigned int *const echo_measurements=NULL, unsigned int *const num_measurements=NULL, unsigned int *const sector_ids=NULL, unsigned int *const sector_data_offsets=NULL, double *const sector_step_angles=NULL, double *const sector_start_angles=NULL, double *const sector_stop_angles=NULL, unsigned int *const sector_start_timestamps=NULL, unsigned int *const sector_stop_timestamps=NULL)
Acquires measurements and corresponding sector data from the Sick LD.
Definition: SickLD.cc:740
int main(int argc, char *argv[])
Defines the SickLD class for working with the Sick LD-OEM/LD-LRS long range LIDARs.
Encapsulates the Sick LIDAR Matlab/C++ toolbox.
Definition: SickLD.cc:44
SickLD * sick_ld
void Uninitialize()
Tear down the connection between the host and the Sick LD.
Definition: SickLD.cc:1659
void SetSickTempScanAreas(const double *active_sector_start_angles, const double *const active_sector_stop_angles, const unsigned int num_active_sectors)
Set the temporary scan areas for the Sick LD.
Definition: SickLD.cc:190


sicktoolbox
Author(s): Jason Derenick , Thomas Miller
autogenerated on Tue Sep 10 2019 03:37:34