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  inline static timeval
23  {
24  timeval TimeStamp;
25  gettimeofday(&TimeStamp, NULL);
26  return TimeStamp;
27  }
28 
29  inline static float
30  GetElapsedSeconds(const timeval& Post, const timeval& Pre)
31  {
32  return float(double(GetElapsedMicroseconds(Post, Pre)) / 1000000.0);
33  }
34 
35  inline static float
36  GetElapsedMilliseconds(const timeval& Post, const timeval& Pre)
37  {
38  return float(double(GetElapsedMicroseconds(Post, Pre)) / 1000.0);
39  }
40 
41  inline static long
42  GetElapsedMicroseconds(const timeval& Post, const timeval& Pre)
43  {
44  return ((Post.tv_sec - Pre.tv_sec) * 1000000) + (Post.tv_usec - Pre.tv_usec);
45  }
46 
47  inline static long
48  GetElapsedMicroseconds(const timeval& Pre)
49  {
50  timeval Post;
51  gettimeofday(&Post, NULL);
52  return ((Post.tv_sec - Pre.tv_sec) * 1000000) + (Post.tv_usec - Pre.tv_usec);
53  }
54 
55  static const timeval s_Zero;
56  };
57 
59  {
60  public:
61  static const float s_G_LPoles;
62  static const float s_G_L45;
63  static const float s_G_LEquator;
64 
65  //LatitudeInDegrees of your location:
66  //http://www.mapsofworld.com/lat_long/germany-lat-long.html
67  //49.0167 Karlsruhe, Germany
68 
69  static float
70  GetGravitationalAcceleration(const float LatitudeInDegrees = 49.0167f)
71  {
72  return s_G_L45 - (s_G_LPoles - s_G_LEquator) *
73  std::cos((float(M_PI) / 90.0f) * LatitudeInDegrees);
74  }
75  };
76 
77 
78 } // namespace IMU
IMU::CTimeStamp::GetElapsedSeconds
static float GetElapsedSeconds(const timeval &Post, const timeval &Pre)
Definition: IMUHelpers.h:30
IMU::CGeolocationInformation::s_G_LEquator
static const float s_G_LEquator
Definition: IMUHelpers.h:63
IMU::CGeolocationInformation::s_G_LPoles
static const float s_G_LPoles
Definition: IMUHelpers.h:61
IMU::CTimeStamp::GetElapsedMilliseconds
static float GetElapsedMilliseconds(const timeval &Post, const timeval &Pre)
Definition: IMUHelpers.h:36
Includes.h
M_PI
#define M_PI
Definition: MathTools.h:17
IMU::CTimeStamp
Definition: IMUHelpers.h:18
IMU
Definition: IIMUEventDispatcher.cpp:13
IMU::CGeolocationInformation::GetGravitationalAcceleration
static float GetGravitationalAcceleration(const float LatitudeInDegrees=49.0167f)
Definition: IMUHelpers.h:70
IMU::CTimeStamp::GetElapsedMicroseconds
static long GetElapsedMicroseconds(const timeval &Pre)
Definition: IMUHelpers.h:48
float
#define float
Definition: 16_Level.h:22
IMU::CTimeStamp::s_Zero
static const timeval s_Zero
Definition: IMUHelpers.h:55
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:42
IMU::CGeolocationInformation::s_G_L45
static const float s_G_L45
Definition: IMUHelpers.h:62
IMU::CGeolocationInformation
Definition: IMUHelpers.h:58