55 #ifndef __SIM_LOC_UTILS_H_INCLUDED 56 #define __SIM_LOC_UTILS_H_INCLUDED 62 #include <boost/thread.hpp> 71 template<
typename ElementType,
typename MutexType = boost::mutex>
class SetGet 79 void set(
const ElementType & value)
110 boost::lock_guard<boost::mutex> value_lockguard(
m_value_mutex);
127 static std::string
toHexString(
const std::vector<uint8_t> & binary_data);
134 static std::string toAsciiString(
const uint8_t* binary_data,
int length);
139 static void flattenString(std::string &
s);
148 std::string out(s.str());
157 s <<
"header.stamp: " << header->stamp.sec <<
"." << header->stamp.NSEC;
164 static std::string
flattenToString(
const sick_scan::SickLocColaTelegramMsg & cola_telegram)
167 s << flattenToString(&cola_telegram.header)
168 <<
", command_type: " << cola_telegram.command_type
169 <<
", command_name: " << cola_telegram.command_name <<
", parameter: [";
170 for(
size_t n = 0; n < cola_telegram.parameter.size(); n++)
171 s << (n>0?
",":
"") << cola_telegram.parameter[n];
173 std::string out(s.str());
181 static std::string
flattenToString(
const sick_scan::SickLocResultPortTelegramMsg & telegram)
185 s << flattenToString(&telegram.header)
186 <<
", telegram_payload: [posex:" << telegram.telegram_payload.posex <<
",posey:" << telegram.telegram_payload.posey <<
",poseyaw:" << telegram.telegram_payload.poseyaw
187 <<
",scancounter:" << telegram.telegram_payload.scancounter <<
",timestamp:" << telegram.telegram_payload.timestamp <<
",quality:" << (int)(telegram.telegram_payload.quality&0xFF)
188 <<
",covariancex:" << telegram.telegram_payload.covariancex <<
",covariancey:" << telegram.telegram_payload.covariancey <<
",covarianceyaw:" << telegram.telegram_payload.covarianceyaw
189 <<
",outliersratio:" << telegram.telegram_payload.outliersratio <<
",errorcode:" << telegram.telegram_payload.errorcode
190 <<
"], telegram_checksum: " << telegram.telegram_trailer.checksum;
191 std::string out(s.str());
203 std::stringstream sx, sy;
206 return sx.str() == sy.str();
214 template <
typename T>
static bool identicalByStream(
const std::vector<T> & x,
const std::vector<T> & y)
216 if(x.size() == y.size())
218 for(
size_t n = 0; n < x.size(); n++)
219 if(!identicalByStream(x[n], y[n]))
231 static bool identicalByStream(
const SickLocResultPortTelegramMsg & x,
const SickLocResultPortTelegramMsg & y)
233 #if defined __ROS_VERSION && __ROS_VERSION == 1 234 return identicalByStream(x.telegram_header, y.telegram_header)
235 && identicalByStream(x.telegram_payload, y.telegram_payload)
236 && identicalByStream(x.telegram_trailer, y.telegram_trailer);
237 #elif defined __ROS_VERSION && __ROS_VERSION == 2 238 return x.telegram_header == y.telegram_header && x.telegram_payload == y.telegram_payload && x.telegram_trailer == y.telegram_trailer;
250 static bool identicalByStream(
const SickLocColaTelegramMsg & x,
const SickLocColaTelegramMsg & y)
252 return x.command_name == y.command_name && x.command_type == y.command_type && identicalByStream(x.parameter, y.parameter);
263 angle -= (2.0 * M_PI);
265 angle += (2.0 * M_PI);
272 #endif // __SIM_LOC_UTILS_H_INCLUDED SetGet32(const uint32_t &value=0)
static bool identicalByStream(const SickLocResultPortTelegramMsg &x, const SickLocResultPortTelegramMsg &y)
static double normalizeAngle(double angle)
static bool identicalByStream(const SickLocColaTelegramMsg &x, const SickLocColaTelegramMsg &y)
static std::string flattenToString(const T &x)
MutexType m_value_mutex
mutex to protect value
static std::string flattenToString(const sick_scan::SickLocResultPortTelegramMsg &telegram)
SetGet(const ElementType &value=ElementType())
ElementType m_value
protected value
static bool identicalByStream(const T &x, const T &y)
static std::string flattenToString(const std_msgs::Header *header)
static bool identicalByStream(const std::vector< T > &x, const std::vector< T > &y)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
static sick_scan::SickScanCommonTcp * s
static std::string flattenToString(const sick_scan::SickLocColaTelegramMsg &cola_telegram)