23 #include <sys/ioctl.h>    32 #ifdef HAVE_LINUX_SERIAL_H    33 #include <linux/serial.h>    35 #define B500000 0010005    46                                                                 _sick_device_path(sick_device_path),
    47                                                                 _curr_session_baud(SICK_BAUD_UNKNOWN),
    48                                                                 _desired_session_baud(SICK_BAUD_UNKNOWN),
    49                                                                 _sick_type(SICK_LMS_TYPE_UNKNOWN),
    50                                                                 _sick_mean_value_sample_size(0),
    51                                                                 _sick_values_subrange_start_index(0),
    52                                                                 _sick_values_subrange_stop_index(0)
    64     memset(&
_old_term,0,
sizeof(
struct termios));
    82       std::cerr << sick_io_exception.
what() << std::endl;
    87       std::cerr << 
"SickLMS2xx::~SickLMS2xx: Unknown exception!" << std::endl;
   106       std::cout << std::endl << 
"\t*** Attempting to initialize the Sick LMS..." << std::endl << std::flush;
   109       std::cout << 
"\tAttempting to open device @ " << 
_sick_device_path << std::endl << std::flush;
   111       std::cout << 
"\t\tDevice opened!" << std::endl << std::flush;
   115         std::cout << 
"\tAttempting to start buffer monitor..." << std::endl;       
   117         std::cout << 
"\t\tBuffer monitor started!" << std::endl;
   120         std::cout << 
"\tAttempting to reset buffer monitor..." << std::endl;       
   122         std::cout << 
"\t\tBuffer monitor reset!" << std::endl;       
   127         std::cout << 
"\tAttempting to set requested baud rate..." << std::endl;
   137         std::cout << 
"\tFailed to set requested baud rate..." << std::endl << std::flush;
   138         std::cout << 
"\tAttempting to detect LMS baud rate..." << std::endl << std::flush;
   149           throw SickIOException(
"SickLMS2xx::Initialize: failed to detect baud rate!"); 
   151         std::cout << std::flush;
   155           std::cout << 
"\tAttempting to setup desired baud (again)..." << std::endl << std::flush;
   163         std::cerr << 
"SickLMS2xx::Initialize: Unknown exception!" << std::endl;
   173       std::cout << 
"\tAttempting to sync driver..." << std::endl << std::flush;
   177       std::cout << 
"\t\tDriver synchronized!" << std::endl << std::flush;
   186       std::cerr << sick_config_exception.
what() << std::endl;
   192       std::cerr << sick_timeout_exception.
what() << std::endl;
   198       std::cerr << sick_io_exception.
what() << std::endl;
   204       std::cerr << sick_thread_exception.
what() << std::endl;
   210       std::cerr << 
"SickLMS2xx::Initialize: Unknown exception!" << std::endl;
   215     std::cout << 
"\t*** Init. complete: Sick LMS is online and ready!" << std::endl; 
   217     std::cout << 
"\tScan Angle: " << 
GetSickScanAngle() << 
" (deg)" << std::endl;  
   221     std::cout << std::endl << std::flush;
   233       std::cout << std::endl << 
"\t*** Attempting to uninitialize the Sick LMS..." << std::endl;       
   245           std::cout << 
"\tAttempting to stop buffer monitor..." << std::endl;
   247           std::cout << 
"\t\tBuffer monitor stopped!" << std::endl;
   250         std::cout << 
