25 #define INVALID_OPTION_STRING " Invalid option!!! :o(" 26 #define PROMPT_STRING "lms2xx?> " 90 int main(
int argc,
char * argv[]) {
96 if ((argc != 2 && argc != 3) || (argc == 2 && strcasecmp(argv[1],
"--help") == 0)) {
97 cout <<
"Usage: lms2xx_config PATH [BAUD RATE]" << endl
98 <<
"Ex: lms2xx_config /dev/ttyUSB0 9600" << endl;
104 device_str = argv[1];
109 device_str = argv[1];
110 if ((desired_baud = SickLMS2xx::StringToSickBaud(argv[2])) == SickLMS2xx::SICK_BAUD_UNKNOWN) {
111 cerr <<
"Invalid baud value! Valid values are: 9600, 19200, 38400, and 500000" << endl;
120 cout <<
"The Sick LIDAR C++/Matlab Toolbox " << endl;
121 cout <<
"Sick LMS 2xx Config Utility " << endl;
129 cerr <<
"Initialize failed! Are you using the correct device path?" << endl;
136 cout <<
"NOTE - Configuring the Sick LMS - REQUIRES - writing to the device's EEPROM." << endl;
137 cout <<
" The number of times this can be done is finite (a few thousand)." << endl;
138 cout <<
" Thus, you should configure sparingly." << endl;
143 cout <<
"Enter your choice: (Ctrl-c to exit)" << endl;
144 cout <<
" [1] Set measuring units"<< endl;
145 cout <<
" [2] Set measuring mode"<< endl;
146 cout <<
" [3] Set availability level" << endl;
147 cout <<
" [4] Set sensitivity level" << endl;
148 cout <<
" [5] Show detailed configuration" << endl;
170 if (!is_null_input) {
190 cout <<
"Quitting..." << endl;
201 cerr <<
"Uninitialize failed!" << endl;
206 cout <<
"Thanks for using the Sick LIDAR Matlab/C++ Toolbox!" << endl;
207 cout <<
"Bye Bye :o)" << endl;
218 istringstream input_stream(input_str);
219 input_stream >> int_val;
229 string user_input_str;
230 getline(cin,user_input_str);
233 is_null_input =
true;
234 if (user_input_str.length() > 0) {
235 is_null_input =
false;
247 string user_input_str;
251 cout <<
"This will attempt to write to EEPROM. Continue [y/n]? ";
252 getline(cin,user_input_str);
255 if (user_input_str ==
"Y" || user_input_str ==
"y") {
258 else if (user_input_str ==
"N" || user_input_str ==
"n") {
262 cerr <<
"Please answer [y/n]!" << endl;
274 bool keep_running =
true;
279 cout <<
"Select the desired units:" << endl;
280 cout <<
" [1] Centimeters (cm)"<< endl;
281 cout <<
" [2] Millimeters (mm)"<< endl;
282 cout <<
" [3] Back to main"<< endl;
292 cout <<
" Setting Sick LMS units to (cm)" << endl;
294 cout <<
" Done!" << endl;
299 cout <<
" Setting Sick LMS units to (mm)" << endl;
301 cout <<
" Done!" << endl;
305 keep_running = !keep_running;
308 if (!is_null_input) {
316 cerr <<
"A Sick exception occurred!" << endl;
321 cerr <<
"An unknown exception occurred!" << endl;
325 }
while (keep_running);
334 bool keep_running =
true;
339 cout <<
"Select the desired measuring mode (see telegram listing for descriptions):" << endl;
340 cout <<
" [1] Measurement range 8m/80m; field A, field B, and dazzle" << endl;
341 cout <<
" [2] Measurement range 8m/80m; reflector bits in 8 levels" << endl;
342 cout <<
" [3] Measurement range 8m/80m; field A, field B and field C" << endl;
343 cout <<
" [4] Measurement range 16m/theoretically 160m; reflector bits in 4 levels" << endl;
344 cout <<
" [5] Measurement range 16m/theoretically 160m; field A and field B" << endl;
345 cout <<
" [6] Measurement range 32m/theoretically 320m; reflector bits in 2 levels" << endl;
346 cout <<
" [7] Measurement range 32m/theoretically 320m; field A" << endl;
347 cout <<
" [8] Measurement range 32m/theoretically 320m; Immediate" << endl;
348 cout <<
" [9] Reflectivity/Intensity values" << endl;
349 cout <<
" [10] Back to main" << endl;
359 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 8m/80m; field A, field B, and dazzle" << endl;
361 cout <<
" Done!" << endl;
366 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 8m/80m; reflector bits in 8 levels" << endl;
368 cout <<
" Done!" << endl;
373 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 8m/80m; field A, field B and field C" << endl;
375 cout <<
" Done!" << endl;
380 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 16m/theoretically 160m; reflector bits in 4 levels" << endl;
382 cout <<
" Done!" << endl;
387 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 16m/theoretically 160m; field A and field B" << endl;
389 cout <<
" Done!" << endl;
394 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 32m/theoretically 320m; reflector bit in 2 levels" << endl;
396 cout <<
" Done!" << endl;
401 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 32m/theoretically 320m; field A" << endl;
403 cout <<
" Done!" << endl;
408 cout <<
" Setting Sick LMS Meas. Mode to: Measurement range 32m/theoretically 320m; Immediate" << endl;
410 cout <<
" Done!" << endl;
415 cout <<
" Setting Sick LMS Meas. Mode to: Reflectivity/Intensity" << endl;
417 cout <<
" Done!" << endl;
421 keep_running = !keep_running;
424 if (!is_null_input) {
432 cerr <<
"A Sick exception occurred!" << endl;
437 cerr <<
"An unknown exception occurred!" << endl;
441 }
while (keep_running);
450 bool keep_running =
true;
455 cout <<
"Select the desired availability (see telegram listing for descriptions):" << endl;
456 cout <<
" [1] Restore to factory default" << endl;
457 cout <<
" [2] High" << endl;
458 cout <<
" [3] High w/ Real-time indices" << endl;
459 cout <<
" [4] High w/ No effect dazzle" << endl;
460 cout <<
" [5] High w/ Real-time indices and No effect dazzle" << endl;
461 cout <<
" [6] Real-time indices" << endl;
462 cout <<
" [7] Real-time indices w/ No effect dazzle" << endl;
463 cout <<
" [8] No effect dazzle" << endl;
464 cout <<
" [9] Back to main" << endl;
474 cout <<
" Setting Sick LMS Availability to: Factory settings" << endl;
476 cout <<
" Done!" << endl;
481 cout <<
" Setting Sick LMS Availability to: High" << endl;
483 cout <<
" Done!" << endl;
488 cout <<
" Setting Sick LMS Availability to: High w/ Real-time indices" << endl;
489 sick_lms_2xx->
SetSickAvailability(SickLMS2xx::SICK_FLAG_AVAILABILITY_HIGH | SickLMS2xx::SICK_FLAG_AVAILABILITY_REAL_TIME_INDICES);
490 cout <<
" Done!" << endl;
495 cout <<
" Setting Sick LMS Availability to: High w/ No effect dazzle" << endl;
496 sick_lms_2xx->
SetSickAvailability(SickLMS2xx::SICK_FLAG_AVAILABILITY_HIGH | SickLMS2xx::SICK_FLAG_AVAILABILITY_DAZZLE_NO_EFFECT);
497 cout <<
" Done!" << endl;
502 cout <<
" Setting Sick LMS Availability to: High w/ Real-time indices and No effect dazzle" << endl;
503 sick_lms_2xx->
SetSickAvailability(SickLMS2xx::SICK_FLAG_AVAILABILITY_HIGH | SickLMS2xx::SICK_FLAG_AVAILABILITY_REAL_TIME_INDICES | SickLMS2xx::SICK_FLAG_AVAILABILITY_DAZZLE_NO_EFFECT);
504 cout <<
" Done!" << endl;
509 cout <<
" Setting Sick LMS Availability to: Real-time indices" << endl;
511 cout <<
" Done!" << endl;
516 cout <<
" Setting Sick LMS Availability to: Real-time indices w/ No effect dazzle" << endl;
517 sick_lms_2xx->
SetSickAvailability(SickLMS2xx::SICK_FLAG_AVAILABILITY_REAL_TIME_INDICES | SickLMS2xx::SICK_FLAG_AVAILABILITY_DAZZLE_NO_EFFECT);
518 cout <<
" Done!" << endl;
523 cout <<
" Setting Sick LMS Availability to: No effect dazzle" << endl;
525 cout <<
" Done!" << endl;
529 keep_running = !keep_running;
532 if (!is_null_input) {
540 cerr <<
"A Sick exception occurred!" << endl;
545 cerr <<
"An unknown exception occurred!" << endl;
549 }
while (keep_running);
558 bool keep_running =
true;
563 cout <<
"Select the desired sensitivity level:" << endl;
564 cout <<
" [1] High (42m @ 10% reflectivity)"<< endl;
565 cout <<
" [2] Standard (30m @ 10% reflectivity, factory setting)"<< endl;
566 cout <<
" [3] Medium (25m @ 10% reflectivity)"<< endl;
567 cout <<
" [4] Low (20m @ 10% reflectivity)"<< endl;
568 cout <<
" [5] Back to main"<< endl;
578 cout <<
" Setting Sick LMS Sensitivity to: High" << endl;
580 cout <<
" Done!" << endl;
585 cout <<
" Setting Sick LMS Sensitivity to: Standard (Factory setting)" << endl;
587 cout <<
" Done!" << endl;
592 cout <<
" Setting Sick LMS Sensitivity to: Medium" << endl;
594 cout <<
" Done!" << endl;
599 cout <<
" Setting Sick LMS Sensitivity to: Low" << endl;
601 cout <<
" Done!" << endl;
605 keep_running = !keep_running;
608 if (!is_null_input) {
616 cerr <<
"A Sick exception occurred!" << endl;
621 cerr <<
"An unknown exception occurred!" << endl;
625 }
while (keep_running);
int getUserOption(bool &is_null_input)
SickLMS2xx * sick_lms_2xx
void sigintHandler(int signal)
int main(int argc, char *argv[])
#define INVALID_OPTION_STRING
Definition of class SickLMS2xx. Code by Jason C. Derenick and Thomas H. Miller. Contact derenick(at)l...
void setAvailabilityLevel()
Prompts the user and sets the desired availability level via the driver interface.
void setMeasuringUnits()
Prompts the user and sets the desired measuring units via the driver interface.
bool writeToEEPROM()
Confirms the user actually wants to perform write.
void setSensitivityLevel()
Prompts the user and sets the desired sensitivity level via the driver interface. ...
void setMeasuringMode()
Prompts the user and sets the desired measuring mode via the driver interface.
int strToInt(string input_str)