IMUHelpers.h
Go to the documentation of this file.
1 /*
2  * IMUHelpers.h
3  *
4  * Created on: Mar 17, 2014
5  * Author: Dr.-Ing. David Israel González Aguirre
6  * Mail: david.gonzalez@kit.edu
7  */
8 
9 #pragma once
10 
11 #include "Includes.h"
12 
13 #define _MINIMAL___LOCK(MUTEX) pthread_mutex_lock(&MUTEX);
14 #define _MINIMAL_UNLOCK(MUTEX) pthread_mutex_unlock(&MUTEX);
15 
16 namespace IMU
17 {
18  class CTimeStamp
19  {
20  public:
21 
22  inline static timeval GetCurrentTimeStamp()
23  {
24  timeval TimeStamp;
25  gettimeofday(&TimeStamp, NULL);
26  return TimeStamp;
27  }
28 
29  inline static float GetElapsedSeconds(const timeval& Post, const timeval& Pre)
30  {
31  return float(double(GetElapsedMicroseconds(Post, Pre)) / 1000000.0);
32  }
33 
34  inline static float GetElapsedMilliseconds(const timeval& Post, const timeval& Pre)
35  {
36  return float(double(GetElapsedMicroseconds(Post, Pre)) / 1000.0);
37  }
38 
39  inline static long GetElapsedMicroseconds(const timeval& Post, const timeval& Pre)
40  {
41  return ((Post.tv_sec - Pre.tv_sec) * 1000000) + (Post.tv_usec - Pre.tv_usec);
42  }
43 
44  inline static long GetElapsedMicroseconds(const timeval& Pre)
45  {
46  timeval Post;
47  gettimeofday(&Post, NULL);
48  return ((Post.tv_sec - Pre.tv_sec) * 1000000) + (Post.tv_usec - Pre.tv_usec);
49  }
50 
51  static const timeval s_Zero;
52  };
53 
55  {
56  public:
57 
58  static const float s_G_LPoles;
59  static const float s_G_L45;
60  static const float s_G_LEquator;
61 
62  //LatitudeInDegrees of your location:
63  //http://www.mapsofworld.com/lat_long/germany-lat-long.html
64  //49.0167 Karlsruhe, Germany
65 
66  static float GetGravitationalAcceleration(const float LatitudeInDegrees = 49.0167f)
67  {
68  return s_G_L45 - (s_G_LPoles - s_G_LEquator) * std::cos((float(M_PI) / 90.0f) * LatitudeInDegrees);
69  }
70  };
71 
72 
73 
74 }
75 
IMU::CTimeStamp::GetElapsedSeconds
static float GetElapsedSeconds(const timeval &Post, const timeval &Pre)
Definition: IMUHelpers.h:29
IMU::CGeolocationInformation::s_G_LEquator
static const float s_G_LEquator
Definition: IMUHelpers.h:60
IMU::CGeolocationInformation::s_G_LPoles
static const float s_G_LPoles
Definition: IMUHelpers.h:58
IMU::CTimeStamp::GetElapsedMilliseconds
static float GetElapsedMilliseconds(const timeval &Post, const timeval &Pre)
Definition: IMUHelpers.h:34
Includes.h
M_PI
#define M_PI
Definition: MathTools.h:17
IMU::CTimeStamp
Definition: IMUHelpers.h:18
IMU
Definition: IIMUEventDispatcher.cpp:12
IMU::CGeolocationInformation::GetGravitationalAcceleration
static float GetGravitationalAcceleration(const float LatitudeInDegrees=49.0167f)
Definition: IMUHelpers.h:66
IMU::CTimeStamp::GetElapsedMicroseconds
static long GetElapsedMicroseconds(const timeval &Pre)
Definition: IMUHelpers.h:44
float
#define float
Definition: 16_Level.h:22
IMU::CTimeStamp::s_Zero
static const timeval s_Zero
Definition: IMUHelpers.h:51
IMU::CTimeStamp::GetCurrentTimeStamp
static timeval GetCurrentTimeStamp()
Definition: IMUHelpers.h:22
IMU::CTimeStamp::GetElapsedMicroseconds
static long GetElapsedMicroseconds(const timeval &Post, const timeval &Pre)
Definition: IMUHelpers.h:39
IMU::CGeolocationInformation::s_G_L45
static const float s_G_L45
Definition: IMUHelpers.h:59
IMU::CGeolocationInformation
Definition: IMUHelpers.h:54