25 #include <sys/socket.h> 26 #include <arpa/inet.h> 27 #include <sys/ioctl.h> 29 #include <sys/types.h> 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)
75 std::cout <<
"\t*** Attempting to initialize the Sick LMS 1xx..." << std::endl;
86 std::cout <<
"\t\tConnected to Sick LMS 1xx!" << std::endl;
91 std::cout <<
"\tAttempting to start buffer monitor..." << std::endl;
95 std::cout <<
"\t\tBuffer monitor started!" << std::endl;
100 std::cout <<
"\tSyncing driver with Sick..." << std::endl;
105 std::cout <<
"\t\tSuccess!" << std::endl;
112 std::cerr << sick_io_exception.
what() << std::endl;
117 std::cerr << sick_error_exception.
what() << std::endl;
122 std::cerr << sick_thread_exception.
what() << std::endl;
127 std::cerr << sick_timeout_exception.
what() << std::endl;
132 std::cerr <<
"SickLMS1xx::Initialize - Unknown exception!" << std::endl;
153 throw SickIOException(
"SickLMS1xx::SetSickScanFreqAndRes: Device NOT Initialized!!!");
173 std::cerr << sick_error_exception.
what() << std::endl;
179 std::cerr << sick_timeout_exception.
what() << std::endl;
185 std::cerr << sick_io_exception.
what() << std::endl;
191 std::cerr <<
"SickLMS1xx::SetSickScanFreqAndRes: Unknown exception!!!" << std::endl;
205 throw SickIOException(
"SickLMS1xx::GetSickScanFreq: Device NOT Initialized!!!");
220 throw SickIOException(
"SickLMS1xx::GetSickScanRes: Device NOT Initialized!!!");
235 throw SickIOException(
"SickLMS1xx::GetSickStartAngle: Device NOT Initialized!!!");
250 throw SickIOException(
"SickLMS1xx::GetSickStopAngle: Device NOT Initialized!!!");
264 throw SickIOException(
"SickLMS1xx::SetSickScanDataFormat: Device NOT Initialized!!!");
284 std::cout <<
"\t\tSuccess!" << std::endl;
290 std::cerr << sick_timeout_exception.
what() << std::endl;
296 std::cerr << sick_io_exception.
what() << std::endl;
301 std::cerr <<
"SickLMS1xx::SetSickScanDataFormat: Unknown exception!!!" << std::endl;
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,
325 throw SickIOException(
"SickLMS1xx::GetSickMeasurements: Device NOT Initialized!!!");
339 std::cerr << sick_config_exception.
what() << std::endl;
345 std::cerr << sick_timeout_exception.
what() << std::endl;
351 std::cerr << sick_io_exception.
what() << std::endl;
356 std::cerr <<
"SickLMS1xx::GetSickMeasurements: Unknown exception!!!" << std::endl;
372 std::cerr << sick_timeout_exception.
what() << std::endl;
377 std::cerr <<
"SickLMS1xx::GetSickMeasurements: Unknown exception!!!" << std::endl;
386 char * payload_str = NULL;
387 unsigned int null_int = 0;
392 if (dev_status != NULL) {
394 payload_str = (
char *)&payload_buffer[16];
395 for (
unsigned int i = 0; i < 3; i++) {
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;
413 if (range_1_vals != NULL) {
415 const char * substr_dist_1 =
"DIST1";
416 unsigned int substr_dist_1_pos = 0;
418 throw SickIOException(
"SickLMS1xx::GetSickMeasurements: _findSubString() failed!");
422 payload_str = (
char *)&payload_buffer[substr_dist_1_pos+6];
423 for (
unsigned int i = 0; i < 4; i++) {
430 for (
unsigned int i = 0; i < num_dist_1_vals; i++) {
441 if (range_2_vals != NULL) {
443 const char * substr_dist_2 =
"DIST2";
444 unsigned int substr_dist_2_pos = 0;
448 payload_str = (
char *)&payload_buffer[substr_dist_2_pos+6];
449 for (
unsigned int i = 0; i < 4; i++) {
456 for (
unsigned int i = 0; i < num_dist_2_vals; i++) {
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;
471 if (reflect_1_vals != NULL) {
474 const char * substr_rssi_1 =
"RSSI1";
475 unsigned int substr_rssi_1_pos = 0;
479 payload_str = (
char *)&payload_buffer[substr_rssi_1_pos+6];
480 for (
unsigned int i = 0; i < 4; i++) {
487 for (
unsigned int i = 0; i < num_rssi_1_vals; i++) {
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;
502 if (reflect_2_vals != NULL) {
505 const char * substr_rssi_2 =
"RSSI2";
506 unsigned int substr_rssi_2_pos = 0;
510 payload_str = (
char *)&payload_buffer[substr_rssi_2_pos+6];
511 for (
unsigned int i = 0; i < 4; i++) {
518 for (
unsigned int i = 0; i < num_rssi_2_vals; i++) {
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;
530 num_measurements = num_dist_1_vals;
543 throw SickIOException(
"SickLMS1xx::Uninitialize: Device NOT Initialized!!!");
547 std::cout << std::endl <<
"\t*** Attempting to uninitialize the Sick LMS 1xx..." << std::endl;
560 std::cout <<
"\tAttempting to cancel buffer monitor..." << std::endl;
564 std::cout <<
"\t\tBuffer monitor canceled!" << std::endl;
569 std::cout <<
"\tClosing connection to Sick LMS 1xx..." << std::endl;
574 std::cout <<
"\t\tConnection closed!" << std::endl;
575 std::cout <<
"\t*** Uninit. complete - Sick LMS 1xx is now offline!" << std::endl;
582 std::cerr << sick_timeout_exception.
what() << std::endl;
588 std::cerr << sick_io_exception.
what() << std::endl;
594 std::cerr << sick_error_exception.
what() << std::endl;
600 std::cerr << sick_thread_exception.
what() << std::endl;
606 std::cerr <<
"SickLMS::Uninitialize: Unknown exception!!!" << std::endl;
621 if (scan_freq == 25) {
624 else if (scan_freq == 50) {
653 if (scan_res == 0.25) {
656 else if (scan_res == 0.50) {
686 if ((
_sick_fd = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP)) < 0) {
687 throw SickIOException(
"SickLMS1xx::_setupConnection: socket() failed!");
708 if (errno != EINPROGRESS) {
709 throw SickIOException(
"SickLMS1xx::_setupConnection: connect() failed!");
714 int num_active_files = 0;
715 struct timeval timeout_val;
716 fd_set file_desc_set;
719 FD_ZERO(&file_desc_set);
723 memset(&timeout_val,0,
sizeof(timeout_val));
727 num_active_files = select(getdtablesize(),0,&file_desc_set,0,&timeout_val);
730 if (num_active_files > 0) {
733 if (!FD_ISSET(
_sick_fd,&file_desc_set)) {
734 throw SickIOException(
"SickLMS1xx::_setupConnection: Unexpected file descriptor!");
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!");
745 throw SickIOException(
"SickLMS1xx::_setupConnection: socket error on connect()!");
749 else if (num_active_files == 0) {
752 throw SickTimeoutException(
"SickLMS1xx::_setupConnection: select() timeout!");
758 throw SickIOException(
"SickLMS1xx::_setupConnection: select() failed!");
769 catch(SickIOException &sick_io_exception) {
770 std::cerr << sick_io_exception.
what() << std::endl;
774 catch(SickTimeoutException &sick_timeout_exception) {
775 std::cerr << sick_timeout_exception.
what() << std::endl;
780 std::cerr <<
"SickLMS1xx::_setupConnection - Unknown exception occurred!" << std::endl;
807 catch (SickTimeoutException &sick_timeout_exception) {
808 std::cerr << sick_timeout_exception.
what() << std::endl;
813 catch (SickIOException &sick_io_exception) {
814 std::cerr << sick_io_exception.
what() << std::endl;
819 catch (SickThreadException &sick_thread_exception) {
820 std::cerr << sick_thread_exception.
what() << std::endl;
825 catch (SickErrorException &sick_error_exception) {
826 std::cerr << sick_error_exception.
what() << std::endl;
831 std::cerr <<
"SickLMS1xx::_reinitialize: Unknown exception!!!" << std::endl;
844 throw SickIOException(
"SickLMS1xx::_teardownConnection: close() failed!");
858 payload_buffer[0] =
's';
859 payload_buffer[1] =
'R';
860 payload_buffer[2] =
'N';
862 payload_buffer[3] =
' ';
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';
885 catch (SickTimeoutException &sick_timeout_exception) {
886 std::cerr << sick_timeout_exception.
what() << std::endl;
891 catch (SickIOException &sick_io_exception) {
892 std::cerr << sick_io_exception.
what() << std::endl;
898 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
903 memset(payload_buffer,0,9);
924 payload_buffer[0] =
's';
925 payload_buffer[1] =
'R';
926 payload_buffer[2] =
'N';
928 payload_buffer[3] =
' ';
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';
956 catch (SickTimeoutException &sick_timeout_exception) {
957 std::cerr << sick_timeout_exception.
what() << std::endl;
962 catch (SickIOException &sick_io_exception) {
963 std::cerr << sick_io_exception.
what() << std::endl;
969 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
974 memset(payload_buffer,0,14);
980 uint32_t scan_freq = 0, scan_res = 0;
981 uint32_t sick_start_angle = 0, sick_stop_angle = 0;
986 const char * token = NULL;
987 if ((token = strtok((
char *)&payload_buffer[15],
" ")) == NULL) {
988 throw SickIOException(
"SickLMS1xx::_getSickConfig: strtok() failed!");
991 if (sscanf(token,
"%x",&scan_freq) == EOF) {
992 throw SickIOException(
"SickLMS1xx::_getSickConfig: sscanf() failed!");
999 if ((token = strtok(NULL,
" ")) == NULL) {
1000 throw SickIOException(
"SickLMS1xx::_getSickConfig: strtok() failed!");
1006 if ((token = strtok(NULL,
" ")) == NULL) {
1007 throw SickIOException(
"SickLMS1xx::_getSickConfig: strtok() failed!");
1010 if (sscanf(token,
"%x",&scan_res) == EOF) {
1011 throw SickIOException(
"SickLMS1xx::_getSickConfig: sscanf() failed!");
1020 if ((token = strtok(NULL,
" ")) == NULL) {
1021 throw SickIOException(
"SickLMS1xx::_getSickConfig: strtok() failed!");
1024 if (sscanf(token,
"%x",&sick_start_angle) == EOF) {
1025 throw SickIOException(
"SickLMS1xx::_getSickConfig: sscanf() failed!");
1033 if ((token = strtok(NULL,
" ")) == NULL) {
1034 throw SickIOException(
"SickLMS1xx::_getSickConfig: strtok() failed!");
1037 if (sscanf(token,
"%x",&sick_stop_angle) == EOF) {
1038 throw SickIOException(
"SickLMS1xx::_getSickConfig: sscanf() failed!");
1069 throw SickConfigException(
"SickLMS1xx::_setSickScanConfig - Invalid Sick LMS 1xx Scan Area!");
1075 std::cout << std::endl <<
"\t*** Attempting to configure device..." << std::endl;
1078 payload_buffer[0] =
's';
1079 payload_buffer[1] =
'M';
1080 payload_buffer[2] =
'N';
1082 payload_buffer[3] =
' ';
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';
1100 payload_buffer[18] =
' ';
1103 std::string freq_str =
int_to_str((
int)scan_freq);
1105 payload_buffer[19] =
'+';
1107 for (
int i = 0; i < 4; i++) {
1108 payload_buffer[20+i] = (uint8_t)((freq_str.c_str())[i]);
1111 payload_buffer[24] =
' ';
1114 payload_buffer[25] =
'+';
1115 payload_buffer[26] =
'1';
1117 payload_buffer[27] =
' ';
1120 std::string res_str =
int_to_str((
int)scan_res);
1122 payload_buffer[28] =
'+';
1124 for (
int i = 0; i < 4; i++) {
1125 payload_buffer[29+i] = (uint8_t)((res_str.c_str())[i]);
1128 payload_buffer[33] =
' ';
1131 std::string start_angle_str =
int_to_str(start_angle);
1133 unsigned int idx = 34;
1134 if (start_angle >= 0) {
1135 payload_buffer[idx] =
'+';
1139 for (
int i = 0; i < start_angle_str.length(); idx++, i++) {
1140 payload_buffer[idx] = (uint8_t)(start_angle_str.c_str())[i];
1143 payload_buffer[idx] =
' ';
1147 std::string stop_angle_str =
int_to_str(stop_angle);
1149 if (stop_angle >= 0) {
1150 payload_buffer[idx] =
'+';
1154 for (
int i = 0; i < stop_angle_str.length(); idx++, i++) {
1155 payload_buffer[idx] = (uint8_t)(stop_angle_str.c_str())[i];
1173 std::cerr << sick_timeout_exception.
what() << std::endl;
1179 std::cerr << sick_io_exception.
what() << std::endl;
1185 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
1196 if (payload_buffer[19] !=
'0') {
1200 std::cout <<
"\t\tDevice configured!" << std::endl << std::endl;
1211 std::cerr << sick_timeout_exception.
what() << std::endl;
1217 std::cerr << sick_io_exception.
what() << std::endl;
1223 std::cerr <<
"SickLMS1xx::_setSickScanConfig: Unknown exception!!!" << std::endl;
1242 payload_buffer[0] =
's';
1243 payload_buffer[1] =
'M';
1244 payload_buffer[2] =
'N';
1246 payload_buffer[3] =
' ';
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';
1263 payload_buffer[17] =
' ';
1266 payload_buffer[18] =
'0';
1267 payload_buffer[19] =
'3';
1269 payload_buffer[20] =
' ';
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';
1295 catch (SickTimeoutException &sick_timeout_exception) {
1296 std::cerr << sick_timeout_exception.
what() << std::endl;
1301 catch (SickIOException &sick_io_exception) {
1302 std::cerr << sick_io_exception.
what() << std::endl;
1308 std::cerr <<
"SickLMS1xx::_setAuthorizedClientAccessMode: Unknown exception!!!" << std::endl;
1313 memset(payload_buffer,0,29);
1319 if (payload_buffer[18] !=
'1') {
1320 throw SickErrorException(
"SickLMS1xx::_setAuthorizedClientAccessMode: Setting Access Mode Failed!");
1336 payload_buffer[0] =
's';
1337 payload_buffer[1] =
'M';
1338 payload_buffer[2] =
'N';
1340 payload_buffer[3] =
' ';
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';
1369 catch (SickTimeoutException &sick_timeout_exception) {
1370 std::cerr << sick_timeout_exception.
what() << std::endl;
1375 catch (SickIOException &sick_io_exception) {
1376 std::cerr << sick_io_exception.
what() << std::endl;
1382 std::cerr <<
"SickLMS1xx::_writeToEEPROM: Unknown exception!!!" << std::endl;
1387 memset(payload_buffer,0,15);
1393 if (payload_buffer[13] !=
'1') {
1394 throw SickIOException(
"SickLMS1xx::_writeToEEPROM: Failed to Write Data!");
1410 payload_buffer[0] =
's';
1411 payload_buffer[1] =
'M';
1412 payload_buffer[2] =
'N';
1413 payload_buffer[3] =
' ';
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';
1443 catch (SickTimeoutException &sick_timeout_exception) {
1444 std::cerr << sick_timeout_exception.
what() << std::endl;
1449 catch (SickIOException &sick_io_exception) {
1450 std::cerr << sick_io_exception.
what() << std::endl;
1456 std::cerr <<
"SickLMS1xx::_startMeasuring: Unknown exception!!!" << std::endl;
1461 memset(payload_buffer,0,16);
1467 if (payload_buffer[17] !=
'0') {
1482 payload_buffer[0] =
's';
1483 payload_buffer[1] =
'M';
1484 payload_buffer[2] =
'N';
1485 payload_buffer[3] =
' ';
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';
1514 catch (SickTimeoutException &sick_timeout_exception) {
1515 std::cerr << sick_timeout_exception.
what() << std::endl;
1520 catch (SickIOException &sick_io_exception) {
1521 std::cerr << sick_io_exception.
what() << std::endl;
1527 std::cerr <<
"SickLMS1xx::_stopMeasuring: Unknown exception!!!" << std::endl;
1532 memset(payload_buffer,0,15);
1538 if (payload_buffer[16] !=
'0') {
1551 std::cout << std::endl <<
"\tRequesting data stream..." << std::endl;
1564 catch (SickConfigException &sick_config_exception) {
1565 std::cerr << sick_config_exception.
what() << std::endl;
1570 catch (SickTimeoutException &sick_timeout_exception) {
1571 std::cerr << sick_timeout_exception.
what() << std::endl;
1576 catch (SickIOException &sick_io_exception) {
1577 std::cerr << sick_io_exception.
what() << std::endl;
1582 std::cerr <<
"SickLMS1xx::SetSickScanArea: Unknown exception!!!" << std::endl;
1586 std::cout <<
"\t\tStream started!" << std::endl;
1599 payload_buffer[0] =
's';
1600 payload_buffer[1] =
'E';
1601 payload_buffer[2] =
'N';
1602 payload_buffer[3] =
' ';
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] =
' ';
1619 payload_buffer[16] =
'1';
1635 catch (SickTimeoutException &sick_timeout_exception) {
1636 std::cerr << sick_timeout_exception.
what() << std::endl;
1641 catch (SickIOException &sick_io_exception) {
1642 std::cerr << sick_io_exception.
what() << std::endl;
1648 std::cerr <<
"SickLMS1xx::_startStreamingMeasurements: Unknown exception!!!" << std::endl;
1663 std::cout <<
"\tStopping data stream..." << std::endl;
1670 payload_buffer[0] =
's';
1671 payload_buffer[1] =
'E';
1672 payload_buffer[2] =
'N';
1673 payload_buffer[3] =
' ';
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] =
' ';
1690 payload_buffer[16] =
'0';
1707 std::cerr << sick_io_exception.
what() << std::endl;
1713 std::cerr <<
"SickLMS1xx::_stopStreamingMeasurements: Unknown exception!!!" << std::endl;
1719 std::cout <<
"\t\tStream stopped!" << std::endl;
1733 struct timeval beg_time, end_time;
1736 gettimeofday(&beg_time,NULL);
1742 bool first_pass =
true;
1757 std::cerr << sick_timeout_exception.
what() << std::endl;
1763 std::cerr << sick_io_exception.
what() << std::endl;
1769 std::cerr <<
"SickLMS1xx::_checkForMeasuringStatus: Unknown exception!!!" << std::endl;
1779 gettimeofday(&end_time,NULL);
1800 payload_buffer[0] =
's';
1801 payload_buffer[1] =
'W';
1802 payload_buffer[2] =
'N';
1803 payload_buffer[3] =
' ';
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] =
' ';
1823 payload_buffer[19] =
'0';
1828 payload_buffer[20] =
'1';
1831 payload_buffer[20] =
'3';
1834 payload_buffer[21] =
' ';
1837 payload_buffer[22] =
'0';
1838 payload_buffer[23] =
'0';
1839 payload_buffer[24] =
' ';
1844 payload_buffer[25] =
'0';
1847 payload_buffer[25] =
'1';
1849 payload_buffer[26] =
' ';
1854 payload_buffer[27] =
'1';
1857 payload_buffer[27] =
'0';
1859 payload_buffer[28] =
' ';
1862 payload_buffer[29] =
'0';
1863 payload_buffer[30] =
' ';
1866 payload_buffer[31] =
'0';
1867 payload_buffer[32] =
'0';
1868 payload_buffer[33] =
' ';
1871 payload_buffer[34] =
'0';
1872 payload_buffer[35] =
'0';
1873 payload_buffer[36] =
' ';
1876 payload_buffer[37] =
'0';
1877 payload_buffer[38] =
' ';
1880 payload_buffer[39] =
'0';
1881 payload_buffer[40] =
' ';
1884 payload_buffer[41] =
'0';
1885 payload_buffer[42] =
' ';
1888 payload_buffer[43] =
'0';
1889 payload_buffer[44] =
' ';
1892 payload_buffer[45] =
'+';
1893 payload_buffer[46] =
'1';
1916 std::cerr << sick_timeout_exception.
what() << std::endl;
1922 std::cerr << sick_io_exception.
what() << std::endl;
1928 std::cerr << sick_thread_exception.
what() << std::endl;
1934 std::cerr << sick_error_exception.
what() << std::endl;
1939 std::cerr <<
"SickLMS1xx::_setSickScanDataFormat: Unknown exception!!!" << std::endl;
1956 payload_buffer[0] =
's';
1957 payload_buffer[1] =
'M';
1958 payload_buffer[2] =
'N';
1959 payload_buffer[3] =
' ';
1962 payload_buffer[4] =
'R';
1963 payload_buffer[5] =
'u';
1964 payload_buffer[6] =
'n';
1980 catch (SickTimeoutException &sick_timeout_exception) {
1981 std::cerr << sick_timeout_exception.
what() << std::endl;
1986 catch (SickIOException &sick_io_exception) {
1987 std::cerr << sick_io_exception.
what() << std::endl;
1993 std::cerr <<
"SickLMS1xx::_restoreMeasuringMode: Unknown exception!!!" << std::endl;
1997 memset(payload_buffer,0,7);
2001 if (payload_buffer[8] !=
'0') {
2002 std::cerr <<
"SickLMS1xx::_restoreMeasuringMode: Unknown exception!!!" << std::endl;
2016 if (start_angle >= stop_angle) {
2026 if (stop_angle < SICK_LMS_1XX_SCAN_AREA_MIN_ANGLE || stop_angle > SICK_LMS_1XX_SCAN_AREA_MAX_ANGLE) {
2049 std::cerr << sick_io_error.
what() << std::endl;
2055 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2074 const std::string reply_command_type,
2075 const std::string reply_command,
2076 const unsigned int timeout_value,
2080 std::string expected_str = reply_command_type +
" " + reply_command;
2096 std::cerr << sick_io_error.
what() << std::endl;
2102 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2129 std::cerr <<
"SickLMS1xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
2166 return "Invalid Scan Frequency";
2168 return "Invalid Scan Resolution";
2170 return "Invalid Scan Frequency and Scan Resolution";
2172 return "Invalid Scan Area";
2174 return "Other Error";
2184 std::cout <<
"\t========= Sick Scan Config =========" << std::endl;
2188 std::cout <<
"\t====================================" << std::endl;
2189 std::cout << std::endl << std::flush;
2197 std::cout <<
"\t*** Init. complete: Sick LMS 1xx is online and ready!" << std::endl;
2201 std::cout << std::endl;
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)";
2243 const unsigned int str_length,
const unsigned int substr_length,
2244 unsigned int &substr_pos,
unsigned int start_pos )
const {
2250 bool substr_found =
false;
2251 for (
unsigned int i = start_pos; !substr_found && (i < (str_length - substr_length) + 1); i++) {
2254 for (
unsigned int k = i; (str[k] == substr[j]) && (j < substr_length); k++, j++);
2256 if (j == substr_length) {
2257 substr_found =
true;
2264 return substr_found;
2276 const char *
const delimeter )
const {
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!");
2284 if (sscanf(token,
"%x",&curr_val) == EOF) {
2285 throw SickIOException(
"SickLMS1xx::_getNextTokenAsUInt: sscanf() failed!");
2290 return str_buffer + strlen(token) + 1;
Contains some simple exception classes.
Defines a class for monitoring the receive buffer when interfacing w/ a Sick LMS 1xx laser range find...
#define DEFAULT_SICK_LMS_1XX_MESSAGE_TIMEOUT
Max time for reply (usecs)
#define SICK_LMS_1XX_SCAN_AREA_MAX_ANGLE
225 degrees (1/10000) degree
Defines simple utility functions for working with the Sick LMS 1xx laser range finder units...
Defines the SickLMS1xx class for working with the Sick LMS1xx laser range finders.
#define DEFAULT_SICK_LMS_1XX_BYTE_TIMEOUT
Max allowable time between consecutive bytes.
#define DEFAULT_SICK_LMS_1XX_CONNECT_TIMEOUT
Max time for establishing connection (usecs)