Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IBEO_CORE_UTILS_H
00009 #define IBEO_CORE_UTILS_H
00010
00011 #include <cmath>
00012 #include <cstddef>
00013 #include <cstdint>
00014 #include <ctime>
00015 #include <vector>
00016
00017 namespace AS
00018 {
00019 namespace Drivers
00020 {
00021 namespace Ibeo
00022 {
00023 const size_t MAGIC_WORD = 0xAFFEC0C2;
00024 typedef uint64_t NTPTime;
00025
00026 inline NTPTime unix_time_to_ntp(struct tm *tm, struct timeval *tv)
00027 {
00028 NTPTime ret_val;
00029
00030 uint64_t ntp_sec = tm->tm_year * 31536000;
00031 ntp_sec += tm->tm_yday * 86400;
00032 ntp_sec += tm->tm_hour * 3600;
00033 ntp_sec += tm->tm_min * 60;
00034 ntp_sec += tm->tm_sec;
00035
00036 ret_val = (ntp_sec << 32);
00037
00038 uint64_t ntp_frac = tv->tv_usec;
00039
00040 ret_val |= ntp_frac;
00041
00042 return ret_val;
00043 }
00044
00045 inline double ticks_to_angle(int16_t angle_ticks, uint16_t angle_ticks_per_rotation)
00046 {
00047 return (2.0 * M_PI * static_cast<double>(angle_ticks) / static_cast<double>(angle_ticks_per_rotation));
00048 };
00049 }
00050 }
00051 }
00052
00053 #endif // IBEO_CORE_UTILS_H