utils.h
Go to the documentation of this file.
00001 /*
00002 * Unpublished Copyright (c) 2009-2019 AutonomouStuff, LLC, All Rights Reserved.
00003 *
00004 * This file is part of the ibeo_core ROS driver which is released under the MIT license.
00005 * See file LICENSE included with this software or go to https://opensource.org/licenses/MIT for full license details.
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;  // Add years since 1900 (in seconds)
00031   ntp_sec += tm->tm_yday * 86400;                  // Add days since Jan 1st (in seconds)
00032   ntp_sec += tm->tm_hour * 3600;                   // Add hours since midnight (in seconds)
00033   ntp_sec += tm->tm_min * 60;                      // Add minutes after the hour (in seconds)
00034   ntp_sec += tm->tm_sec;                           // Add seconds after the minute
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 }  // namespace Ibeo
00050 }  // namespace Drivers
00051 }  // namespace AS
00052 
00053 #endif  // IBEO_CORE_UTILS_H


ibeo_core
Author(s): Joshua Whitley , Daniel Stanek
autogenerated on Sat May 18 2019 02:23:51