All Classes Namespaces Files Functions Variables Enumerations Enumerator
libs/range_sensor/UrgUtils.h
Go to the documentation of this file.
00001 #ifndef QRK_URG_UTILS_H
00002 #define QRK_URG_UTILS_H
00003 
00013 #include <cstdlib>
00014 
00015 
00016 namespace qrk
00017 {
00026   template <class T>
00027   long urgSerialId(T* urg)
00028   {
00029     std::vector<std::string> version_lines;
00030     if (! urg->versionLines(version_lines)) {
00031       return -1;
00032     }
00033     if (version_lines.size() < 5) {
00034       return -1;
00035     }
00036 
00037     std::string& serial_line = version_lines[4];
00038     if (serial_line.size() < 7) {
00039       return -1;
00040     }
00041     return atol(serial_line.substr(6).c_str());
00042   }
00043 }
00044 
00045 #endif /* !QRK_URG_UTILS_H */