util.h
Go to the documentation of this file.
1 
32 #ifndef CREATE_UTIL_H
33 #define CREATE_UTIL_H
34 
35 #include <sys/time.h>
36 
37 #define COUT(prefix,msg) (std::cout<<prefix<<msg<<std::endl)
38 #define CERR(prefix,msg) (std::cerr<<prefix<<msg<<std::endl)
39 
40 namespace create {
41  namespace util {
42 
43  static const uint8_t STREAM_HEADER = 19;
44  static const float V_3_TICKS_PER_REV = 508.8;
45  static const uint32_t V_3_MAX_ENCODER_TICKS = 65535;
46  static const float MAX_RADIUS = 2.0;
47  static const float STRAIGHT_RADIUS = 32.768;
48  static const float IN_PLACE_RADIUS = 0.001;
49  static const float PI = 3.14159;
50  static const float TWO_PI = 6.28318;
51  static const float EPS = 0.0001;
52 
53  inline float normalizeAngle(const float& angle) {
54  float a = angle;
55  while (a < -PI) a += TWO_PI;
56  while (a > PI) a -= TWO_PI;
57  return a;
58  };
59 
60  typedef unsigned long long timestamp_t;
61 
64  static timestamp_t getTimestamp() {
65  struct timeval now;
66  gettimeofday(&now, NULL);
67  return now.tv_usec + (timestamp_t) now.tv_sec * 1000000;
68  }
69 
70  inline bool willFloatOverflow(const float a, const float b) {
71  return ( (a < 0.0) == (b < 0.0) && std::abs(b) > std::numeric_limits<float>::max() - std::abs(a) );
72  }
73  } // namespace util
74 } // namespace create
75 
76 #endif // CREATE_UTIL_H
static const float PI
Definition: util.h:49
static const float IN_PLACE_RADIUS
Definition: util.h:48
static const float TWO_PI
Definition: util.h:50
static timestamp_t getTimestamp()
Definition: util.h:64
unsigned long long timestamp_t
Definition: util.h:58
Definition: create.h:46
static const float V_3_TICKS_PER_REV
Definition: util.h:44
static const uint32_t V_3_MAX_ENCODER_TICKS
Definition: util.h:45
static const float MAX_RADIUS
Definition: util.h:46
bool willFloatOverflow(const float a, const float b)
Definition: util.h:70
static const float EPS
Definition: util.h:51
static const float STRAIGHT_RADIUS
Definition: util.h:47
float normalizeAngle(const float &angle)
Definition: util.h:53
static const uint8_t STREAM_HEADER
Definition: util.h:43


libcreate
Author(s): Jacob Perron
autogenerated on Sat Jun 8 2019 17:58:17