"\t*** Uninit. complete - Sick LMS is now offline!" << std::endl << std::flush;
   255       catch(SickConfigException &sick_config_exception) {
   256         std::cerr << sick_config_exception.
what() << 
" (attempting to kill connection anyways)" << std::endl;
   261       catch(SickTimeoutException &sick_timeout_exception) {
   262         std::cerr << sick_timeout_exception.
what() << 
" (attempting to kill connection anyways)" << std::endl;
   267       catch(SickIOException &sick_io_exception) {
   268         std::cerr << sick_io_exception.
what() << 
" (attempting to kill connection anyways)" << std::endl;
   273       catch(SickThreadException &sick_thread_exception) {
   274         std::cerr << sick_thread_exception.
what() << 
" (attempting to kill connection anyways)" << std::endl;
   280         std::cerr << 
"SickLMS2xx::Unintialize: Unknown exception!!!" << std::endl;
   307       throw SickConfigException(
"SickLMS2xx::GetSickType: Sick LMS is not initialized!");
   323       throw SickConfigException(
"SickLMS2xx::GetSickScanAngle: Sick LMS is not initialized!");
   339       throw SickConfigException(
"SickLMS2xx::GetSickScanResolution: Sick LMS is not initialized!");
   356       throw SickConfigException(
"SickLMS2xx::SetSickMeasuringUnits: Sick LMS is not initialized!");
   361       throw SickConfigException(
"SickLMS2xx::SetSickMeasuringUnits: Undefined measurement units!");
   385         std::cerr << sick_config_exception.
what() << std::endl;
   391         std::cerr << sick_timeout_exception.
what() << std::endl;
   397         std::cerr << sick_io_exception.
what() << std::endl;
   403         std::cerr << sick_thread_exception.
what() << std::endl;
   409         std::cerr << 
"SickLMS2xx::SetSickMeasuringUnits: Unknown exception!!!" << std::endl;
   415       std::cerr << 
"\tSickLMS2xx::SetSickMeasuringUnits - Device is already configured w/ these units. (skipping write)" << std::endl;
   428       throw SickConfigException(
"SickLMS2xx::GetSickMeasuringUnits: Sick LMS is not initialized!");
   450       throw SickConfigException(
"SickLMS2xx::SetSickSensitivity: This command is not supported by this Sick model!");
   479         std::cerr << sick_config_exception.
what() << std::endl;
   485         std::cerr << sick_timeout_exception.
what() << std::endl;
   491         std::cerr << sick_io_exception.
what() << std::endl;
   497         std::cerr << sick_thread_exception.
what() << std::endl;
   503         std::cerr << 
"SickLMS2xx::SetSickSensitivity: Unknown exception!!!" << std::endl;
   509       std::cerr << 
"\tSickLMS2xx::SetSickSensitivity - Sick is already operating at this sensitivity level! (skipping write)" << std::endl;
   523       throw SickConfigException(
"SickLMS2xx::SetSickPeakThreshold: Sick LMS is not initialized!");
   528       throw SickConfigException(
"SickLMS2xx::SetSickPeakThreshold: This command is not supported by this Sick model!");
   557         std::cerr << sick_config_exception.
what() << std::endl;
   563         std::cerr << sick_timeout_exception.
what() << std::endl;
   569         std::cerr << sick_io_exception.
what() << std::endl;
   575         std::cerr << sick_thread_exception.
what() << std::endl;
   581         std::cerr << 
"SickLMS2xx::SetSickPeakThreshold: Unknown exception!!!" << std::endl;
   587       std::cerr << 
"\tSickLMS2xx::SetSickPeakThreshold - Sick is already operating w/ given threshold! (skipping write)" << std::endl;
   600       throw SickConfigException(
"SickLMS2xx::GetSickSensitivity: Sick LMS is not initialized!");
   622       throw SickConfigException(
"SickLMS2xx::GetSickPeakThreshold: Sick LMS is not initialized!");
   627       std::cerr << 
"Peak threshold is undefined for model: " << 
SickTypeToString(
GetSickType()) << 
" (returning \"Unknown\")" << std::endl;
   645       throw SickConfigException(
"SickLMS2xx::SetSickMeasuringUnits: Sick LMS is not initialized!");
   674         std::cerr << sick_config_exception.
what() << std::endl;
   680         std::cerr << sick_timeout_exception.
what() << std::endl;
   686         std::cerr << sick_io_exception.
what() << std::endl;
   692         std::cerr << sick_thread_exception.
what() << std::endl;
   698         std::cerr << 
"SickLMS2xx::SetSickMeasuringMode: Unknown exception!!!" << std::endl;
   704       std::cerr << 
"\tSickLMS2xx::SetSickMeasuringMode - Sick is already operating w/ this measuring mode! (skipping write)" << std::endl;
   717       throw SickConfigException(
"SickLMS2xx::GetSickMeasuringMode: Sick LMS is not initialized!");
   733       throw SickConfigException(
"SickLMS2xx::GetSickScanAngle: Sick LMS is not initialized!");
   750       throw SickConfigException(
"SickLMS2xx::SetSickAvailabilityFlags: Sick LMS is not initialized!");
   754     if ( sick_availability_flags > 7 ) {      
   782         std::cerr << sick_config_exception.
what() << std::endl;
   788         std::cerr << sick_timeout_exception.
what() << std::endl;
   794         std::cerr << sick_io_exception.
what() << std::endl;
   800         std::cerr << sick_thread_exception.
what() << std::endl;
   806         std::cerr << 
"SickLMS2xx::SetSickAvailabilityFlags: Unknown exception!!!" << std::endl;
   812       std::cerr << 
"\tSickLMS2xx::SetSickAvailability - Device is already operating w/ given availability. (skipping write)" << std::endl;
   825       throw SickConfigException(
"SickLMS2xx::GetSickAvailabilityFlags: Sick LMS is not initialized!");
   848       throw SickConfigException(
"SickLMS2xx::SetSickVariant: Command not supported on this model!");
   858       throw SickConfigException(
"SickLMS2xx::SetSickMeasuringUnits: Undefined scan resolution!");
   864     payload_buffer[0] = 0x3B; 
   869       payload_buffer[1] = 0x64;
   872       payload_buffer[1] = 0xB4;
   879     switch(scan_resolution) {
   881       payload_buffer[3] = 0x64;
   884       payload_buffer[3] = 0x32;
   887       payload_buffer[3] = 0x19;
   890       throw SickConfigException(
"SickLMS2xx::SetSickVariant: Given scan resolution is invalid!");
   913       std::cerr << sick_config_exception.
what() << std::endl;
   919       std::cerr << sick_timeout_exception.
what() << std::endl;
   925       std::cerr << sick_io_exception.
what() << std::endl;
   931       std::cerr << sick_thread_exception.
what() << std::endl;
   937       std::cerr << 
"SickLMS2xx::SetSickVariant: Unknown exception!!!" << std::endl;
   945     if(payload_buffer[1] != 0x01) {
   978                              unsigned int & num_measurement_values,
   979                              unsigned int * 
const sick_field_a_values,
   980                              unsigned int * 
const sick_field_b_values,
   981                              unsigned int * 
const sick_field_c_values,
   982                              unsigned int * 
const sick_telegram_index,
  1006         throw SickIOException(
"SickLMS2xx::GetSickScan: Unexpected message!");
  1024       for (
unsigned int i = 0; i < num_measurement_values; i++) {
  1030         if(sick_field_a_values) {
  1035         if(sick_field_b_values) {
  1040         if(sick_field_c_values) {
  1047       if(sick_real_time_scan_index) {
  1052       if(sick_telegram_index) {
  1060       std::cerr << sick_config_exception.
what() << std::endl;
  1066       std::cerr << sick_timeout_exception.
what() << std::endl;
  1072       std::cerr << sick_io_exception.
what() << std::endl;
  1078       std::cerr << sick_thread_exception.
what() << std::endl;
  1084       std::cerr << 
"SickLMS2xx::GetSickScan: Unknown exception!!!" << std::endl;
  1108                              unsigned int * 
const reflect_values,
  1109                              unsigned int & num_range_measurements,
  1110                              unsigned int & num_reflect_measurements,
  1111                              unsigned int * 
const sick_field_a_values,
  1112                              unsigned int * 
const sick_field_b_values,
  1113                              unsigned int * 
const sick_field_c_values,
  1114                              unsigned int * 
const sick_telegram_index,
  1138         throw SickIOException(
"SickLMS2xx::GetSickScan: Unexpected message!");
  1163         if(sick_field_a_values) {
  1168         if(sick_field_b_values) {
  1173         if(sick_field_c_values) {
  1180       for( 
unsigned int i = 0; i < num_reflect_measurements; i++) {
  1185       if(sick_telegram_index) {
  1190       if(sick_real_time_scan_index) {
  1198       std::cerr << sick_config_exception.
what() << std::endl;
  1204       std::cerr << sick_timeout_exception.
what() << std::endl;
  1210       std::cerr << sick_io_exception.
what() << std::endl;
  1216       std::cerr << sick_thread_exception.
what() << std::endl;
  1222       std::cerr << 
"SickLMS2xx::GetSickScan: Unknown exception!!!" << std::endl;
  1251                                      const uint16_t sick_subrange_stop_index,
  1252                                      unsigned int * 
const measurement_values,
  1253                                      unsigned int & num_measurement_values,
  1254                                      unsigned int * 
const sick_field_a_values,
  1255                                      unsigned int * 
const sick_field_b_values,
  1256                                      unsigned int * 
const sick_field_c_values,
  1257                                      unsigned int * 
const sick_telegram_index,
  1262       throw SickConfigException(
"SickLMS2xx::GetSickScanSubrange: Sick LMS is not initialized!");
  1281         throw SickIOException(
"SickLMS2xx::GetSickScanSubrange: Unexpected message!");
  1299       for (
unsigned int i = 0; i < num_measurement_values; i++) {
  1305         if(sick_field_a_values) {
  1310         if(sick_field_b_values) {
  1315         if(sick_field_c_values) {
  1322       if(sick_real_time_scan_index) {
  1327       if(sick_telegram_index) {
  1335       std::cerr << sick_config_exception.
what() << std::endl;
  1341       std::cerr << sick_timeout_exception.
what() << std::endl;
  1347       std::cerr << sick_io_exception.
what() << std::endl;
  1353       std::cerr << sick_thread_exception.
what() << std::endl;
  1359       std::cerr << 
"SickLMS2xx::GetSickScanSubrange: Unknown exception!!!" << std::endl;
  1389                                     unsigned int & num_measurement_values,
  1390                                     unsigned int & partial_scan_index,
  1391                                     unsigned int * 
const sick_field_a_values,
  1392                                     unsigned int * 
const sick_field_b_values,
  1393                                     unsigned int * 
const sick_field_c_values,
  1394                                     unsigned int * 
const sick_telegram_index,
  1399       throw SickConfigException(
"SickLMS2xx::GetSickPartialScan: Sick LMS is not initialized!");
  1418         throw SickIOException(
"SickLMS2xx::GetSickPartialScan: Unexpected message!");
  1439       for (
unsigned int i = 0; i < num_measurement_values; i++) {
  1445         if(sick_field_a_values) {
  1450         if(sick_field_b_values) {
  1455         if(sick_field_c_values) {
  1462       if(sick_real_time_scan_index) {
  1467       if(sick_telegram_index) {
  1475       std::cerr << sick_config_exception.
what() << std::endl;
  1481       std::cerr << sick_timeout_exception.
what() << std::endl;
  1487       std::cerr << sick_io_exception.
what() << std::endl;
  1493       std::cerr << sick_thread_exception.
what() << std::endl;
  1499       std::cerr << 
"SickLMS2xx::GetSickPartialScan: Unknown exception!!!" << std::endl;
  1520                                    unsigned int * 
const measurement_values,
  1521                                    unsigned int & num_measurement_values,
  1522                                    unsigned int * 
const sick_telegram_index,
  1546         throw SickIOException(
"SickLMS2xx::GetSickMeanValues: Unexpected message!");
  1564       for (
unsigned int i = 0; i < num_measurement_values; i++) {
  1570       if(sick_real_time_scan_index) {
  1575       if(sick_telegram_index) {
  1583       std::cerr << sick_config_exception.
what() << std::endl;
  1589       std::cerr << sick_timeout_exception.
what() << std::endl;
  1595       std::cerr << sick_io_exception.
what() << std::endl;
  1601       std::cerr << sick_thread_exception.
what() << std::endl;
  1607       std::cerr << 
"SickLMS2xx::GetSickMeanValues: Unknown exception!!!" << std::endl;
  1634                                            const uint16_t sick_subrange_start_index,
  1635                                            const uint16_t sick_subrange_stop_index,
  1636                                            unsigned int * 
const measurement_values,
  1637                                            unsigned int & num_measurement_values,
  1638                                            unsigned int * 
const sick_telegram_index,
  1643       throw SickConfigException(
"SickLMS2xx::GetSickMeanValuesSubrange: Sick LMS is not initialized!");
  1662         throw SickIOException(
"SickLMS2xx::GetSickMeanValuesSubrange: Unexpected message!");
  1680       for (
unsigned int i = 0; i < num_measurement_values; i++) {
  1688       if(sick_real_time_scan_index) {
  1693       if(sick_telegram_index) {
  1701       std::cerr << sick_config_exception.
what() << std::endl;
  1707       std::cerr << sick_timeout_exception.
what() << std::endl;
  1713       std::cerr << sick_io_exception.
what() << std::endl;
  1719       std::cerr << sick_thread_exception.
what() << std::endl;
  1725       std::cerr << 
"SickLMS2xx::GetMeanValuesSubrange: Unknown exception!!!" << std::endl;
  1742       throw SickConfigException(
"SickLMS2xx::GetSickStatus: Sick LMS is not initialized!");
  1753     catch(SickTimeoutException &sick_timeout_exception) {
  1754       std::cerr << sick_timeout_exception.
what() << std::endl;
  1759     catch(SickIOException &sick_io_exception) {
  1760       std::cerr << sick_io_exception.
what() << std::endl;
  1765     catch(SickThreadException &sick_thread_exception) {
  1766       std::cerr << sick_thread_exception.
what() << std::endl;
  1772       std::cerr << 
"SickLMS2xx::GetSickStatus: Unknown exception!" << std::endl;
  1787       throw SickConfigException(
"SickLMS2xx::IsSickLMS2xxFast: Sick LMS is not initialized!");
  1804       throw SickConfigException(
"SickLMS2xx::ResetSick: Sick LMS is not initialized!");
  1814     std::cout << 
"\tResetting the device..." << std::endl;
  1815     std::cout << 
"\tWaiting for Power on message..." << std::endl;
  1822       std::cout << 
"\t\tPower on message received!" << std::endl;
  1823       std::cout << 
"\tWaiting for LMS Ready message..." << std::endl;
  1833         std::cerr << 
"SickLMS2xx::ResetSick: Unexpected reply! (assuming device has been reset!)"  << std::endl;
  1835         std::cout << 
"\t\tLMS Ready message received!" << std::endl;
  1837       std::cout << std::endl;
  1845     catch(SickTimeoutException &sick_timeout_exception) {
  1846       std::cerr << sick_timeout_exception.
what() << std::endl;
  1851     catch(SickIOException &sick_io_exception) {
  1852       std::cerr << sick_io_exception.
what() << std::endl;
  1857     catch(SickThreadException &sick_thread_exception) {
  1858       std::cerr << sick_thread_exception.
what() << std::endl;
  1864       std::cerr << 
"SickLMS2xx::ResetSick: Unknown exception!!!" << std::endl;
  1868     std::cout << 
"\tRe-initialization sucessful. LMS is ready to go!" << std::endl;
  1878     std::stringstream str_stream;
  1880     str_stream << 
"\t=============== Sick LMS Status ===============" << std::endl;
  1887       str_stream << 
"\tScan Angle: " << 
GetSickScanAngle() << 
" (deg)" << std::endl;
  1896       str_stream << 
"\t Unknown (Device is not initialized)" << std::endl;
  1900     str_stream << 
"\t===============================================" << std::endl;
  1902     return str_stream.str();
  1911     std::stringstream str_stream;
  1913     str_stream << 
"\t============== Sick LMS Software ==============" << std::endl;
  1923       str_stream << 
"\t Unknown (Device is not initialized)" << std::endl;
  1927     str_stream << 
"\t===============================================" << std::endl;
  1929     return str_stream.str();
  1938     std::stringstream str_stream;
  1940     str_stream<< 
"\t=============== Sick LMS Config ===============" << std::endl;
  1974       str_stream << 
"\t Unknown (Device is not initialized)" << std::endl;
  1978     str_stream << 
"\t===============================================" << std::endl;
  1980     return str_stream.str();
  2013       return "Sick LMS 200-30106";
  2015       return "Sick LMS 211-30106";
  2017       return "Sick LMS 211-30206";
  2019       return "Sick LMS 211-S07";
  2021       return "Sick LMS 211-S14";
  2023       return "Sick LMS 211-S15";
  2025       return "Sick LMS 211-S19";
  2027       return "Sick LMS 211-S20";
  2029       return "Sick LMS 220-30106";
  2031       return "Sick LMS 221-30106";
  2033       return "Sick LMS 221-30206";
  2035       return "Sick LMS 221-S07";
  2037       return "Sick LMS 221-S14";
  2039       return "Sick LMS 221-S15";
  2041       return "Sick LMS 221-S16";
  2043       return "Sick LMS 221-S19";
  2045       return "Sick LMS 221-S20";
  2047       return "Sick LMS 291-S05";
  2049       return "Sick LMS 291-S14";
  2051       return "Sick LMS 291-S15";
  2064     switch(scan_angle_int) {
  2083     switch(scan_resolution_int) {
  2154     std::istringstream input_stream(baud_str);
  2155     input_stream >> baud_int;
  2170       return "Error (possibly fatal)";
  2183     switch(sick_measuring_mode) {
  2185       return "8m/80m; fields A,B,Dazzle";
  2187       return "8m/80m; 3 reflector bits";
  2189       return "8m/80m; fields A,B,C";
  2191       return "16m; 4 reflector bits";
  2193       return "16m; fields A & B";
  2195       return "32m; 2 reflector bits";
  2197       return "32m; field A";
  2199       return "32m; immediate";
  2201       return "Reflectivity";
  2214     switch(sick_operating_mode) {
  2216       return "Installation Mode";
  2218       return "Diagnostic Mode";
  2220       return "Stream mim measured values for each segment";
  2222       return "Min measured value for each segment when object detected";
  2224       return "Min vertical distance";
  2226       return "Min vertical distance when object detected";
  2228       return "Stream all measured values";
  2230       return "Request measured values";
  2232       return "Stream mean measured values";
  2234       return "Stream measured value subrange";
  2236       return "Stream mean measured value subrange";
  2238       return "Stream measured and field values";
  2240       return "Stream measured values from partial scan";
  2242       return "Stream range w/ reflectivity from partial scan";
  2244       return "Stream min measured values for each segment over a subrange";
  2246       return "Output navigation data records";
  2248       return "Stream range w/ reflectivity values";
  2262     switch(sick_sensitivity) {    
  2264       return "Standard (~30m @ 10% reflectivity)";
  2266       return "Medium (~25m @ 10% reflectivity)";
  2268       return "Low (~20m @ 10% relfectivity)";
  2270       return "High (~42m @ 10% reflectivity)";
  2284     switch(sick_peak_threshold) {    
  2286       return "Peak detection, no black extension";
  2288       return "Peak detection w/ black extension";
  2290       return "No peak detection, no black extension";
  2292       return "No peak detection w/ black extension";
  2307     switch(sick_units) {
  2309       return "Centimeters (cm)";
  2311       return "Millimeters (mm)";
  2335         throw SickIOException(
"SickLMS2xx::_setupConnection: - Unable to open serial port");
  2343         throw SickIOException(
"SickLMS2xx::_setupConnection: tcgetattr() failed!");
  2353       std::cerr << sick_io_exception.
what() << std::endl;
  2359       std::cerr << sick_thread_exception.
what() << std::endl;
  2365       std::cerr << 
"SickLMS2xx::_setupConnection: Unknown exception!" << std::endl;
  2383       throw SickIOException(
"SickLMS2xx::_teardownConnection: tcsetattr() failed!");
  2388       throw SickIOException(
"SickLMS2xx::_teardownConnection: close() failed!");
  2404       if (tcflush(
_sick_fd,TCIOFLUSH) != 0) {
  2405         throw SickThreadException(
"SickLMS2xx::_flushTerminalBuffer: tcflush() failed!");
  2414     catch(SickThreadException &sick_thread_exception) {
  2415       std::cerr << sick_thread_exception.
what() << std::endl;
  2421       std::cerr << 
"SickLMS2xx::_flushTerminalBuffer: Unknown exception!" << std::endl;
  2439                                             const unsigned int timeout_value,
  2442     uint8_t sick_reply_code = send_message.GetCommandCode() + 0x80;
  2459       std::cerr << sick_thread_exception.
what() << std::endl;
  2465       std::cerr << sick_io_error.
what() << std::endl;
  2471       std::cerr << 
"SickLMS2xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
  2487                                             const uint8_t reply_code,
  2488                                             const unsigned int timeout_value,
  2508       std::cerr << sick_thread_exception.
what() << std::endl;
  2514       std::cerr << sick_io_error.
what() << std::endl;
  2520       std::cerr << 
"SickLMS2xx::_sendMessageAndGetReply: Unknown exception!!!" << std::endl;
  2538       throw SickIOException(
"SickLMS2xx::_setSessionBaud: Undefined baud rate!");
  2543     payload[1] = baud_rate;
  2562       std::cerr << sick_timeout_exception.
what() << std::endl;
  2568       std::cerr << sick_io_exception.
what() << std::endl;
  2574       std::cerr << sick_thread_exception.
what() << std::endl;
  2580       std::cerr << 
"SickLMS2xx::_getSickErrors: Unknown exception!!!" << std::endl;
  2596         throw SickIOException(
"SickLMS2xx::_testBaudRate: Undefined baud rate!");
  2600       std::cout << 
"\t\tChecking " << 
SickBaudToString(baud_rate) << 
"..." << std::endl;
  2620         std::cerr << 
"SickLMS2xx::_testBaudRate: Unknown exception!" << std::endl;
  2628       std::cerr << sick_io_exception.
what() << std::endl;
  2634       std::cerr << sick_thread_exception.
what() << std::endl;
  2640       std::cerr << 
"SickLMS2xx::_testBaudRate: Unknown exception!!!" << std::endl;
  2655     struct termios term;
  2657 #ifdef HAVE_LINUX_SERIAL_H  2658     struct serial_struct serial;
  2666 #ifdef HAVE_LINUX_SERIAL_H  2669         if(ioctl(
_sick_fd,TIOCGSERIAL,&serial) < 0) {
  2670           throw SickIOException(
"SickLMS2xx::_setTerminalBaud: ioctl() failed!");
  2674         serial.flags |= ASYNC_SPD_CUST;
  2675         serial.custom_divisor = 48; 
  2678         if(ioctl(
_sick_fd,TIOCSSERIAL,&serial) < 0) {
  2679           throw SickIOException(
"SickLMS2xx::_setTerminalBaud: ioctl() failed!");
  2683         throw SickIOException(
"SickLMS2xx::_setTerminalBaud - 500K baud is only supported under Linux!");
  2688 #ifdef HAVE_LINUX_SERIAL_H  2693         if(ioctl(
_sick_fd,TIOCGSERIAL,&serial) < 0) {
  2694           std::cerr << 
"SickLMS2xx::_setTermSpeed: ioctl() failed while trying to get serial port info!" << std::endl;
  2695           std::cerr << 
"\tNOTE: This is normal when connected via USB!" <<std::endl;
  2698         serial.custom_divisor = 0;
  2699         serial.flags &= ~ASYNC_SPD_CUST;
  2701         if(ioctl(
_sick_fd,TIOCSSERIAL,&serial) < 0) {
  2702           std::cerr << 
"SickLMS2xx::_setTerminalBaud: ioctl() failed while trying to set serial port info!" << std::endl;
  2703           std::cerr << 
"\tNOTE: This is normal when connected via USB!" <<std::endl;
  2711       if(tcgetattr(
_sick_fd,&term) < 0) {
  2712         throw SickIOException(
"SickLMS2xx::_setTerminalBaud: Unable to get device attributes!");
  2719         cfsetispeed(&term,B9600);
  2720         cfsetospeed(&term,B9600);
  2725         cfsetispeed(&term,B19200);
  2726         cfsetospeed(&term,B19200);
  2731         cfsetispeed(&term,B38400);
  2732         cfsetospeed(&term,B38400);            
  2737         cfsetispeed(&term,B38400);
  2738         cfsetospeed(&term,B38400);
  2742         throw SickIOException(
"SickLMS2xx::_setTerminalBaud: Unknown baud rate!");
  2746       if(tcsetattr(
_sick_fd,TCSAFLUSH,&term) < 0 ) {
  2747         throw SickIOException(
"SickLMS2xx::_setTerminalBaud: Unable to set device attributes!");
  2760       std::cerr << sick_io_exception.
what() << std::endl;
  2766       std::cerr << sick_thread_exception.
what() << std::endl;
  2772       std::cerr << 
"SickLMS2xx::_setTerminalBaud: Unknown exception!!!" << std::endl;
  2789     payload_buffer[0] = 0x3A; 
  2802     catch(SickTimeoutException &sick_timeout_exception) {
  2803       std::cerr << sick_timeout_exception.
what() << std::endl;
  2808     catch(SickIOException &sick_io_exception) {
  2809       std::cerr << sick_io_exception.
what() << std::endl;
  2814     catch(SickThreadException &sick_thread_exception) {
  2815       std::cerr << sick_thread_exception.
what() << std::endl;
  2821       std::cerr << 
"SickLMS2xx::_getSickType: Unknown exception!!!" << std::endl;
  2826     memset(payload_buffer,0,1);
  2835     char * string_buffer = 
new char[payload_length-1];
  2838     memset(string_buffer,0,payload_length-1);
  2839     memcpy(string_buffer,&payload_buffer[1],payload_length-2);
  2842     std::string type_string = string_buffer;
  2845     if(type_string.find(
"LMS200;30106") != std::string::npos) {
  2847     } 
else if(type_string.find(
"LMS211;30106") != std::string::npos) {
  2849     } 
else if(type_string.find(
"LMS211;30206") != std::string::npos) {
  2851     } 
else if(type_string.find(
"LMS211;S07") != std::string::npos) {
  2853     } 
else if(type_string.find(
"LMS211;S14") != std::string::npos) {
  2855     } 
else if(type_string.find(
"LMS211;S15") != std::string::npos) {
  2857     } 
else if(type_string.find(
"LMS211;S19") != std::string::npos) {
  2859     } 
else if(type_string.find(
"LMS211;S20") != std::string::npos) {
  2861     } 
else if(type_string.find(
"LMS220;30106") != std::string::npos) {
  2863     } 
else if(type_string.find(
"LMS221;30106") != std::string::npos) {
  2865     } 
else if(type_string.find(
"LMS221;30206") != std::string::npos) {
  2867     } 
else if(type_string.find(
"LMS221;S07") != std::string::npos) {
  2869     } 
else if(type_string.find(
"LMS221;S14") != std::string::npos) {
  2871     } 
else if(type_string.find(
"LMS221;S15") != std::string::npos) {
  2873     } 
else if(type_string.find(
"LMS221;S16") != std::string::npos) {
  2875     } 
else if(type_string.find(
"LMS221;S19") != std::string::npos) {
  2877     } 
else if(type_string.find(
"LMS221;S20") != std::string::npos) {
  2879     } 
else if(type_string.find(
"LMS291;S05") != std::string::npos) {
  2881     } 
else if(type_string.find(
"LMS291;S14") != std::string::npos) {
  2883     } 
else if(type_string.find(
"LMS291;S15") != std::string::npos) {
  2890     if (string_buffer) {
  2891       delete [] string_buffer;
  2906      payload_buffer[0] = 0x74;
  2919      catch(SickTimeoutException &sick_timeout_exception) {
  2920        std::cerr << sick_timeout_exception.
what() << std::endl;
  2925      catch(SickIOException &sick_io_exception) {
  2926        std::cerr << sick_io_exception.
what() << std::endl;
  2931      catch(SickThreadException &sick_thread_exception) {
  2932        std::cerr << sick_thread_exception.
what() << std::endl;
  2938        std::cerr << 
"SickLMS2xx::_getSickConfig: Unknown exception!!!" << std::endl;
  2943      payload_buffer[0] = 0;
  2962       std::cout << 
"\tAttempting to configure the device (this can take a few seconds)..." << std::endl;
  2972       payload_buffer[0] = 0x77; 
  2980       memcpy(&payload_buffer[1],&temp_buffer,2);
  2983       payload_buffer[3] = sick_device_config.sick_stop_threshold; 
  2984       payload_buffer[4] = sick_device_config.sick_peak_threshold; 
  2987       payload_buffer[5] = sick_device_config.sick_availability_level;
  2990       payload_buffer[6] = sick_device_config.sick_measuring_mode;
  2993       payload_buffer[7] = sick_device_config.sick_measuring_units;
  2996       payload_buffer[8] = sick_device_config.sick_temporary_field;
  2999       payload_buffer[9] = sick_device_config.sick_subtractive_fields;
  3002       payload_buffer[10] = sick_device_config.sick_multiple_evaluation;
  3005       payload_buffer[11] = sick_device_config.sick_restart;
  3008       payload_buffer[12] = sick_device_config.sick_restart_time;
  3011       payload_buffer[13] = sick_device_config.sick_multiple_evaluation_suppressed_objects;
  3014       payload_buffer[14] = sick_device_config.sick_contour_a_reference;
  3017       payload_buffer[15] = sick_device_config.sick_contour_a_positive_tolerance_band;
  3020       payload_buffer[16] = sick_device_config.sick_contour_a_negative_tolerance_band;
  3023       payload_buffer[17] = sick_device_config.sick_contour_a_start_angle;
  3026       payload_buffer[18] = sick_device_config.sick_contour_a_stop_angle;
  3029       payload_buffer[19] = sick_device_config.sick_contour_b_reference;
  3032       payload_buffer[20] = sick_device_config.sick_contour_b_positive_tolerance_band;
  3035       payload_buffer[21] = sick_device_config.sick_contour_b_negative_tolerance_band;
  3038       payload_buffer[22] = sick_device_config.sick_contour_b_start_angle;
  3041       payload_buffer[23] = sick_device_config.sick_contour_b_stop_angle;
  3044       payload_buffer[24] = sick_device_config.sick_contour_c_reference;
  3047       payload_buffer[25] = sick_device_config.sick_contour_c_positive_tolerance_band;
  3050       payload_buffer[26] = sick_device_config.sick_contour_c_negative_tolerance_band;
  3053       payload_buffer[27] = sick_device_config.sick_contour_c_start_angle;
  3056       payload_buffer[28] = sick_device_config.sick_contour_c_stop_angle;
  3059       payload_buffer[29] = sick_device_config.sick_pixel_oriented_evaluation;
  3062       payload_buffer[30] = sick_device_config.sick_single_measured_value_evaluation_mode;
  3066       memcpy(&payload_buffer[31],&temp_buffer,2);
  3070       memcpy(&payload_buffer[33],&temp_buffer,2);
  3079       memset(payload_buffer,0,35);
  3085       if (payload_buffer[1] != 0x01) {
  3090       std::cout << 
"\t\tConfiguration successful! :o)" << std::endl;
  3105       std::cerr << sick_timeout_exception.
what() << std::endl;
  3111       std::cerr << sick_config_exception.
what() << std::endl;
  3117       std::cerr << sick_io_exception.
what() << std::endl;
  3123       std::cerr << sick_thread_exception.
what() << std::endl;
  3129       std::cerr << 
"SickLMS2xx::_setSickConfig: Unknown exception!" << std::endl;
  3147      payload_buffer[0] = 0x32;
  3161        std::cerr << sick_timeout_exception.
what() << std::endl;
  3167        std::cerr << sick_io_exception.
what() << std::endl;
  3173        std::cerr << sick_thread_exception.
what() << std::endl;
  3179        std::cerr << 
"SickLMS2xx::_getSickErrors: Unknown exception!!!" << std::endl;
  3187      double num_errors = ((payload_length-2)/((
double)2));
  3190      if (num_sick_errors) {
  3191        *num_sick_errors = (
unsigned int)num_errors;
  3195      for (
unsigned int i = 0, k = 1; i < (
unsigned int)num_errors && (error_type_buffer || error_num_buffer); i++) {
  3198        if (error_type_buffer) {
  3199          error_type_buffer[i] = payload_buffer[k];
  3204        if (error_num_buffer) {
  3205          error_num_buffer[i] = payload_buffer[k];
  3223     payload_buffer[0] = 0x31;
  3236     catch(SickTimeoutException &sick_timeout_exception) {
  3237       std::cerr << sick_timeout_exception.
what() << std::endl;
  3242     catch(SickIOException &sick_io_exception) {
  3243       std::cerr << sick_io_exception.
what() << std::endl;
  3248     catch(SickThreadException &sick_thread_exception) {
  3249       std::cerr << sick_thread_exception.
what() << std::endl;
  3255       std::cerr << 
"SickLMS2xx::_getSickStatus: Unknown exception!" << std::endl;
  3260     payload_buffer[0] = 0;
  3332     for (
unsigned int i = 0, k = 19; i < 8; i++, k+=2) {
  3339     for (
unsigned int i = 0, k = 35; i < 4; i++, k+=2) {
  3346     for (
unsigned int i = 0, k = 43; i < 8; i++, k+=2) {
  3353     for (
unsigned int i = 0, k = 59; i < 4; i++, k+=2) {
  3519       catch(SickConfigException &sick_config_exception) {
  3520         std::cerr << sick_config_exception.
what() << std::endl;
  3525       catch(SickTimeoutException &sick_timeout_exception) {
  3526         std::cerr << sick_timeout_exception.
what() << std::endl;
  3531       catch(SickIOException &sick_io_exception) {
  3532         std::cerr << sick_io_exception.
what() << std::endl;
  3537       catch(SickThreadException &sick_thread_exception) {
  3538         std::cerr << sick_thread_exception.
what() << std::endl;
  3544         std::cerr << 
"SickLMS2xx::_setSickOpModeInstallation: Unknown exception!!!" << std::endl;
  3567       std::cout << 
"\tAttempting to enter diagnostic mode..." << std::endl;
  3577       catch(SickConfigException &sick_config_exception) {
  3578         std::cerr << sick_config_exception.
what() << std::endl;
  3583       catch(SickTimeoutException &sick_timeout_exception) {
  3584         std::cerr << sick_timeout_exception.
what() << std::endl;
  3589       catch(SickIOException &sick_io_exception) {
  3590         std::cerr << sick_io_exception.
what() << std::endl;
  3595       catch(SickThreadException &sick_thread_exception) {
  3596         std::cerr << sick_thread_exception.
what() << std::endl;
  3602         std::cerr << 
"SickLMS2xx::_setSickOpModeInstallation: Unknown exception!!!" << std::endl;
  3612       std::cout << 
"Success!" << std::endl;
  3635       catch(SickConfigException &sick_config_exception) {
  3636         std::cerr << sick_config_exception.
what() << std::endl;
  3641       catch(SickTimeoutException &sick_timeout_exception) {
  3642         std::cerr << sick_timeout_exception.
what() << std::endl;
  3647       catch(SickIOException &sick_io_exception) {
  3648         std::cerr << sick_io_exception.
what() << std::endl;
  3653       catch(SickThreadException &sick_thread_exception) {
  3654         std::cerr << sick_thread_exception.
what() << std::endl;
  3660         std::cerr << 
"SickLMS2xx::_setSickOpModeMonitorRequestValues: Unknown exception!!!" << std::endl;
  3683       std::cout << 
"\tRequesting measured value data stream..." << std::endl;
  3693       catch(SickConfigException &sick_config_exception) {
  3694         std::cerr << sick_config_exception.
what() << std::endl;
  3699       catch(SickTimeoutException &sick_timeout_exception) {
  3700         std::cerr << sick_timeout_exception.
what() << std::endl;
  3705       catch(SickIOException &sick_io_exception) {
  3706         std::cerr << sick_io_exception.
what() << std::endl;
  3711       catch(SickThreadException &sick_thread_exception) {
  3712         std::cerr << sick_thread_exception.
what() << std::endl;
  3718         std::cerr << 
"SickLMS2xx::_setSickOpModeMonitorStreamValues: Unknown exception!!!" << std::endl;
  3728       std::cout << 
"\t\tData stream started!" << std::endl;
  3742       throw SickConfigException(
"SickLMS2xx::_setSickOpModeMonitorStreamRangeAndReflectivity: Mode not supported by this model!");
  3749       uint8_t mode_params[4] = {0x01,0x00,0xB5,0x00}; 
  3751       std::cout << 
"\tRequesting range & reflectivity data stream..." << std::endl;
  3761       catch(SickConfigException &sick_config_exception) {
  3762         std::cerr << sick_config_exception.
what() << std::endl;
  3767       catch(SickTimeoutException &sick_timeout_exception) {
  3768         std::cerr << sick_timeout_exception.
what() << std::endl;
  3773       catch(SickIOException &sick_io_exception) {
  3774         std::cerr << sick_io_exception.
what() << std::endl;
  3779       catch(SickThreadException &sick_thread_exception) {
  3780         std::cerr << sick_thread_exception.
what() << std::endl;
  3786         std::cerr << 
"SickLMS2xx::_setSickOpModeStreamRangeAndReflectivity: Unknown exception!!!" << std::endl;
  3796       std::cout << 
"\t\tData stream started!" << std::endl;
  3811       std::cout << 
"\tRequesting partial scan data stream..." << std::endl;
  3821       catch(SickConfigException &sick_config_exception) {
  3822         std::cerr << sick_config_exception.
what() << std::endl;
  3827       catch(SickTimeoutException &sick_timeout_exception) {
  3828         std::cerr << sick_timeout_exception.
what() << std::endl;
  3833       catch(SickIOException &sick_io_exception) {
  3834         std::cerr << sick_io_exception.
what() << std::endl;
  3839       catch(SickThreadException &sick_thread_exception) {
  3840         std::cerr << sick_thread_exception.
what() << std::endl;
  3846         std::cerr << 
"SickLMS2xx::_setSickOpModeStreamValuesFromPartialScan: Unknown exception!!!" << std::endl;
  3856       std::cout << 
"\t\tData stream started!" << std::endl;
  3873       if(sample_size < 2 || sample_size > 250) {
  3874         throw SickConfigException(
"SickLMS2xx::_setSickOpModeMonitorStreamMeanValues: Invalid sample size!");
  3877       std::cout << 
"\tRequesting mean value data stream (sample size = " << (int)sample_size << 
")..." << std::endl;
  3888         std::cerr << sick_config_exception.
what() << std::endl;
  3894         std::cerr << sick_timeout_exception.
what() << std::endl;
  3900         std::cerr << sick_io_exception.
what() << std::endl;
  3906         std::cerr << sick_thread_exception.
what() << std::endl;
  3912         std::cerr << 
"SickLMS2xx::_setSickOpModeStreamRangeFromPartialScan: Unknown exception!!!" << std::endl;
  3925       std::cout << 
"\t\tData stream started!" << std::endl;
  3948       if(subrange_start_index > subrange_stop_index || subrange_start_index == 0 || subrange_stop_index > max_subrange_stop_index) {
  3949         throw SickConfigException(
"SickLMS2xx::_setSickOpMonitorStreamValuesSubrange: Invalid subregion bounds!");
  3953       uint8_t mode_params[4] = {0};
  3954       uint16_t temp_buffer = 0;
  3958       memcpy(mode_params,&temp_buffer,2);
  3962       memcpy(&mode_params[2],&temp_buffer,2);
  3964       std::cout << 
"\tRequesting measured value stream... (subrange = [" << subrange_start_index << 
"," << subrange_stop_index << 
"])" << std::endl;
  3975         std::cerr << sick_config_exception.
what() << std::endl;
  3981         std::cerr << sick_timeout_exception.
what() << std::endl;
  3987         std::cerr << sick_io_exception.
what() << std::endl;
  3993         std::cerr << sick_thread_exception.
what() << std::endl;
  3999         std::cerr << 
"SickLMS2xx::_setSickOpModeInstallation: Unknown exception!!!" << std::endl;
  4013       std::cout << 
"\t\tData stream started!" << std::endl;
  4035       if(sample_size < 2 || sample_size > 250) {
  4036         throw SickConfigException(
"SickLMS2xx::_setSickOpModeMonitorStreamMeanValuesSubrange: Invalid sample size!");
  4043       if(subrange_start_index > subrange_stop_index || subrange_start_index == 0 || subrange_stop_index > max_subrange_stop_index) {
  4044         throw SickConfigException(
"SickLMS2xx::_setSickOpMonitorStreamMeanValuesSubrange: Invalid subregion bounds!");
  4048       uint8_t mode_params[5] = {0};
  4049       uint16_t temp_buffer = 0;
  4052       mode_params[0] = sample_size;
  4056       memcpy(&mode_params[1],&temp_buffer,2);
  4060       memcpy(&mode_params[3],&temp_buffer,2);
  4062       std::cout << 
"\tRequesting mean value stream... (subrange = [" << subrange_start_index << 
"," << subrange_stop_index << 
"])" << std::endl;
  4073         std::cerr << sick_config_exception.
what() << std::endl;
  4079         std::cerr << sick_timeout_exception.
what() << std::endl;
  4085         std::cerr << sick_io_exception.
what() << std::endl;
  4091         std::cerr << sick_thread_exception.
what() << std::endl;
  4097         std::cerr << 
"SickLMS2xx::_setSickOpModeInstallation: Unknown exception!!!" << std::endl;
  4111       std::cout << 
"\t\tData stream started!" << std::endl;
  4128     uint16_t num_partial_scans = 0;
  4131     payload_buffer[0] = 0x20;
  4132     payload_buffer[1] = sick_mode;
  4139       if(mode_params == NULL) {
  4140         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4143       memcpy(&payload_buffer[2],mode_params,8); 
  4178       if(mode_params == NULL) {
  4179         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4182       payload_buffer[2] = *mode_params;
  4189       if(mode_params == NULL) {
  4190         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4193       memcpy(&payload_buffer[2],mode_params,2);       
  4194       memcpy(&payload_buffer[4],&mode_params[2],2);   
  4201       if(mode_params == NULL) {
  4202         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4205       payload_buffer[2] = mode_params[0];             
  4206       memcpy(&payload_buffer[3],&mode_params[1],2);   
  4207       memcpy(&payload_buffer[5],&mode_params[3],2);   
  4214       if(mode_params == NULL) {
  4215         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4218       memcpy(&payload_buffer[2],mode_params,2);       
  4219       memcpy(&payload_buffer[4],&mode_params[2],2);   
  4230       if(mode_params == NULL) {
  4231         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4235       memcpy(&num_partial_scans,mode_params,2);
  4238       memcpy(&payload_buffer[2],mode_params,num_partial_scans*4+2);
  4245       if(mode_params == NULL) {
  4246         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4250       memcpy(&num_partial_scans,mode_params,2);
  4253       memcpy(&payload_buffer[2],mode_params,num_partial_scans*4+2);    
  4264       if(mode_params == NULL) {
  4265         throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode - Requested mode requires parameters!");
  4268       memcpy(&payload_buffer[2],mode_params,2);       
  4269       memcpy(&payload_buffer[4],&mode_params[2],2);   
  4277       throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode: Unrecognized operating mode!");
  4289       std::cerr << sick_timeout_exception.
what() << std::endl;
  4295       std::cerr << sick_io_exception.
what() << std::endl;
  4301       std::cerr << sick_thread_exception.
what() << std::endl;
  4307       std::cerr << 
"SickLMS2xx::_switchSickOperatingMode: Unknown exception!!!" << std::endl;
  4312     memset(payload_buffer,0,
sizeof(payload_buffer));
  4318     if(payload_buffer[1] != 0x00) {
  4319       throw SickConfigException(
"SickLMS2xx::_switchSickOperatingMode: configuration request failed!");
  4625                                                uint8_t * 
const field_a_values, uint8_t * 
const field_b_values, uint8_t * 
const field_c_values )
 const {
  4633         for(
unsigned int i = 0; i < num_measurements; i++) {
  4634           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x1F);
  4636           if(field_a_values) {  
  4637             field_a_values[i] = byte_sequence[i*2+1] & 0x20;
  4640           if(field_b_values) {
  4641             field_b_values[i] = byte_sequence[i*2+1] & 0x40;
  4644           if(field_c_values) {
  4645             field_c_values[i] = byte_sequence[i*2+1] & 0x80;
  4656         for(
unsigned int i = 0; i < num_measurements; i++) {
  4657           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x1F);
  4659           if(field_a_values) {
  4660             field_a_values[i] = byte_sequence[i*2+1] & 0xE0;
  4671         for(
unsigned int i = 0; i < num_measurements; i++) {
  4672           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x1F);
  4674           if(field_a_values) {
  4675             field_a_values[i] = byte_sequence[i*2+1] & 0x20;
  4678           if(field_b_values) {
  4679             field_b_values[i] = byte_sequence[i*2+1] & 0x40;
  4682           if(field_c_values) {
  4683             field_c_values[i] = byte_sequence[i*2+1] & 0x80;
  4694         for(
unsigned int i = 0; i < num_measurements; i++) {
  4695           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x3F);
  4697           if (field_a_values) {
  4698             field_a_values[i] = byte_sequence[i*2+1] & 0xC0;
  4709         for(
unsigned int i = 0; i < num_measurements; i++) {
  4710           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x3F);
  4712           if(field_a_values) {
  4713             field_a_values[i] = byte_sequence[i*2+1] & 0x40;
  4716           if(field_b_values) {
  4717             field_b_values[i] = byte_sequence[i*2+1] & 0x80;
  4728         for(
unsigned int i = 0; i < num_measurements; i++) {
  4729           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x7F);
  4731           if(field_a_values) {
  4732             field_a_values[i] = byte_sequence[i*2+1] & 0x80;
  4743         for(
unsigned int i = 0; i < num_measurements; i++) {
  4744           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1] & 0x7F);
  4746           if(field_a_values) {
  4747             field_a_values[i] = byte_sequence[i*2+1] & 0x80;
  4758         for(
unsigned int i = 0; i < num_measurements; i++) {
  4759           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1]);
  4768         for(
unsigned int i = 0; i < num_measurements; i++) {
  4769           measured_values[i] = byte_sequence[i*2] + 256*(byte_sequence[i*2+1]);
  5028       std::cerr << 
"Unexpected baud rate!" << std::endl;
  5042     if (availability_flags == 0) {
  5043       return "Default (Unspecified)";
  5046     std::string availability_str;
  5049     if (0x01 & availability_flags) {
  5050       availability_str += 
"Highest";
  5054     if (0x02 & availability_flags) {
  5057       if (availability_str.length() > 0) {
  5058         availability_str += 
", ";
  5061       availability_str += 
"Real-time indices";
  5065     if (0x04 & availability_flags) {
  5068       if (availability_str.length() > 0) {
  5069         availability_str += 
", ";
  5072       availability_str += 
"No effect dazzle";
  5076     return availability_str;
  5087     std::string restart_str;
  5090     switch(restart_code) {
  5092       restart_str += 
"Restart when button actuated";
  5095       restart_str += 
"Restart after set time";
  5098       restart_str += 
"No restart block";
  5101       restart_str += 
"Button switches field set, restart after set time";
  5104       restart_str += 
"Button switches field set, no restart block";
  5107       restart_str += 
"LMS2xx operates as a slave, restart after set time";
  5110       restart_str += 
"LMS2xx operates as a slave, immediate restart";
  5113       restart_str += 
"Unknown!";      
  5128     switch(temp_field_code) {
  5132       return "Belongs to field set no. 1";
  5134       return "Belongs to field set no. 2";
  5148     switch(subt_field_code) {
  5150       return "Not active";
  5166     switch(contour_function_code) {
  5168       return "Not active";
  5172       std::ostringstream output_str;
  5175       output_str << 
"Active, Min object size: " << (int)contour_function_code << 
" (cm)";
  5176       return output_str.str();
  5192       return "Standard device (LMS2xx,type 6)";
  5195       return "Special device (LMS211-/221-S19/-S20)";
 
#define DEFAULT_SICK_LMS_2XX_BYTE_INTERVAL
Minimum time in microseconds between transmitted bytes. 
#define DEFAULT_SICK_LMS_2XX_SICK_MESSAGE_TIMEOUT
The max time to wait for a message reply (usecs) 
#define DEFAULT_SICK_LMS_2XX_SICK_SWITCH_MODE_TIMEOUT
Can take the Sick LD up to 3 seconds to reply (usecs) 
Contains some simple exception classes. 
#define DEFAULT_SICK_LMS_2XX_SICK_ADDRESS
Sick LMS default serial address. 
Defines simple utility functions for working with the Sick LMS 2xx laser range finder units...
Definition of class SickLMS2xxMessage. 
#define DEFAULT_SICK_LMS_2XX_SICK_BAUD
Initial baud rate of the LMS (whatever is set in flash) 
Definition of class SickLMS2xx. Code by Jason C. Derenick and Thomas H. Miller. Contact derenick(at)l...
#define DEFAULT_SICK_LMS_2XX_NUM_TRIES
The max number of tries before giving up on a request. 
Defines a class for monitoring the receive buffer when interfacing w/ a Sick LMS 2xx laser range find...
#define DEFAULT_SICK_LMS_2XX_SICK_MEAN_VALUES_MESSAGE_TIMEOUT
When using mean values, the Sick can sometimes take more than 10s to respond. 
#define DEFAULT_SICK_LMS_2XX_SICK_CONFIG_MESSAGE_TIMEOUT
The sick can take some time to respond to config commands (usecs) 
#define DEFAULT_SICK_LMS_2XX_SICK_PASSWORD
Password for entering installation mode.