SickLMS1xx.cc
Go to the documentation of this file.
1 
16 /* Auto-generated header */
18 
19 /* Implementation dependencies */
20 #include <string>
21 #include <cmath>
22 #include <cstdlib>
23 #include <iostream>
24 #include <iomanip>
25 #include <sys/socket.h> // for socket function definitions
26 #include <arpa/inet.h> // for sockaddr_in, inet_addr, and htons
27 #include <sys/ioctl.h> // for using ioctl functionality for the socket input buffer
28 #include <unistd.h> // for select functionality (e.g. FD_SET, etc...)
29 #include <sys/types.h> // for fd data types
30 #include <sys/time.h> // for select timeout parameter
31 #include <fcntl.h> // for getting file flags
32 #include <pthread.h> // for POSIX threads
33 #include <sstream> // for parsing ip addresses
34 #include <vector> // for returning the results of parsed strings
35 #include <errno.h> // for timing connect()
36 #include <stdio.h>
37 
43 
44 /* Associate the namespace */
45 namespace SickToolbox {
46 
52  SickLMS1xx::SickLMS1xx( const std::string sick_ip_address, const uint16_t sick_tcp_port ) :
54  _sick_ip_address(sick_ip_address),
55  _sick_tcp_port(sick_tcp_port),
56  _sick_scan_format(SICK_LMS_1XX_SCAN_FORMAT_UNKNOWN),
57  _sick_device_status(SICK_LMS_1XX_STATUS_UNKNOWN),
58  _sick_temp_safe(false),
59  _sick_streaming(false)
60  {
62  }
63 
68 
73 
74  if (disp_banner) {
75  std::cout << "\t*** Attempting to initialize the Sick LMS 1xx..." << std::endl;
76  }
77 
78  try {
79 
80  /* Attempt to connect to the Sick LD */
81  if (disp_banner) {
82  std::cout << "\tAttempting to connect to Sick LMS 1xx @ " << _sick_ip_address << ":" << _sick_tcp_port << std::endl;
83  }
85  if (disp_banner) {
86  std::cout << "\t\tConnected to Sick LMS 1xx!" << std::endl;
87  }
88 
89  /* Start the buffer monitor */
90  if (disp_banner) {
91  std::cout << "\tAttempting to start buffer monitor..." << std::endl;
92  }
94  if (disp_banner) {
95  std::cout << "\t\tBuffer monitor started!" << std::endl;
96  }
97 
98  /* Ok, lets sync the driver with the Sick */
99  if (disp_banner) {
100  std::cout << "\tSyncing driver with Sick..." << std::endl;
101  }
104  if (disp_banner) {
105  std::cout << "\t\tSuccess!" << std::endl;
106  _printInitFooter();
107  }
108 
109  }
110 
111  catch(SickIOException &sick_io_exception) {
112  std::cerr << sick_io_exception.what() << std::endl;
113  throw;
114  }
115 
116  catch(SickErrorException &sick_error_exception) {
117  std::cerr << sick_error_exception.what() << std::endl;
118  throw;
119  }
120 
121  catch(SickThreadException &sick_thread_exception) {
122  std::cerr << sick_thread_exception.what() << std::endl;
123  throw;
124  }
125 
126  catch(SickTimeoutException &sick_timeout_exception) {
127  std::cerr << sick_timeout_exception.what() << std::endl;
128  throw;
129  }
130 
131  catch(...) {
132  std::cerr << "SickLMS1xx::Initialize - Unknown exception!" << std::endl;
133  throw;
134  }
135 
136  //std::cout << "\t\tSynchronized!" << std::endl;
137  _sick_initialized = true;
138 
139  /* Success */
140  }
141 
150 
151  /* Ensure the device has been initialized */
152  if (!_sick_initialized) {
153  throw SickIOException("SickLMS1xx::SetSickScanFreqAndRes: Device NOT Initialized!!!");
154  }
155 
156  try {
157 
158  /* Is the device streaming? */
159  if (_sick_streaming) {
161  }
162 
163  /* Set the desired configuration */
164  _setSickScanConfig(scan_freq,
165  scan_res,
168 
169  }
170 
171  /* Handle config exceptions */
172  catch (SickErrorException &sick_error_exception) {
173  std::cerr << sick_error_exception.what() << std::endl;
174  throw;
175  }
176 
177  /* Handle a timeout! */
178  catch (SickTimeoutException &sick_timeout_exception) {
179  std::cerr << sick_timeout_exception.what() << std::endl;
180  throw;
181  }
182 
183  /* Handle write buffer exceptions */
184  catch (SickIOException &sick_io_exception) {
185  std::cerr << sick_io_exception.what() << std::endl;
186  throw;
187  }
188 
189  /* A safety net */
190  catch (...) {
191  std::cerr << "SickLMS1xx::SetSickScanFreqAndRes: Unknown exception!!!" << std::endl;
192  throw;
193  }
194 
195  }
196 
202 
203  /* Ensure the device has been initialized */
204  if (!_sick_initialized) {
205  throw SickIOException("SickLMS1xx::GetSickScanFreq: Device NOT Initialized!!!");
206  }
207 
209 
210  }
211 
217 
218  /* Ensure the device has been initialized */
219  if (!_sick_initialized) {
220  throw SickIOException("SickLMS1xx::GetSickScanRes: Device NOT Initialized!!!");
221  }
222 
224 
225  }
226 
232 
233  /* Ensure the device has been initialized */
234  if (!_sick_initialized) {
235  throw SickIOException("SickLMS1xx::GetSickStartAngle: Device NOT Initialized!!!");
236  }
237 
239 
240  }
241 
247 
248  /* Ensure the device has been initialized */
249  if (!_sick_initialized) {
250  throw SickIOException("SickLMS1xx::GetSickStopAngle: Device NOT Initialized!!!");
251  }
252 
254 
255  }
256 
261 
262  /* Ensure the device has been initialized */
263  if (!_sick_initialized) {
264  throw SickIOException("SickLMS1xx::SetSickScanDataFormat: Device NOT Initialized!!!");
265  }
266 
267  /* If scan data format matches current format ignore it (perhaps a warning is in order?) */
268  if (scan_format == _sick_scan_format) {
269  return;
270  }
271 
272  try {
273 
274  /* Is the device streaming? */
275  if (_sick_streaming ) {
277  }
278 
279  std::cout << "\t*** Setting scan format " << _sickScanDataFormatToString(scan_format) << "..." << std::endl;
280 
281  /* Set the desired data format! */
282  _setSickScanDataFormat(scan_format);
283 
284  std::cout << "\t\tSuccess!" << std::endl;
285 
286  }
287 
288  /* Handle a timeout! */
289  catch (SickTimeoutException &sick_timeout_exception) {
290  std::cerr << sick_timeout_exception.what() << std::endl;
291  throw;
292  }
293 
294  /* Handle write buffer exceptions */
295  catch (SickIOException &sick_io_exception) {
296  std::cerr << sick_io_exception.what() << std::endl;
297  throw;
298  }
299 
300  catch (...) {
301  std::cerr << "SickLMS1xx::SetSickScanDataFormat: Unknown exception!!!" << std::endl;
302  throw;
303  }
304 
305  /* Success! */
306 
307  }
308 
316  void SickLMS1xx::GetSickMeasurements( unsigned int * const range_1_vals,
317  unsigned int * const range_2_vals,
318  unsigned int * const reflect_1_vals,
319  unsigned int * const reflect_2_vals,
320  unsigned int & num_measurements,
321  unsigned int * const dev_status ) throw ( SickIOException, SickConfigException, SickTimeoutException ) {
322 
323  /* Ensure the device has been initialized */
324  if (!_sick_initialized) {
325  throw SickIOException("SickLMS1xx::GetSickMeasurements: Device NOT Initialized!!!");
326  }
327 
328  try {
329 
330  /* Is the device already streaming? */
331  if (!_sick_streaming) {
333  }
334 
335  }
336 
337  /* Handle config exceptions */
338  catch (SickConfigException &sick_config_exception) {
339  std::cerr << sick_config_exception.what() << std::endl;
340  throw;
341  }
342 
343  /* Handle a timeout! */
344  catch (SickTimeoutException &sick_timeout_exception) {
345  std::cerr << sick_timeout_exception.what() << std::endl;
346  throw;
347  }
348 
349  /* Handle write buffer exceptions */
350  catch (SickIOException &sick_io_exception) {
351  std::cerr << sick_io_exception.what() << std::endl;
352  throw;
353  }
354 
355  catch (...) {
356  std::cerr << "SickLMS1xx::GetSickMeasurements: Unknown exception!!!" << std::endl;
357  throw;
358  }
359 
360  /* Allocate receive message */
361  SickLMS1xxMessage recv_message;
362 
363  try {
364 
365  /* Grab the next message from the stream */
366  _recvMessage(recv_message);
367 
368  }
369 
370  /* Handle a timeout! */
371  catch (SickTimeoutException &sick_timeout_exception) {
372  std::cerr << sick_timeout_exception.what() << std::endl;
373  throw;
374  }
375 
376  catch (...) {
377  std::cerr << "SickLMS1xx::GetSickMeasurements: Unknown exception!!!" << std::endl;
378  throw;
379  }
380 
381  /* Allocate a single buffer for payload contents */
382  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH+1] = {0};
383 
384  recv_message.GetPayloadAsCStr((char *)payload_buffer);
385 
386  char * payload_str = NULL;
387  unsigned int null_int = 0;
388 
389  /*
390  * Acquire status
391  */
392  if (dev_status != NULL) {
393 
394  payload_str = (char *)&payload_buffer[16];
395  for (unsigned int i = 0; i < 3; i++) {
396  payload_str = _convertNextTokenToUInt(payload_str,null_int);
397  }
398 
399  /* Grab the contaimination value */
400  _convertNextTokenToUInt(payload_str,*dev_status);
401 
402  }
403 
404  /*
405  * Process DIST1
406  */
407  unsigned int num_dist_1_vals = 0;
408  unsigned int num_dist_2_vals = 0;
409  unsigned int num_rssi_1_vals = 0;
410  unsigned int num_rssi_2_vals = 0;
411 
412  /* Locate DIST1 Section */
413  if (range_1_vals != NULL) {
414 
415  const char * substr_dist_1 = "DIST1";
416  unsigned int substr_dist_1_pos = 0;
417  if (!_findSubString((char *)payload_buffer,substr_dist_1,recv_message.GetPayloadLength()+1,5,substr_dist_1_pos)) {
418  throw SickIOException("SickLMS1xx::GetSickMeasurements: _findSubString() failed!");
419  }
420 
421  /* Extract Num DIST1 Values */
422  payload_str = (char *)&payload_buffer[substr_dist_1_pos+6];
423  for (unsigned int i = 0; i < 4; i++) {
424  payload_str = _convertNextTokenToUInt(payload_str,null_int);
425  }
426 
427  payload_str = _convertNextTokenToUInt(payload_str,num_dist_1_vals);
428 
429  /* Grab the DIST1 values */
430  for (unsigned int i = 0; i < num_dist_1_vals; i++) {
431  payload_str = _convertNextTokenToUInt(payload_str,range_1_vals[i]);
432  }
433 
434  }
435 
436  /*
437  * Process DIST2
438  */
439 
440  /* Locate DIST2 Section */
441  if (range_2_vals != NULL) {
442 
443  const char * substr_dist_2 = "DIST2";
444  unsigned int substr_dist_2_pos = 0;
445  if (_findSubString((char *)payload_buffer,substr_dist_2,recv_message.GetPayloadLength()+1,5,substr_dist_2_pos)) {
446 
447  /* Extract Num DIST2 Values */
448  payload_str = (char *)&payload_buffer[substr_dist_2_pos+6];
449  for (unsigned int i = 0; i < 4; i++) {
450  payload_str = _convertNextTokenToUInt(payload_str,null_int);
451  }
452 
453  payload_str = _convertNextTokenToUInt(payload_str,num_dist_2_vals);
454 
455  /* Acquire the DIST2 values */
456  for (unsigned int i = 0; i < num_dist_2_vals; i++) {
457  payload_str = _convertNextTokenToUInt(payload_str,range_2_vals[i]);
458  }
459  }
460  else {
461  std::cerr << "SickLMS1xx::GetSickMeasurements: WARNING! It seems you are expecting double-pulse range values, which are not being streamed! ";
462  std::cerr << "Use SetSickScanDataFormat to configure the LMS 1xx to stream these values - or - set the corresponding buffer input to NULL to avoid this warning." << std::endl;
463  }
464 
465  }
466 
467  /*
468  * Process RSSI1
469  */
470 
471  if (reflect_1_vals != NULL) {
472 
473  /* Locate RSSI1 Section */
474  const char * substr_rssi_1 = "RSSI1";
475  unsigned int substr_rssi_1_pos = 0;
476  if (_findSubString((char *)payload_buffer,substr_rssi_1,recv_message.GetPayloadLength()+1,5,substr_rssi_1_pos)) {
477 
478  /* Extract Num RSSI1 Values */
479  payload_str = (char *)&payload_buffer[substr_rssi_1_pos+6];
480  for (unsigned int i = 0; i < 4; i++) {
481  payload_str = _convertNextTokenToUInt(payload_str,null_int);
482  }
483 
484  payload_str = _convertNextTokenToUInt(payload_str,num_rssi_1_vals);
485 
486  /* Grab the RSSI1 values */
487  for (unsigned int i = 0; i < num_rssi_1_vals; i++) {
488  payload_str = _convertNextTokenToUInt(payload_str,reflect_1_vals[i]);
489  }
490  }
491  else {
492  std::cerr << "SickLMS1xx::GetSickMeasurements: WARNING! It seems you are expecting single-pulse reflectivity values, which are not being streamed! ";
493  std::cerr << "Use SetSickScanDataFormat to configure the LMS 1xx to stream these values - or - set the corresponding buffer input to NULL to avoid this warning." << std::endl;
494  }
495 
496  }
497 
498  /*
499  * Process RSSI2
500  */
501 
502  if (reflect_2_vals != NULL) {
503 
504  /* Locate RSSI2 Section */
505  const char * substr_rssi_2 = "RSSI2";
506  unsigned int substr_rssi_2_pos = 0;
507  if (_findSubString((char *)payload_buffer,substr_rssi_2,recv_message.GetPayloadLength()+1,5,substr_rssi_2_pos)) {
508 
509  /* Extract Num RSSI1 Values */
510  payload_str = (char *)&payload_buffer[substr_rssi_2_pos+6];
511  for (unsigned int i = 0; i < 4; i++) {
512  payload_str = _convertNextTokenToUInt(payload_str,null_int);
513  }
514 
515  payload_str = _convertNextTokenToUInt(payload_str,num_rssi_2_vals);
516 
517  /* Grab the RSSI1 values */
518  for (unsigned int i = 0; i < num_rssi_2_vals; i++) {
519  payload_str = _convertNextTokenToUInt(payload_str,reflect_2_vals[i]);
520  }
521  }
522  else {
523  std::cerr << "SickLMS1xx::GetSickMeasurements: WARNING! It seems you are expecting double-pulse reflectivity values, which are not being streamed! ";
524  std::cerr << "Use SetSickScanDataFormat to configure the LMS 1xx to stream these values - or - set the corresponding buffer input to NULL to avoid this warning." << std::endl;
525  }
526 
527  }
528 
529  /* Assign number of measurements */
530  num_measurements = num_dist_1_vals;
531 
532  /* Success! */
533 
534  }
535 
540 
541  /* Ensure the device has been initialized */
542  if (!_sick_initialized) {
543  throw SickIOException("SickLMS1xx::Uninitialize: Device NOT Initialized!!!");
544  }
545 
546  if (disp_banner) {
547  std::cout << std::endl << "\t*** Attempting to uninitialize the Sick LMS 1xx..." << std::endl;
548  }
549 
550  /* If necessary, tell the Sick LD to stop streaming data */
551  try {
552 
553  /* Is the device streaming? */
554  if (_sick_streaming) {
555  _stopStreamingMeasurements(disp_banner);
556  }
557 
558  /* Attempt to cancel the buffer monitor */
559  if (disp_banner) {
560  std::cout << "\tAttempting to cancel buffer monitor..." << std::endl;
561  }
562  _stopListening();
563  if (disp_banner) {
564  std::cout << "\t\tBuffer monitor canceled!" << std::endl;
565  }
566 
567  /* Attempt to close the tcp connection */
568  if (disp_banner) {
569  std::cout << "\tClosing connection to Sick LMS 1xx..." << std::endl;
570  }
572 
573  if (disp_banner) {
574  std::cout << "\t\tConnection closed!" << std::endl;
575  std::cout << "\t*** Uninit. complete - Sick LMS 1xx is now offline!" << std::endl;
576  }
577 
578  }
579 
580  /* Handle a timeout! */
581  catch (SickTimeoutException &sick_timeout_exception) {
582  std::cerr << sick_timeout_exception.what() << std::endl;
583  throw;
584  }
585 
586  /* Handle I/O exceptions */
587  catch (SickIOException &sick_io_exception) {
588  std::cerr << sick_io_exception.what() << std::endl;
589  throw;
590  }
591 
592  /* Handle a returned error code */
593  catch (SickErrorException &sick_error_exception) {
594  std::cerr << sick_error_exception.what() << std::endl;
595  throw;
596  }
597 
598  /* Handle a returned error code */
599  catch (SickThreadException &sick_thread_exception) {
600  std::cerr << sick_thread_exception.what() << std::endl;
601  throw;
602  }
603 
604  /* A safety net */
605  catch (...) {
606  std::cerr << "SickLMS::Uninitialize: Unknown exception!!!" << std::endl;
607  throw;
608  }
609 
610  /* Mark the device as uninitialized */
611  _sick_initialized = false;
612 
613  /* Success! */
614  }
615 
620 
621  if (scan_freq == 25) {
623  }
624  else if (scan_freq == 50) {
626  }
627 
629 
630  }
631 
636 
637  switch(scan_freq) {
639  return 25;
641  return 50;
642  default:
643  return -1;
644  }
645 
646  }
647 
652 
653  if (scan_res == 0.25) {
655  }
656  else if (scan_res == 0.50) {
658  }
659 
661 
662  }
663 
668 
669  switch(scan_res) {
671  return 0.25;
673  return 0.50;
674  default:
675  return -1;
676  }
677 
678  }
679 
684 
685  /* Create the TCP socket */
686  if ((_sick_fd = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP)) < 0) {
687  throw SickIOException("SickLMS1xx::_setupConnection: socket() failed!");
688  }
689 
690  /* Initialize the buffer */
691  memset(&_sick_inet_address_info,0,sizeof(struct sockaddr_in));
692 
693  /* Setup the Sick LD inet address structure */
694  _sick_inet_address_info.sin_family = AF_INET; // Internet protocol address family
695  _sick_inet_address_info.sin_port = htons(_sick_tcp_port); // TCP port number
696  _sick_inet_address_info.sin_addr.s_addr = inet_addr(_sick_ip_address.c_str()); // Convert ip string to numerical address
697 
698  try {
699 
700  /* Set to non-blocking so we can time connect */
702 
703  /* Try to connect to the Sick LD */
704  int conn_return;
705  if ((conn_return = connect(_sick_fd,(struct sockaddr *)&_sick_inet_address_info,sizeof(struct sockaddr_in))) < 0) {
706 
707  /* Check whether it is b/c it would block */
708  if (errno != EINPROGRESS) {
709  throw SickIOException("SickLMS1xx::_setupConnection: connect() failed!");
710  }
711 
712  /* Use select to wait on the socket */
713  int valid_opt = 0;
714  int num_active_files = 0;
715  struct timeval timeout_val; // This structure will be used for setting our timeout values
716  fd_set file_desc_set; // File descriptor set for monitoring I/O
717 
718  /* Initialize and set the file descriptor set for select */
719  FD_ZERO(&file_desc_set);
720  FD_SET(_sick_fd,&file_desc_set);
721 
722  /* Setup the timeout structure */
723  memset(&timeout_val,0,sizeof(timeout_val)); // Initialize the buffer
724  timeout_val.tv_usec = DEFAULT_SICK_LMS_1XX_CONNECT_TIMEOUT; // Wait for specified time before throwing a timeout
725 
726  /* Wait for the OS to tell us that the connection is established! */
727  num_active_files = select(getdtablesize(),0,&file_desc_set,0,&timeout_val);
728 
729  /* Figure out what to do based on the output of select */
730  if (num_active_files > 0) {
731 
732  /* This is just a sanity check */
733  if (!FD_ISSET(_sick_fd,&file_desc_set)) {
734  throw SickIOException("SickLMS1xx::_setupConnection: Unexpected file descriptor!");
735  }
736 
737  /* Check for any errors on the socket - just to be sure */
738  socklen_t len = sizeof(int);
739  if (getsockopt(_sick_fd,SOL_SOCKET,SO_ERROR,(void*)(&valid_opt),&len) < 0) {
740  throw SickIOException("SickLMS1xx::_setupConnection: getsockopt() failed!");
741  }
742 
743  /* Check whether the opt value indicates error */
744  if (valid_opt) {
745  throw SickIOException("SickLMS1xx::_setupConnection: socket error on connect()!");
746  }
747 
748  }
749  else if (num_active_files == 0) {
750 
751  /* A timeout has occurred! */
752  throw SickTimeoutException("SickLMS1xx::_setupConnection: select() timeout!");
753 
754  }
755  else {
756 
757  /* An error has occurred! */
758  throw SickIOException("SickLMS1xx::_setupConnection: select() failed!");
759 
760  }
761 
762  }
763 
764  /* Restore blocking IO */
765  _setBlockingIO();
766 
767  }
768 
769  catch(SickIOException &sick_io_exception) {
770  std::cerr << sick_io_exception.what() << std::endl;
771  throw;
772  }
773 
774  catch(SickTimeoutException &sick_timeout_exception) {
775  std::cerr << sick_timeout_exception.what() << std::endl;
776  throw;
777  }
778 
779  catch(...) {
780  std::cerr << "SickLMS1xx::_setupConnection - Unknown exception occurred!" << std::endl;
781  throw;
782  }
783 
784  /* Success */
785  }
786 
791 
792  try {
793 
794  //std::cout << "\t*** Reinitializing Sick LMS 1xx..." << std::endl;
795 
796  /* Uninitialize the device */
797  Uninitialize(false);
798 
799  /* Initialize the device */
800  Initialize(false);
801 
802  //std::cout << "\t\tSuccess!" << std::endl;
803 
804  }
805 
806  /* Handle a timeout! */
807  catch (SickTimeoutException &sick_timeout_exception) {
808  std::cerr << sick_timeout_exception.what() << std::endl;
809  throw;
810  }
811 
812  /* Handle write buffer exceptions */
813  catch (SickIOException &sick_io_exception) {
814  std::cerr << sick_io_exception.what() << std::endl;
815  throw;
816  }
817 
818  /* Handle a timeout! */
819  catch (SickThreadException &sick_thread_exception) {
820  std::cerr << sick_thread_exception.what() << std::endl;
821  throw;
822  }
823 
824  /* Handle a timeout! */
825  catch (SickErrorException &sick_error_exception) {
826  std::cerr << sick_error_exception.what() << std::endl;
827  throw;
828  }
829 
830  catch (...) {
831  std::cerr << "SickLMS1xx::_reinitialize: Unknown exception!!!" << std::endl;
832  throw;
833  }
834 
835  }
836 
841 
842  /* Close the socket! */
843  if (close(_sick_fd) < 0) {
844  throw SickIOException("SickLMS1xx::_teardownConnection: close() failed!");
845  }
846 
847  }
848 
853 
854  /* Allocate a single buffer for payload contents */
855  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
856 
857  /* Set the command type */
858  payload_buffer[0] = 's';
859  payload_buffer[1] = 'R';
860  payload_buffer[2] = 'N';
861 
862  payload_buffer[3] = ' ';
863 
864  /* Set the command */
865  payload_buffer[4] = 'S';
866  payload_buffer[5] = 'T';
867  payload_buffer[6] = 'l';
868  payload_buffer[7] = 'm';
869  payload_buffer[8] = 's';
870 
871  /* Construct command message */
872  SickLMS1xxMessage send_message(payload_buffer,9);
873 
874  /* Setup container for recv message */
875  SickLMS1xxMessage recv_message;
876 
877  /* Send message and get reply using parent's method */
878  try {
879 
880  _sendMessageAndGetReply(send_message, recv_message, "sRA", "STlms");
881 
882  }
883 
884  /* Handle a timeout! */
885  catch (SickTimeoutException &sick_timeout_exception) {
886  std::cerr << sick_timeout_exception.what() << std::endl;
887  throw;
888  }
889 
890  /* Handle write buffer exceptions */
891  catch (SickIOException &sick_io_exception) {
892  std::cerr << sick_io_exception.what() << std::endl;
893  throw;
894  }
895 
896  /* A safety net */
897  catch (...) {
898  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
899  throw;
900  }
901 
902  /* Reset the buffer (not necessary, but its better to do so just in case) */
903  memset(payload_buffer,0,9);
904 
905  /* Extract the message payload */
906  recv_message.GetPayload(payload_buffer);
907 
908  _sick_device_status = _intToSickStatus(atoi((char *)&payload_buffer[10]));
909  _sick_temp_safe = (bool)atoi((char *)&payload_buffer[12]);
910 
911  /* Success */
912 
913  }
914 
919 
920  /* Allocate a single buffer for payload contents */
921  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
922 
923  /* Set the command type */
924  payload_buffer[0] = 's';
925  payload_buffer[1] = 'R';
926  payload_buffer[2] = 'N';
927 
928  payload_buffer[3] = ' ';
929 
930  /* Set the command */
931  payload_buffer[4] = 'L';
932  payload_buffer[5] = 'M';
933  payload_buffer[6] = 'P';
934  payload_buffer[7] = 's';
935  payload_buffer[8] = 'c';
936  payload_buffer[9] = 'a';
937  payload_buffer[10] = 'n';
938  payload_buffer[11] = 'c';
939  payload_buffer[12] = 'f';
940  payload_buffer[13] = 'g';
941 
942  /* Construct command message */
943  SickLMS1xxMessage send_message(payload_buffer,14);
944 
945  /* Setup container for recv message */
946  SickLMS1xxMessage recv_message;
947 
948  /* Send message and get reply using parent's method */
949  try {
950 
951  _sendMessageAndGetReply(send_message, recv_message, "sRA", "LMPscancfg");
952 
953  }
954 
955  /* Handle a timeout! */
956  catch (SickTimeoutException &sick_timeout_exception) {
957  std::cerr << sick_timeout_exception.what() << std::endl;
958  throw;
959  }
960 
961  /* Handle write buffer exceptions */
962  catch (SickIOException &sick_io_exception) {
963  std::cerr << sick_io_exception.what() << std::endl;
964  throw;
965  }
966 
967  /* A safety net */
968  catch (...) {
969  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
970  throw;
971  }
972 
973  /* Reset the buffer (not necessary, but its better to do so just in case) */
974  memset(payload_buffer,0,14);
975 
976  /* Extract the message payload */
977  recv_message.GetPayloadAsCStr((char *)payload_buffer);
978 
979  /* Utility variables */
980  uint32_t scan_freq = 0, scan_res = 0;
981  uint32_t sick_start_angle = 0, sick_stop_angle = 0;
982 
983  /*
984  * Grab the scanning frequency
985  */
986  const char * token = NULL;
987  if ((token = strtok((char *)&payload_buffer[15]," ")) == NULL) {
988  throw SickIOException("SickLMS1xx::_getSickConfig: strtok() failed!");
989  }
990 
991  if (sscanf(token,"%x",&scan_freq) == EOF) {
992  throw SickIOException("SickLMS1xx::_getSickConfig: sscanf() failed!");
993  }
994 
995  sick_lms_1xx_scan_freq_t sick_scan_freq;
996  sick_scan_freq = (sick_lms_1xx_scan_freq_t)sick_lms_1xx_to_host_byte_order(scan_freq);
997 
998  /* Ignore the number of segments value (its always 1 for the LMS 1xx) */
999  if ((token = strtok(NULL," ")) == NULL) {
1000  throw SickIOException("SickLMS1xx::_getSickConfig: strtok() failed!");
1001  }
1002 
1003  /*
1004  * Grab the angular resolution
1005  */
1006  if ((token = strtok(NULL," ")) == NULL) {
1007  throw SickIOException("SickLMS1xx::_getSickConfig: strtok() failed!");
1008  }
1009 
1010  if (sscanf(token,"%x",&scan_res) == EOF) {
1011  throw SickIOException("SickLMS1xx::_getSickConfig: sscanf() failed!");
1012  }
1013 
1014  sick_lms_1xx_scan_res_t sick_scan_res;
1015  sick_scan_res = (sick_lms_1xx_scan_res_t)sick_lms_1xx_to_host_byte_order(scan_res);
1016 
1017  /*
1018  * Grab the start angle
1019  */
1020  if ((token = strtok(NULL," ")) == NULL) {
1021  throw SickIOException("SickLMS1xx::_getSickConfig: strtok() failed!");
1022  }
1023 
1024  if (sscanf(token,"%x",&sick_start_angle) == EOF) {
1025  throw SickIOException("SickLMS1xx::_getSickConfig: sscanf() failed!");
1026  }
1027 
1028  sick_start_angle = sick_lms_1xx_to_host_byte_order(sick_start_angle);
1029 
1030  /*
1031  * Grab the stop angle
1032  */
1033  if ((token = strtok(NULL," ")) == NULL) {
1034  throw SickIOException("SickLMS1xx::_getSickConfig: strtok() failed!");
1035  }
1036 
1037  if (sscanf(token,"%x",&sick_stop_angle) == EOF) {
1038  throw SickIOException("SickLMS1xx::_getSickConfig: sscanf() failed!");
1039  }
1040 
1041  sick_stop_angle = sick_lms_1xx_to_host_byte_order(sick_stop_angle);
1042 
1043  /*
1044  * Assign the config values!
1045  */
1046  _sick_scan_config.sick_scan_freq = sick_scan_freq;
1047  _sick_scan_config.sick_scan_res = sick_scan_res;
1048  _sick_scan_config.sick_start_angle = sick_start_angle;
1049  _sick_scan_config.sick_stop_angle = sick_stop_angle;
1050 
1051  /* Success */
1052 
1053  }
1054 
1064  const sick_lms_1xx_scan_res_t scan_res,
1065  const int start_angle, const int stop_angle ) throw( SickTimeoutException, SickIOException, SickErrorException ) {
1066 
1067  /* Verify valid inputs */
1068  if (!_validScanArea(start_angle, stop_angle)) {
1069  throw SickConfigException("SickLMS1xx::_setSickScanConfig - Invalid Sick LMS 1xx Scan Area!");
1070  }
1071 
1072  /* Allocate a single buffer for payload contents */
1073  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1074 
1075  std::cout << std::endl << "\t*** Attempting to configure device..." << std::endl;
1076 
1077  /* Set the command type */
1078  payload_buffer[0] = 's';
1079  payload_buffer[1] = 'M';
1080  payload_buffer[2] = 'N';
1081 
1082  payload_buffer[3] = ' ';
1083 
1084  /* Set the command */
1085  payload_buffer[4] = 'm';
1086  payload_buffer[5] = 'L';
1087  payload_buffer[6] = 'M';
1088  payload_buffer[7] = 'P';
1089  payload_buffer[8] = 's';
1090  payload_buffer[9] = 'e';
1091  payload_buffer[10] = 't';
1092  payload_buffer[11] = 's';
1093  payload_buffer[12] = 'c';
1094  payload_buffer[13] = 'a';
1095  payload_buffer[14] = 'n';
1096  payload_buffer[15] = 'c';
1097  payload_buffer[16] = 'f';
1098  payload_buffer[17] = 'g';
1099 
1100  payload_buffer[18] = ' ';
1101 
1102  /* Desired scanning frequency */
1103  std::string freq_str = int_to_str((int)scan_freq);
1104 
1105  payload_buffer[19] = '+';
1106 
1107  for (int i = 0; i < 4; i++) {
1108  payload_buffer[20+i] = (uint8_t)((freq_str.c_str())[i]);
1109  }
1110 
1111  payload_buffer[24] = ' ';
1112 
1113  /* Desired number of segments (always 1) */
1114  payload_buffer[25] = '+';
1115  payload_buffer[26] = '1';
1116 
1117  payload_buffer[27] = ' ';
1118 
1119  /* Desired angular resolution */
1120  std::string res_str = int_to_str((int)scan_res);
1121 
1122  payload_buffer[28] = '+';
1123 
1124  for (int i = 0; i < 4; i++) {
1125  payload_buffer[29+i] = (uint8_t)((res_str.c_str())[i]);
1126  }
1127 
1128  payload_buffer[33] = ' ';
1129 
1130  /* Desired starting angle */
1131  std::string start_angle_str = int_to_str(start_angle);
1132 
1133  unsigned int idx = 34;
1134  if (start_angle >= 0) {
1135  payload_buffer[idx] = '+';
1136  idx++;
1137  }
1138 
1139  for (int i = 0; i < start_angle_str.length(); idx++, i++) {
1140  payload_buffer[idx] = (uint8_t)(start_angle_str.c_str())[i];
1141  }
1142 
1143  payload_buffer[idx] = ' ';
1144  idx++;
1145 
1146  /* Desired stopping angle */
1147  std::string stop_angle_str = int_to_str(stop_angle);
1148 
1149  if (stop_angle >= 0) {
1150  payload_buffer[idx] = '+';
1151  idx++;
1152  }
1153 
1154  for (int i = 0; i < stop_angle_str.length(); idx++, i++) {
1155  payload_buffer[idx] = (uint8_t)(stop_angle_str.c_str())[i];
1156  }
1157 
1158  /* Construct command message */
1159  SickLMS1xxMessage send_message(payload_buffer,idx);
1160 
1161  /* Setup container for recv message */
1162  SickLMS1xxMessage recv_message;
1163 
1164  try {
1165 
1166  /* Send message and get reply */
1167  _sendMessageAndGetReply(send_message, recv_message, "sAN", "mLMPsetscancfg");
1168 
1169  }
1170 
1171  /* Handle a timeout! */
1172  catch (SickTimeoutException &sick_timeout_exception) {
1173  std::cerr << sick_timeout_exception.what() << std::endl;
1174  throw;
1175  }
1176 
1177  /* Handle write buffer exceptions */
1178  catch (SickIOException &sick_io_exception) {
1179  std::cerr << sick_io_exception.what() << std::endl;
1180  throw;
1181  }
1182 
1183  /* A safety net */
1184  catch (...) {
1185  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
1186  throw;
1187  }
1188 
1189  /* Reset the buffer (not necessary, but its better to do so just in case) */
1190  memset(payload_buffer,0,SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH);
1191 
1192  /* Extract the message payload */
1193  recv_message.GetPayload(payload_buffer);
1194 
1195  /* Check if it worked... */
1196  if (payload_buffer[19] != '0') {
1197  throw SickErrorException("SickLMS1xx::_setSickScanConfig: " + _intToSickConfigErrorStr(atoi((char *)&payload_buffer[19])));
1198  }
1199 
1200  std::cout << "\t\tDevice configured!" << std::endl << std::endl;
1201 
1202  /* Update the scan configuration! */
1203  try {
1204 
1206 
1207  }
1208 
1209  /* Handle a timeout! */
1210  catch (SickTimeoutException &sick_timeout_exception) {
1211  std::cerr << sick_timeout_exception.what() << std::endl;
1212  throw;
1213  }
1214 
1215  /* Handle write buffer exceptions */
1216  catch (SickIOException &sick_io_exception) {
1217  std::cerr << sick_io_exception.what() << std::endl;
1218  throw;
1219  }
1220 
1221  /* A safety net */
1222  catch (...) {
1223  std::cerr << "SickLMS1xx::_setSickScanConfig: Unknown exception!!!" << std::endl;
1224  throw;
1225  }
1226 
1227  /* Success! */
1229 
1230  }
1231 
1232 
1237 
1238  /* Allocate a single buffer for payload contents */
1239  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1240 
1241  /* Set the command type */
1242  payload_buffer[0] = 's';
1243  payload_buffer[1] = 'M';
1244  payload_buffer[2] = 'N';
1245 
1246  payload_buffer[3] = ' ';
1247 
1248  /* Set the command */
1249  payload_buffer[4] = 'S';
1250  payload_buffer[5] = 'e';
1251  payload_buffer[6] = 't';
1252  payload_buffer[7] = 'A';
1253  payload_buffer[8] = 'c';
1254  payload_buffer[9] = 'c';
1255  payload_buffer[10] = 'e';
1256  payload_buffer[11] = 's';
1257  payload_buffer[12] = 's';
1258  payload_buffer[13] = 'M';
1259  payload_buffer[14] = 'o';
1260  payload_buffer[15] = 'd';
1261  payload_buffer[16] = 'e';
1262 
1263  payload_buffer[17] = ' ';
1264 
1265  /* Set as authorized client */
1266  payload_buffer[18] = '0';
1267  payload_buffer[19] = '3';
1268 
1269  payload_buffer[20] = ' ';
1270 
1271  /* Encoded value for client */
1272  payload_buffer[21] = 'F';
1273  payload_buffer[22] = '4';
1274  payload_buffer[23] = '7';
1275  payload_buffer[24] = '2';
1276  payload_buffer[25] = '4';
1277  payload_buffer[26] = '7';
1278  payload_buffer[27] = '4';
1279  payload_buffer[28] = '4';
1280 
1281  /* Construct command message */
1282  SickLMS1xxMessage send_message(payload_buffer,29);
1283 
1284  /* Setup container for recv message */
1285  SickLMS1xxMessage recv_message;
1286 
1287  /* Send message and get reply using parent's method */
1288  try {
1289 
1290  _sendMessageAndGetReply(send_message, recv_message, "sAN", "SetAccessMode");
1291 
1292  }
1293 
1294  /* Handle a timeout! */
1295  catch (SickTimeoutException &sick_timeout_exception) {
1296  std::cerr << sick_timeout_exception.what() << std::endl;
1297  throw;
1298  }
1299 
1300  /* Handle write buffer exceptions */
1301  catch (SickIOException &sick_io_exception) {
1302  std::cerr << sick_io_exception.what() << std::endl;
1303  throw;
1304  }
1305 
1306  /* A safety net */
1307  catch (...) {
1308  std::cerr << "SickLMS1xx::_setAuthorizedClientAccessMode: Unknown exception!!!" << std::endl;
1309  throw;
1310  }
1311 
1312  /* Reset the buffer (not necessary, but its better to do so just in case) */
1313  memset(payload_buffer,0,29);
1314 
1315  /* Extract the message payload */
1316  recv_message.GetPayload(payload_buffer);
1317 
1318  /* Check Response */
1319  if (payload_buffer[18] != '1') {
1320  throw SickErrorException("SickLMS1xx::_setAuthorizedClientAccessMode: Setting Access Mode Failed!");
1321  }
1322 
1323  /* Success! Woohoo! */
1324 
1325  }
1326 
1331 
1332  /* Allocate a single buffer for payload contents */
1333  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1334 
1335  /* Set the command type */
1336  payload_buffer[0] = 's';
1337  payload_buffer[1] = 'M';
1338  payload_buffer[2] = 'N';
1339 
1340  payload_buffer[3] = ' ';
1341 
1342  /* Set the command */
1343  payload_buffer[4] = 'm';
1344  payload_buffer[5] = 'E';
1345  payload_buffer[6] = 'E';
1346  payload_buffer[7] = 'w';
1347  payload_buffer[8] = 'r';
1348  payload_buffer[9] = 'i';
1349  payload_buffer[10] = 't';
1350  payload_buffer[11] = 'e';
1351  payload_buffer[12] = 'a';
1352  payload_buffer[13] = 'l';
1353  payload_buffer[14] = 'l';
1354 
1355  /* Construct command message */
1356  SickLMS1xxMessage send_message(payload_buffer,15);
1357 
1358  /* Setup container for recv message */
1359  SickLMS1xxMessage recv_message;
1360 
1361  try {
1362 
1363  /* Send message and get reply */
1364  _sendMessageAndGetReply(send_message, recv_message, "sAN", "mEEwriteall");
1365 
1366  }
1367 
1368  /* Handle a timeout! */
1369  catch (SickTimeoutException &sick_timeout_exception) {
1370  std::cerr << sick_timeout_exception.what() << std::endl;
1371  throw;
1372  }
1373 
1374  /* Handle write buffer exceptions */
1375  catch (SickIOException &sick_io_exception) {
1376  std::cerr << sick_io_exception.what() << std::endl;
1377  throw;
1378  }
1379 
1380  /* A safety net */
1381  catch (...) {
1382  std::cerr << "SickLMS1xx::_writeToEEPROM: Unknown exception!!!" << std::endl;
1383  throw;
1384  }
1385 
1386  /* Reset the buffer (not necessary, but its better to do so just in case) */
1387  memset(payload_buffer,0,15);
1388 
1389  /* Extract the message payload */
1390  recv_message.GetPayload(payload_buffer);
1391 
1392  /* Check Response */
1393  if (payload_buffer[13] != '1') {
1394  throw SickIOException("SickLMS1xx::_writeToEEPROM: Failed to Write Data!");
1395  }
1396 
1397  /* Success! Woohoo! */
1398 
1399  }
1400 
1405 
1406  /* Allocate a single buffer for payload contents */
1407  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1408 
1409  /* Set the command type */
1410  payload_buffer[0] = 's';
1411  payload_buffer[1] = 'M';
1412  payload_buffer[2] = 'N';
1413  payload_buffer[3] = ' ';
1414 
1415  /* Set the command */
1416  payload_buffer[4] = 'L';
1417  payload_buffer[5] = 'M';
1418  payload_buffer[6] = 'C';
1419  payload_buffer[7] = 's';
1420  payload_buffer[8] = 't';
1421  payload_buffer[9] = 'a';
1422  payload_buffer[10] = 'r';
1423  payload_buffer[11] = 't';
1424  payload_buffer[12] = 'm';
1425  payload_buffer[13] = 'e';
1426  payload_buffer[14] = 'a';
1427  payload_buffer[15] = 's';
1428 
1429  /* Construct command message */
1430  SickLMS1xxMessage send_message(payload_buffer,16);
1431 
1432  /* Setup container for recv message */
1433  SickLMS1xxMessage recv_message;
1434 
1435  try {
1436 
1437  /* Send message and get reply */
1438  _sendMessageAndGetReply(send_message, recv_message, "sAN", "LMCstartmeas");
1439 
1440  }
1441 
1442  /* Handle a timeout! */
1443  catch (SickTimeoutException &sick_timeout_exception) {
1444  std::cerr << sick_timeout_exception.what() << std::endl;
1445  throw;
1446  }
1447 
1448  /* Handle write buffer exceptions */
1449  catch (SickIOException &sick_io_exception) {
1450  std::cerr << sick_io_exception.what() << std::endl;
1451  throw;
1452  }
1453 
1454  /* A safety net */
1455  catch (...) {
1456  std::cerr << "SickLMS1xx::_startMeasuring: Unknown exception!!!" << std::endl;
1457  throw;
1458  }
1459 
1460  /* Reset the buffer (not necessary, but its better to do so just in case) */
1461  memset(payload_buffer,0,16);
1462 
1463  /* Extract the message payload */
1464  recv_message.GetPayload(payload_buffer);
1465 
1466  /* Check if it worked... */
1467  if (payload_buffer[17] != '0') {
1468  throw SickConfigException("SickLMS1xx::_startMeasuring: Unable to start measuring!");
1469  }
1470 
1471  }
1472 
1477 
1478  /* Allocate a single buffer for payload contents */
1479  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1480 
1481  /* Set the command type */
1482  payload_buffer[0] = 's';
1483  payload_buffer[1] = 'M';
1484  payload_buffer[2] = 'N';
1485  payload_buffer[3] = ' ';
1486 
1487  /* Set the command */
1488  payload_buffer[4] = 'L';
1489  payload_buffer[5] = 'M';
1490  payload_buffer[6] = 'C';
1491  payload_buffer[7] = 's';
1492  payload_buffer[8] = 't';
1493  payload_buffer[9] = 'o';
1494  payload_buffer[10] = 'p';
1495  payload_buffer[11] = 'm';
1496  payload_buffer[12] = 'e';
1497  payload_buffer[13] = 'a';
1498  payload_buffer[14] = 's';
1499 
1500  /* Construct command message */
1501  SickLMS1xxMessage send_message(payload_buffer,15);
1502 
1503  /* Setup container for recv message */
1504  SickLMS1xxMessage recv_message;
1505 
1506  try {
1507 
1508  /* Send message and get reply */
1509  _sendMessageAndGetReply(send_message, recv_message, "sAN", "LMCstopmeas");
1510 
1511  }
1512 
1513  /* Handle a timeout! */
1514  catch (SickTimeoutException &sick_timeout_exception) {
1515  std::cerr << sick_timeout_exception.what() << std::endl;
1516  throw;
1517  }
1518 
1519  /* Handle write buffer exceptions */
1520  catch (SickIOException &sick_io_exception) {
1521  std::cerr << sick_io_exception.what() << std::endl;
1522  throw;
1523  }
1524 
1525  /* A safety net */
1526  catch (...) {
1527  std::cerr << "SickLMS1xx::_stopMeasuring: Unknown exception!!!" << std::endl;
1528  throw;
1529  }
1530 
1531  /* Reset the buffer (not necessary, but its better to do so just in case) */
1532  memset(payload_buffer,0,15);
1533 
1534  /* Extract the message payload */
1535  recv_message.GetPayload(payload_buffer);
1536 
1537  /* Check if it worked... */
1538  if (payload_buffer[16] != '0') {
1539  throw SickConfigException("SickLMS1xx::_stopMeasuring: Unable to start measuring!");
1540  }
1541 
1542  }
1543 
1550 
1551  std::cout << std::endl << "\tRequesting data stream..." << std::endl;
1552 
1553  try {
1554 
1555  /* Wait for device to be measuring */
1557 
1558  /* Request the data stream... */
1560 
1561  }
1562 
1563  /* Handle config exceptions */
1564  catch (SickConfigException &sick_config_exception) {
1565  std::cerr << sick_config_exception.what() << std::endl;
1566  throw;
1567  }
1568 
1569  /* Handle a timeout! */
1570  catch (SickTimeoutException &sick_timeout_exception) {
1571  std::cerr << sick_timeout_exception.what() << std::endl;
1572  throw;
1573  }
1574 
1575  /* Handle write buffer exceptions */
1576  catch (SickIOException &sick_io_exception) {
1577  std::cerr << sick_io_exception.what() << std::endl;
1578  throw;
1579  }
1580 
1581  catch (...) {
1582  std::cerr << "SickLMS1xx::SetSickScanArea: Unknown exception!!!" << std::endl;
1583  throw;
1584  }
1585 
1586  std::cout << "\t\tStream started!" << std::endl;
1587 
1588  }
1589 
1590  /*
1591  * \brief Start Streaming Values
1592  */
1594 
1595  /* Allocate a single buffer for payload contents */
1596  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1597 
1598  /* Set the command type */
1599  payload_buffer[0] = 's';
1600  payload_buffer[1] = 'E';
1601  payload_buffer[2] = 'N';
1602  payload_buffer[3] = ' ';
1603 
1604  /* Set the command */
1605  payload_buffer[4] = 'L';
1606  payload_buffer[5] = 'M';
1607  payload_buffer[6] = 'D';
1608  payload_buffer[7] = 's';
1609  payload_buffer[8] = 'c';
1610  payload_buffer[9] = 'a';
1611  payload_buffer[10] = 'n';
1612  payload_buffer[11] = 'd';
1613  payload_buffer[12] = 'a';
1614  payload_buffer[13] = 't';
1615  payload_buffer[14] = 'a';
1616  payload_buffer[15] = ' ';
1617 
1618  /* Start streaming! */
1619  payload_buffer[16] = '1';
1620 
1621  /* Construct command message */
1622  SickLMS1xxMessage send_message(payload_buffer,17);
1623 
1624  /* Setup container for recv message */
1625  SickLMS1xxMessage recv_message;
1626 
1627  try {
1628 
1629  /* Send message and get reply */
1630  _sendMessageAndGetReply(send_message, recv_message, "sSN", "LMDscandata");
1631 
1632  }
1633 
1634  /* Handle a timeout! */
1635  catch (SickTimeoutException &sick_timeout_exception) {
1636  std::cerr << sick_timeout_exception.what() << std::endl;
1637  throw;
1638  }
1639 
1640  /* Handle write buffer exceptions */
1641  catch (SickIOException &sick_io_exception) {
1642  std::cerr << sick_io_exception.what() << std::endl;
1643  throw;
1644  }
1645 
1646  /* A safety net */
1647  catch (...) {
1648  std::cerr << "SickLMS1xx::_startStreamingMeasurements: Unknown exception!!!" << std::endl;
1649  throw;
1650  }
1651 
1652  /* Success! */
1653  _sick_streaming = true;
1654 
1655  }
1656 
1661 
1662  if (disp_banner) {
1663  std::cout << "\tStopping data stream..." << std::endl;
1664  }
1665 
1666  /* Allocate a single buffer for payload contents */
1667  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1668 
1669  /* Set the command type */
1670  payload_buffer[0] = 's';
1671  payload_buffer[1] = 'E';
1672  payload_buffer[2] = 'N';
1673  payload_buffer[3] = ' ';
1674 
1675  /* Set the command */
1676  payload_buffer[4] = 'L';
1677  payload_buffer[5] = 'M';
1678  payload_buffer[6] = 'D';
1679  payload_buffer[7] = 's';
1680  payload_buffer[8] = 'c';
1681  payload_buffer[9] = 'a';
1682  payload_buffer[10] = 'n';
1683  payload_buffer[11] = 'd';
1684  payload_buffer[12] = 'a';
1685  payload_buffer[13] = 't';
1686  payload_buffer[14] = 'a';
1687  payload_buffer[15] = ' ';
1688 
1689  /* Start streaming! */
1690  payload_buffer[16] = '0';
1691 
1692  /* Construct command message */
1693  SickLMS1xxMessage send_message(payload_buffer,17);
1694 
1695  /* Setup container for recv message */
1696  SickLMS1xxMessage recv_message;
1697 
1698  try {
1699 
1700  /* Send message and get reply */
1701  _sendMessage(send_message);
1702 
1703  }
1704 
1705  /* Handle write buffer exceptions */
1706  catch (SickIOException &sick_io_exception) {
1707  std::cerr << sick_io_exception.what() << std::endl;
1708  throw;
1709  }
1710 
1711  /* A safety net */
1712  catch (...) {
1713  std::cerr << "SickLMS1xx::_stopStreamingMeasurements: Unknown exception!!!" << std::endl;
1714  throw;
1715  }
1716 
1717  /* Success! */
1718  if (disp_banner) {
1719  std::cout << "\t\tStream stopped!" << std::endl;
1720  }
1721 
1722  _sick_streaming = false;
1723 
1724  }
1725 
1730  void SickLMS1xx::_checkForMeasuringStatus( unsigned int timeout_value ) throw( SickTimeoutException, SickIOException ) {
1731 
1732  /* Timeval structs for handling timeouts */
1733  struct timeval beg_time, end_time;
1734 
1735  /* Acquire the elapsed time since epoch */
1736  gettimeofday(&beg_time,NULL);
1737 
1738  /* Get device status */
1739  _updateSickStatus( );
1740 
1741  /* Check the shared object */
1742  bool first_pass = true;
1744 
1745  if (first_pass) {
1746 
1747  try {
1748 
1749  /* Tell the device to start measuring ! */
1750  _startMeasuring();
1751  first_pass = false;
1752 
1753  }
1754 
1755  /* Handle a timeout! */
1756  catch (SickTimeoutException &sick_timeout_exception) {
1757  std::cerr << sick_timeout_exception.what() << std::endl;
1758  throw;
1759  }
1760 
1761  /* Handle write buffer exceptions */
1762  catch (SickIOException &sick_io_exception) {
1763  std::cerr << sick_io_exception.what() << std::endl;
1764  throw;
1765  }
1766 
1767  /* A safety net */
1768  catch (...) {
1769  std::cerr << "SickLMS1xx::_checkForMeasuringStatus: Unknown exception!!!" << std::endl;
1770  throw;
1771  }
1772 
1773  }
1774 
1775  /* Sleep a little bit */
1776  usleep(1000);
1777 
1778  /* Check whether the allowed time has expired */
1779  gettimeofday(&end_time,NULL);
1780  if (_computeElapsedTime(beg_time,end_time) > timeout_value) {
1781  throw SickTimeoutException("SickLMS1xx::_checkForMeasuringStatus: Timeout occurred!");
1782  }
1783 
1784  /* Grab the latest device status */
1786 
1787  }
1788 
1789  }
1790 
1795 
1796  /* Allocate a single buffer for payload contents */
1797  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1798 
1799  /* Set the command type */
1800  payload_buffer[0] = 's';
1801  payload_buffer[1] = 'W';
1802  payload_buffer[2] = 'N';
1803  payload_buffer[3] = ' ';
1804 
1805  /* Set the command */
1806  payload_buffer[4] = 'L';
1807  payload_buffer[5] = 'M';
1808  payload_buffer[6] = 'D';
1809  payload_buffer[7] = 's';
1810  payload_buffer[8] = 'c';
1811  payload_buffer[9] = 'a';
1812  payload_buffer[10] = 'n';
1813  payload_buffer[11] = 'd';
1814  payload_buffer[12] = 'a';
1815  payload_buffer[13] = 't';
1816  payload_buffer[14] = 'a';
1817  payload_buffer[15] = 'c';
1818  payload_buffer[16] = 'f';
1819  payload_buffer[17] = 'g';
1820  payload_buffer[18] = ' ';
1821 
1822  /* Specify the channel */
1823  payload_buffer[19] = '0';
1824 
1828  payload_buffer[20] = '1';
1829  }
1830  else {
1831  payload_buffer[20] = '3';
1832  }
1833 
1834  payload_buffer[21] = ' ';
1835 
1836  /* Values should be 0 */
1837  payload_buffer[22] = '0';
1838  payload_buffer[23] = '0';
1839  payload_buffer[24] = ' ';
1840 
1841  /* Send remission values? */
1844  payload_buffer[25] = '0'; // 0 = no, 1 = yes
1845  }
1846  else {
1847  payload_buffer[25] = '1'; // 0 = no, 1 = yes
1848  }
1849  payload_buffer[26] = ' ';
1850 
1851  /* Remission resolution */
1854  payload_buffer[27] = '1'; // 0 = 8bit, 1 = 16bit
1855  }
1856  else {
1857  payload_buffer[27] = '0'; // 0 = 8bit, 1 = 16bit
1858  }
1859  payload_buffer[28] = ' ';
1860 
1861  /* Units (always 0) */
1862  payload_buffer[29] = '0';
1863  payload_buffer[30] = ' ';
1864 
1865  /* Encoder data? */
1866  payload_buffer[31] = '0'; // (00 = no encode data, 01 = channel 1 encoder)
1867  payload_buffer[32] = '0';
1868  payload_buffer[33] = ' ';
1869 
1870  /* These values should be 0 */
1871  payload_buffer[34] = '0';
1872  payload_buffer[35] = '0';
1873  payload_buffer[36] = ' ';
1874 
1875  /* Send position values? */
1876  payload_buffer[37] = '0'; // (0 = no position, 1 = send position)
1877  payload_buffer[38] = ' ';
1878 
1879  /* Send device name? */
1880  payload_buffer[39] = '0'; // (0 = no, 1 = yes)
1881  payload_buffer[40] = ' ';
1882 
1883  /* Send comment? */
1884  payload_buffer[41] = '0'; // (0 = no, 1 = yes)
1885  payload_buffer[42] = ' ';
1886 
1887  /* Send time info? */
1888  payload_buffer[43] = '0'; // (0 = no, 1 = yes)
1889  payload_buffer[44] = ' ';
1890 
1891  /* Send time info? */
1892  payload_buffer[45] = '+'; // +1 = send all scans, +2 every second scan, etc
1893  payload_buffer[46] = '1';
1894 
1895  /* Construct command message */
1896  SickLMS1xxMessage send_message(payload_buffer,47);
1897 
1898  /* Setup container for recv message */
1899  SickLMS1xxMessage recv_message;
1900 
1901  try {
1902 
1903  /* Send message and get reply */
1904  _sendMessageAndGetReply(send_message, recv_message, "sWA", "LMDscandatacfg");
1905 
1906  /* Reinitialize the Sick so it uses the requested format */
1907  _reinitialize();
1908 
1909  /* Set the sick scan data format */
1910  _sick_scan_format = scan_format;
1911 
1912  }
1913 
1914  /* Handle a timeout! */
1915  catch (SickTimeoutException &sick_timeout_exception) {
1916  std::cerr << sick_timeout_exception.what() << std::endl;
1917  throw;
1918  }
1919 
1920  /* Handle write buffer exceptions */
1921  catch (SickIOException &sick_io_exception) {
1922  std::cerr << sick_io_exception.what() << std::endl;
1923  throw;
1924  }
1925 
1926  /* Handle thread exception */
1927  catch (SickThreadException &sick_thread_exception) {
1928  std::cerr << sick_thread_exception.what() << std::endl;
1929  throw;
1930  }
1931 
1932  /* Handle Sick error */
1933  catch (SickErrorException &sick_error_exception) {
1934  std::cerr << sick_error_exception.what() << std::endl;
1935  throw;
1936  }
1937 
1938  catch (...) {
1939  std::cerr << "SickLMS1xx::_setSickScanDataFormat: Unknown exception!!!" << std::endl;
1940  throw;
1941  }
1942 
1943  /* Success! */
1944 
1945  }
1946 
1951 
1952  /* Allocate a single buffer for payload contents */
1953  uint8_t payload_buffer[SickLMS1xxMessage::MESSAGE_PAYLOAD_MAX_LENGTH] = {0};
1954 
1955  /* Set the command type */
1956  payload_buffer[0] = 's';
1957  payload_buffer[1] = 'M';
1958  payload_buffer[2] = 'N';
1959  payload_buffer[3] = ' ';
1960 
1961  /* Set the command */
1962  payload_buffer[4] = 'R';
1963  payload_buffer[5] = 'u';
1964  payload_buffer[6] = 'n';
1965 
1966  /* Construct command message */
1967  SickLMS1xxMessage send_message(payload_buffer,7);
1968 
1969  /* Setup container for recv message */
1970  SickLMS1xxMessage recv_message;
1971 
1972  try {
1973 
1974  /* Send message and get reply */
1975  _sendMessageAndGetReply(send_message, recv_message, "sWA", "LMDscandatacfg");
1976 
1977  }
1978 
1979  /* Handle a timeout! */
1980  catch (SickTimeoutException &sick_timeout_exception) {
1981  std::cerr << sick_timeout_exception.what() << std::endl;
1982  throw;
1983  }
1984 
1985  /* Handle write buffer exceptions */
1986  catch (SickIOException &sick_io_exception) {
1987  std::cerr << sick_io_exception.what() << std::endl;
1988  throw;
1989  }
1990 
1991  /* A safety net */
1992  catch (...) {
1993  std::cerr << "SickLMS1xx::_restoreMeasuringMode: Unknown exception!!!" << std::endl;
1994  throw;
1995  }
1996 
1997  memset(payload_buffer,0,7);
1998  recv_message.GetPayload(payload_buffer);
1999 
2000  /* Check return value */
2001  if (payload_buffer[8] != '0') {
2002  std::cerr << "SickLMS1xx::_restoreMeasuringMode: Unknown exception!!!" << std::endl;
2003  throw;
2004  }
2005 
2006  /* Success! */
2007 
2008  }
2009 
2013  bool SickLMS1xx::_validScanArea( const int start_angle, const int stop_angle ) const {
2014 
2015  /* Ensure stop is greater than start */
2016  if (start_angle >= stop_angle) {
2017  return false;
2018  }
2019 
2020  /* Check angular bounds */
2021  if (start_angle < SICK_LMS_1XX_SCAN_AREA_MIN_ANGLE || start_angle > SICK_LMS_1XX_SCAN_AREA_MAX_ANGLE) {
2022  return false;
2023  }
2024 
2025  /* Check angular bounds */
2026  if (stop_angle < SICK_LMS_1XX_SCAN_AREA_MIN_ANGLE || stop_angle > SICK_LMS_1XX_SCAN_AREA_MAX_ANGLE) {
2027  return false;
2028  }
2029 
2030  /* Valid! */
2031  return true;
2032 
2033  }
2034 
2038  void SickLMS1xx::_sendMessage( const SickLMS1xxMessage &send_message ) const throw( SickIOException ) {
2039 
2040  try {
2041 
2042  /* Send a message using parent's method */
2044 
2045  }
2046 
2047  /* Handle write buffer exceptions */
2048  catch (SickIOException &sick_io_error) {
2049  std::cerr << sick_io_error.what() << std::endl;
2050  throw;
2051  }
2052 
2053  /* A safety net */
2054  catch (...) {
2055  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2056  throw;
2057  }
2058 
2059  /* Success */
2060 
2061  }
2062 
2073  SickLMS1xxMessage &recv_message,
2074  const std::string reply_command_type,
2075  const std::string reply_command,
2076  const unsigned int timeout_value,
2077  const unsigned int num_tries ) throw( SickIOException, SickTimeoutException ) {
2078 
2079  /* Construct the expected string */
2080  std::string expected_str = reply_command_type + " " + reply_command;
2081 
2082  try {
2083 
2084  /* Send a message and get reply using parent's method */
2085  SickLIDAR< SickLMS1xxBufferMonitor, SickLMS1xxMessage >::_sendMessageAndGetReply(send_message,recv_message,(uint8_t *)expected_str.c_str(),expected_str.length(),DEFAULT_SICK_LMS_1XX_BYTE_TIMEOUT,timeout_value,num_tries);
2086 
2087  }
2088 
2089  /* Handle a timeout! */
2090  catch (SickTimeoutException &sick_timeout) {
2091  throw;
2092  }
2093 
2094  /* Handle write buffer exceptions */
2095  catch (SickIOException &sick_io_error) {
2096  std::cerr << sick_io_error.what() << std::endl;
2097  throw;
2098  }
2099 
2100  /* A safety net */
2101  catch (...) {
2102  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2103  throw;
2104  }
2105 
2106  /* Success! */
2107 
2108  }
2109 
2113  void SickLMS1xx::_recvMessage( SickLMS1xxMessage &sick_message ) const throw ( SickTimeoutException ) {
2114 
2115  try {
2116 
2117  /* Receive message using parent's method */
2119 
2120  }
2121 
2122  /* Handle a timeout! */
2123  catch (SickTimeoutException &sick_timeout) {
2124  throw;
2125  }
2126 
2127  /* A safety net */
2128  catch (...) {
2129  std::cerr << "SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2130  throw;
2131  }
2132 
2133  }
2134 
2140  {
2141  switch(status) {
2142  case 1:
2144  case 2:
2146  case 3:
2147  return SICK_LMS_1XX_STATUS_IDLE;
2148  case 4:
2150  case 5:
2152  case 6:
2154  case 7:
2156  default:
2158  }
2159  }
2160 
2162  std::string SickLMS1xx::_intToSickConfigErrorStr( const int error ) const {
2163 
2164  switch(error) {
2165  case 1:
2166  return "Invalid Scan Frequency";
2167  case 2:
2168  return "Invalid Scan Resolution";
2169  case 3:
2170  return "Invalid Scan Frequency and Scan Resolution";
2171  case 4:
2172  return "Invalid Scan Area";
2173  default:
2174  return "Other Error";
2175  }
2176 
2177  }
2178 
2183 
2184  std::cout << "\t========= Sick Scan Config =========" << std::endl;
2185  std::cout << "\tScan Frequency: " << ((double)_sick_scan_config.sick_scan_freq)/100 << "(Hz)" << std::endl;
2186  std::cout << "\tScan Resolution: " << ((double)_sick_scan_config.sick_scan_res)/10000 << " (deg)" << std::endl;
2187  std::cout << "\tScan Area: " << "[" << ((double)_sick_scan_config.sick_start_angle)/10000 << "," << ((double)_sick_scan_config.sick_stop_angle)/10000 << "]" << std::endl;
2188  std::cout << "\t====================================" << std::endl;
2189  std::cout << std::endl << std::flush;
2190  }
2191 
2196 
2197  std::cout << "\t*** Init. complete: Sick LMS 1xx is online and ready!" << std::endl;
2198  std::cout << "\tScan Frequency: " << _convertSickFreqUnitsToHz(_sick_scan_config.sick_scan_freq) << "(Hz)" << std::endl;
2199  std::cout << "\tScan Resolution: " << _convertSickAngleUnitsToDegs(_sick_scan_config.sick_scan_res) << " (deg)" << std::endl;
2200  std::cout << "\tScan Area: " << "[" << _convertSickAngleUnitsToDegs(_sick_scan_config.sick_start_angle) << "," << _convertSickAngleUnitsToDegs(_sick_scan_config.sick_stop_angle) << "]" << std::endl;
2201  std::cout << std::endl;
2202 
2203  }
2204 
2211 
2212  /* Determine the type of distance measurements */
2213  switch (scan_format) {
2215  return "(single-pulse dist, no reflect)";
2217  return "(single-pulse dist, 8Bit reflect)";
2219  return "(single-pulse dist, 16Bit reflect)";
2221  return "(double-pulse dist, no reflect)";
2223  return "(double-pulse dist, 8Bit reflect)";
2225  return "(double-pulse dist, 16Bit reflect)";
2226  default:
2227  return "Unknown";
2228  }
2229 
2230  }
2231 
2242  bool SickLMS1xx::_findSubString( const char * const str, const char * const substr,
2243  const unsigned int str_length, const unsigned int substr_length,
2244  unsigned int &substr_pos, unsigned int start_pos ) const {
2245 
2246  /* Init substring position */
2247  substr_pos = 0;
2248 
2249  /* Look for the substring */
2250  bool substr_found = false;
2251  for (unsigned int i = start_pos; !substr_found && (i < (str_length - substr_length) + 1); i++) {
2252 
2253  unsigned int j = 0;
2254  for (unsigned int k = i; (str[k] == substr[j]) && (j < substr_length); k++, j++);
2255 
2256  if (j == substr_length) {
2257  substr_found = true;
2258  substr_pos = i;
2259  }
2260 
2261  }
2262 
2263  /* Found! */
2264  return substr_found;
2265 
2266  }
2267 
2275  char * SickLMS1xx::_convertNextTokenToUInt( char * const str_buffer, unsigned int & num_val,
2276  const char * const delimeter ) const {
2277 
2278  const char * token = NULL;
2279  uint32_t curr_val = 0;
2280  if ((token = strtok(str_buffer,delimeter)) == NULL) {
2281  throw SickIOException("SickLMS1xx::_getextTokenAsUInt: strtok() failed!");
2282  }
2283 
2284  if (sscanf(token,"%x",&curr_val) == EOF) {
2285  throw SickIOException("SickLMS1xx::_getNextTokenAsUInt: sscanf() failed!");
2286  }
2287 
2288  num_val = (unsigned int)sick_lms_1xx_to_host_byte_order(curr_val);
2289 
2290  return str_buffer + strlen(token) + 1;
2291 
2292  }
2293 
2294 } //namespace SickToolbox
std::string int_to_str(const int value)
Utility function for converting int to standard string.
void _recvMessage(SICK_MSG_CLASS &sick_message, const unsigned int timeout_value) const
Attempt to acquire the latest available message from the device.
Definition: SickLIDAR.hh:301
void _getSickScanConfig()
Get the scan configuration of the Sick LMS 1xx.
Definition: SickLMS1xx.cc:918
sick_lms_1xx_status_t _intToSickStatus(const int status) const
Converts int to status.
Definition: SickLMS1xx.cc:2139
sick_lms_1xx_status_t
Defines the Sick LMS 1xx status. This enum lists all of the Sick LMS 1xx status.
Definition: SickLMS1xx.hh:61
unsigned int GetPayloadLength() const
Definition: SickMessage.hh:68
double GetSickStopAngle() const
Gets the Sick LMS 1xx scan area start angle [-45,270] deg.
Definition: SickLMS1xx.cc:246
sick_lms_1xx_scan_res_t GetSickScanRes() const
Gets the Sick LMS 1xx scan resolution.
Definition: SickLMS1xx.cc:216
void GetSickMeasurements(unsigned int *const range_1_vals, unsigned int *const range_2_vals, unsigned int *const reflect_1_vals, unsigned int *const reflect_2_vals, unsigned int &num_measurements, unsigned int *const dev_status=NULL)
Acquire multi-pulse sick range measurements.
Definition: SickLMS1xx.cc:316
Thrown when Sick returns an error code or an unexpected response.
void _startMeasuring()
Tell the device to start measuring.
Definition: SickLMS1xx.cc:1404
Contains some simple exception classes.
void _checkForMeasuringStatus(unsigned int timeout_value=DEFAULT_SICK_LMS_1XX_STATUS_TIMEOUT)
Attempts to set and waits until device has in measuring status.
Definition: SickLMS1xx.cc:1730
void _sendMessageAndGetReply(const SickLMS1xxMessage &send_message, SickLMS1xxMessage &recv_message, const std::string reply_command_code, const std::string reply_command, const unsigned int timeout_value=DEFAULT_SICK_LMS_1XX_MESSAGE_TIMEOUT, const unsigned int num_tries=1)
Sends a message and searches for the reply with given command type and command.
Definition: SickLMS1xx.cc:2072
void _writeToEEPROM()
Login as an authorized client.
Definition: SickLMS1xx.cc:1330
std::string _intToSickConfigErrorStr(const int error) const
Definition: SickLMS1xx.cc:2162
sick_lms_1xx_scan_freq_t GetSickScanFreq() const
Gets the Sick LMS 1xx scan frequency.
Definition: SickLMS1xx.cc:201
A class for monitoring the receive buffer when interfacing with a Sick LD LIDAR.
char * _convertNextTokenToUInt(char *const str_buffer, unsigned int &num_val, const char *const delimeter=" ") const
Utility function for converting next token into unsigned int.
Definition: SickLMS1xx.cc:2275
void _setSickScanDataFormat(const sick_lms_1xx_scan_format_t scan_format)
Definition: SickLMS1xx.cc:1794
sick_lms_1xx_scan_format_t _sick_scan_format
Definition: SickLMS1xx.hh:200
std::string _sick_ip_address
Definition: SickLMS1xx.hh:188
void _setAuthorizedClientAccessMode()
Login as an authorized client.
Definition: SickLMS1xx.cc:1236
sick_lms_1xx_status_t _sick_device_status
Definition: SickLMS1xx.hh:203
Defines a class for monitoring the receive buffer when interfacing w/ a Sick LMS 1xx laser range find...
void Initialize(const bool disp_banner=true)
Initializes the driver and syncs it with Sick LMS 1xx unit. Uses flash params.
Definition: SickLMS1xx.cc:72
void _setupConnection()
Establish a TCP connection to the unit.
Definition: SickLMS1xx.cc:683
void _requestDataStream()
Request a data data stream type.
Definition: SickLMS1xx.cc:1549
double SickScanResToDouble(const sick_lms_1xx_scan_res_t scan_res) const
Convert sick_lms_1xx_scan_res_t to corresponding double.
Definition: SickLMS1xx.cc:667
int32_t sick_start_angle
Sick scan area start angle.
Definition: SickLMS1xx.hh:183
A structure for aggregrating the Sick LMS 1xx configuration params.
Definition: SickLMS1xx.hh:180
sick_lms_1xx_scan_freq_t sick_scan_freq
Sick scan frequency.
Definition: SickLMS1xx.hh:181
virtual const char * what() const
From the standard exception library.
bool _findSubString(const char *const str, const char *const substr, const unsigned int str_length, const unsigned int substr_length, unsigned int &substr_pos, unsigned int start_pos=0) const
Searches a string for a substring.
Definition: SickLMS1xx.cc:2242
uint16_t sick_lms_1xx_to_host_byte_order(uint16_t value)
Converts Sick LMS byte order (little-endian) to host byte order (little-endian)
void _updateSickStatus()
Get the status of the Sick LMS 1xx.
Definition: SickLMS1xx.cc:852
void _stopMeasuring()
Tell the device to start measuring.
Definition: SickLMS1xx.cc:1476
void GetPayload(uint8_t *const payload_buffer) const
Get the payload contents as a sequence of well-formed bytes.
Definition: SickMessage.hh:156
void _printInitFooter() const
Prints the initialization footer.
Definition: SickLMS1xx.cc:2195
#define DEFAULT_SICK_LMS_1XX_MESSAGE_TIMEOUT
Max time for reply (usecs)
Definition: SickLMS1xx.hh:24
bool _validScanArea(const int start_angle, const int stop_angle) const
Utility function to ensure valid scan area.
Definition: SickLMS1xx.cc:2013
#define SICK_LMS_1XX_SCAN_AREA_MAX_ANGLE
225 degrees (1/10000) degree
Definition: SickLMS1xx.hh:28
void _teardownConnection()
Teardown TCP connection to Sick LMS 1xx.
Definition: SickLMS1xx.cc:840
void _printSickScanConfig() const
Prints Sick LMS 1xx scan configuration.
Definition: SickLMS1xx.cc:2182
struct sockaddr_in _sick_inet_address_info
Definition: SickLMS1xx.hh:194
void _recvMessage(SickLMS1xxMessage &sick_message) const
Receive a message.
Definition: SickLMS1xx.cc:2113
Provides an abstract parent for all Sick LIDAR devices.
Definition: SickLIDAR.hh:53
sick_lms_1xx_scan_res_t DoubleToSickScanRes(const double scan_res) const
Convert double to corresponding sick_lms_1xx_scan_res_t.
Definition: SickLMS1xx.cc:651
void GetPayloadAsCStr(char *const payload_str) const
Definition: SickMessage.hh:162
void Uninitialize(const bool disp_banner=true)
Tear down the connection between the host and the Sick LD.
Definition: SickLMS1xx.cc:539
int32_t sick_stop_angle
Sick scan area stop angle.
Definition: SickLMS1xx.hh:184
int SickScanFreqToInt(const sick_lms_1xx_scan_freq_t scan_freq) const
Convert sick_lms_1xx_scan_freq_t to corresponding integer.
Definition: SickLMS1xx.cc:635
SickLMS1xx(const std::string sick_ip_address=DEFAULT_SICK_LMS_1XX_IP_ADDRESS, const uint16_t sick_tcp_port=DEFAULT_SICK_LMS_1XX_TCP_PORT)
A standard constructor.
Definition: SickLMS1xx.cc:52
void _stopStreamingMeasurements(const bool disp_banner=true)
Stop Measurment Stream.
Definition: SickLMS1xx.cc:1660
sick_lms_1xx_scan_res_t sick_scan_res
Sick scan resolution.
Definition: SickLMS1xx.hh:182
Defines simple utility functions for working with the Sick LMS 1xx laser range finder units...
double GetSickStartAngle() const
Gets the Sick LMS 1xx scan area start angle [-45,270] deg.
Definition: SickLMS1xx.cc:231
sick_lms_1xx_scan_freq_t IntToSickScanFreq(const int scan_freq) const
Convert integer to corresponding sick_lms_1xx_scan_freq_t.
Definition: SickLMS1xx.cc:619
sick_lms_1xx_scan_res_t
Defines the Sick LMS 1xx scan resolution. This enum lists all of the Sick LMS 1xx scan resolutions...
Definition: SickLMS1xx.hh:109
void SetSickScanFreqAndRes(const sick_lms_1xx_scan_freq_t scan_freq, const sick_lms_1xx_scan_res_t scan_res)
Sets the Sick LMS 1xx scan frequency and resolution.
Definition: SickLMS1xx.cc:148
virtual void _sendMessageAndGetReply(const SICK_MSG_CLASS &send_message, SICK_MSG_CLASS &recv_message, const uint8_t *const byte_sequence, const unsigned int byte_sequence_length, const unsigned int byte_interval, const unsigned int timeout_value, const unsigned int num_tries)
Definition: SickLIDAR.hh:396
Encapsulates the Sick LIDAR Matlab/C++ toolbox.
Definition: SickLD.cc:44
sick_lms_1xx_scan_freq_t
Defines the Sick LMS 1xx scan frequency. This enum lists all of the Sick LMS 1xx scan frequencies...
Definition: SickLMS1xx.hh:96
double _convertSickAngleUnitsToDegs(const int sick_angle) const
Definition: SickLMS1xx.hh:291
void _setSickScanConfig(const sick_lms_1xx_scan_freq_t scan_freq, const sick_lms_1xx_scan_res_t scan_res, const int start_angle, const int stop_angle)
Set the Sick LMS 1xx scan configuration (volatile, does not write to EEPROM)
Definition: SickLMS1xx.cc:1063
sick_lms_1xx_scan_config_t _sick_scan_config
Definition: SickLMS1xx.hh:197
void SetSickScanDataFormat(const sick_lms_1xx_scan_format_t scan_format)
Definition: SickLMS1xx.cc:260
void _reinitialize()
Re-initializes the Sick LMS 1xx.
Definition: SickLMS1xx.cc:790
Defines the SickLMS1xx class for working with the Sick LMS1xx laser range finders.
Thrown instance where the driver can&#39;t read,write,drain,flush,... the buffers.
#define DEFAULT_SICK_LMS_1XX_BYTE_TIMEOUT
Max allowable time between consecutive bytes.
double _computeElapsedTime(const struct timeval &beg_time, const struct timeval &end_time) const
Definition: SickLIDAR.hh:115
sick_lms_1xx_scan_format_t
Defines the Sick LMS 1xx scan types This enum is for specifiying the desired scan returns...
Definition: SickLMS1xx.hh:79
Thrown when the driver detects (or the Sick reports) an invalid config.
Makes handling timeouts much easier.
A class to represent all messages sent to and from the Sick LMS 1xx unit.
void _sendMessage(const SickLMS1xxMessage &send_message) const
Sends a message without waiting for reply.
Definition: SickLMS1xx.cc:2038
unsigned int _convertSickFreqUnitsToHz(const unsigned int sick_freq) const
Definition: SickLMS1xx.hh:294
void _sendMessage(const SICK_MSG_CLASS &sick_message, const unsigned int byte_interval) const
Sends a message to the Sick device.
Definition: SickLIDAR.hh:258
Thrown when error occurs during thread initialization, and uninitialization.
#define DEFAULT_SICK_LMS_1XX_CONNECT_TIMEOUT
Max time for establishing connection (usecs)
Definition: SickLMS1xx.hh:23
std::string _sickScanDataFormatToString(const sick_lms_1xx_scan_format_t scan_format) const
Utility function for returning scan format as string.
Definition: SickLMS1xx.cc:2210


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