ISConstants.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef CONSTANTS_H_
14 #define CONSTANTS_H_
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #undef _MATH_DEFINES_DEFINED
21 #define _MATH_DEFINES_DEFINED
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <math.h>
25 #include <string.h>
26 #include <assert.h>
27 #include <inttypes.h>
28 #include <time.h>
29 
30 #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32)
31 
32 #define PLATFORM_IS_WINDOWS 1
33 #define PLATFORM_IS_EMBEDDED 0
34 #ifndef _CRT_SECURE_NO_DEPRECATE
35 #define _CRT_SECURE_NO_DEPRECATE
36 #endif
37 
38 // If you are getting winsock compile errors, make sure to include ISConstants.h as the first file in your header or c/cpp file
39 #define _WINSOCKAPI_
40 #include <winsock2.h>
41 #include <WS2tcpip.h>
42 #include <windows.h>
43 #define socket_t SOCKET
44 
45 #define CPU_IS_LITTLE_ENDIAN (REG_DWORD == REG_DWORD_LITTLE_ENDIAN)
46 #define CPU_IS_BIG_ENDIAN (REG_DWORD == REG_DWORD_BIG_ENDIAN)
47 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
48 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
49 
50 #elif defined(__APPLE__)
51 
52 #define socket_t int
53 
54 #define PLATFORM_IS_APPLE 1
55 #define PLATFORM_IS_EMBEDDED 0
56 
57 #if defined(__LITTLE_ENDIAN__)
58 #define CPU_IS_LITTLE_ENDIAN 1
59 #define CPU_IS_BIG_ENDIAN 0
60 #elif defined(__BIG_ENDIAN__)
61 #define CPU_IS_LITTLE_ENDIAN 0
62 #define CPU_IS_BIG_ENDIAN 1
63 #endif
64 
65 #elif defined(__linux__) || defined(__unix__) || defined(__CYGWIN__)
66 
67 #include <endian.h>
68 
69 #ifndef __BYTE_ORDER
70 #error __BYTE_ORDER not defined, must be __LITTLE_ENDIAN or __BIG_ENDIAN
71 #endif
72 
73 #define PLATFORM_IS_LINUX 1
74 #define PLATFORM_IS_EMBEDDED 0
75 #define socket_t int
76 #define CPU_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
77 #define CPU_IS_BIG_ENDIAN (__BYTE_ORDER == __BIG_ENDIAN)
78 
79 #elif defined(__INERTIAL_SENSE_EVB_2__)
80 #define PLATFORM_IS_EMBEDDED 1
81 #define PLATFORM_IS_ARM 1
82 #define PLATFORM_IS_EVB_2 1
83 #define CPU_IS_LITTLE_ENDIAN 1
84 #define CPU_IS_BIG_ENDIAN 0
85 
86 
87 #elif defined(ARM) || defined(__SAM3X8E__)
88 
89 #define PLATFORM_IS_EMBEDDED 1
90 #define PLATFORM_IS_ARM 1
91 #define CPU_IS_LITTLE_ENDIAN 1
92 #define CPU_IS_BIG_ENDIAN 0
93 
94 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega168__) ||defined(__AVR_ATmega168P__) ||defined(__AVR_ATmega328P__)
95 #define PLATFORM_IS_EMBEDDED 1
96 #define PLATFORM_IS_ARM 0
97 #define CPU_IS_LITTLE_ENDIAN 1
98 #define CPU_IS_BIG_ENDIAN 0
99 
100 #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
101 
102 #define PLATFORM_IS_EMBEDDED 1
103 #define PLATFORM_IS_ARM 1
104 #define CPU_IS_LITTLE_ENDIAN 1
105 #define CPU_IS_BIG_ENDIAN 0
106 
107 #else
108 
109 #error Unknown platform not supported, be sure to set it up here, defining CPU_IS_LITTLE_ENDIAN and CPU_IS_BIG_ENDIAN
110 
111 #endif // platform defines
112 
113 #if !defined(CPU_IS_LITTLE_ENDIAN) || !defined(CPU_IS_BIG_ENDIAN) || CPU_IS_LITTLE_ENDIAN == CPU_IS_BIG_ENDIAN
114 
115 #error Unsupported / unknown CPU architecture
116 
117 #endif // Invalid CPU endianess
118 
119 
120 // "PLATFORM_IS_EMBEDDED" must be defined
121 #if !defined(PLATFORM_IS_EMBEDDED)
122 #error "Missing PLATFORM_IS_EMBEDDED macro!!!"
123 #endif
124 
125 
126 #if PLATFORM_IS_EMBEDDED
127 
128 extern void* pvPortMalloc(size_t xWantedSize);
129 extern void vPortFree(void* pv);
130 #define MALLOC(m) pvPortMalloc(m)
131 #define REALLOC(m, size) 0 // not supported
132 #define FREE(m) vPortFree(m)
133 
134 #else
135 
136 #define MALLOC(m) malloc(m)
137 #define REALLOC(m, size) realloc(m, size)
138 #define FREE(m) free(m)
139 
140 #endif
141 
142 #if PLATFORM_IS_EMBEDDED
143 #include "../hw-libs/printf-master/printf.h" // Use embedded-safe SNPRINTF
144 #define SNPRINTF snprintf_
145 #else
146 #define SNPRINTF snprintf
147 #endif
148 
149 
150 #if defined(_MSC_VER)
151 
152 #ifndef INLINE
153 #define INLINE __inline
154 #endif
155 
156 #ifndef SSCANF
157 #define SSCANF(src, fmt, ...) sscanf_s(src, fmt, __VA_ARGS__);
158 #endif
159 
160 #ifndef STRNCPY
161 #define STRNCPY(a, b, c) strncpy_s(a, c, b, c);
162 #endif
163 
164 #define strncasecmp _strnicmp
165 
166 #else
167 
168 #ifndef INLINE
169 #define INLINE inline
170 #endif
171 
172 #ifndef SSCANF
173 #define SSCANF sscanf
174 #endif
175 
176 #ifndef STRNCPY
177 #define STRNCPY(a, b, c) strncpy((char*)a, (char*)b, c)
178 #endif
179 
180 #endif // defined(_MSC_VER)
181 
182 #if defined(PLATFORM_IS_EVB_2)
183 #define _MKDIR(dir) f_mkdir(dir)
184 #define _RMDIR(dir) f_unlink(dir)
185 #define _GETCWD(buf, len) f_getcwd(buf, len)
186 
187 #elif !PLATFORM_IS_EMBEDDED
188 #define BEGIN_CRITICAL_SECTION
189 #define END_CRITICAL_SECTION
190 #define DBGPIO_ENABLE(pin)
191 #define DBGPIO_START(pin)
192 #define DBGPIO_END(pin)
193 #define DBGPIO_TOGGLE(pin)
194 
195 #if PLATFORM_IS_WINDOWS
196 
197 #include <direct.h>
198 #include <sys/utime.h>
199 #define _MKDIR(dir) _mkdir(dir)
200 #define _RMDIR(dir) _rmdir(dir)
201 #define _GETCWD(buf, len) _getcwd(buf, len)
202 #define _UTIME _utime
203 #define _UTIMEBUF struct _utimbuf
204 
205 #else // POSIX
206 
207 #include <unistd.h>
208 #include <dirent.h>
209 #include <errno.h>
210 #include <utime.h>
211 #include <sys/stat.h>
212 //#define _MKDIR(dir) mkdir(dir, S_IRWXU) // 777 owner access only
213 #define _MKDIR(dir) mkdir(dir, ACCESSPERMS) // 0777 access for all
214 #define _RMDIR(dir) rmdir(dir)
215 #define _GETCWD(buf, len) getcwd(buf, len)
216 #define _UTIME utime
217 #define _UTIMEBUF struct utimbuf
218 
219 #endif
220 
221 #endif
222 
223 // with this you can tell the compiler not to insert padding
224 #if defined(_MSC_VER)
225 #define PUSH_PACK_1 __pragma(pack(push, 1))
226 #define PUSH_PACK_4 __pragma(pack(push, 4))
227 #define PUSH_PACK_8 __pragma(pack(push, 8))
228 #define POP_PACK __pragma(pack(pop))
229 #define PACKED
230 #else
231 #define PUSH_PACK_1 _Pragma("pack(push, 1)")
232 #define PUSH_PACK_4 _Pragma("pack(push, 4)")
233 #define PUSH_PACK_8 _Pragma("pack(push, 8)")
234 #define POP_PACK _Pragma("pack(pop)")
235 #define PACKED
236 #endif
237 
238 // #define PACKED_STRUCT typedef struct PACKED
239 // #define PACKED_UNION typedef union PACKED
240 
241 #ifndef RAMFUNC
242 
243 /* Define RAMFUNC attribute */
244 #if defined ( __CC_ARM ) /* Keil uVision 4 */
245 # define RAMFUNC __attribute__ ((section(".ramfunc")))
246 #elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
247 # define RAMFUNC __ramfunc
248 #elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
249 # define RAMFUNC __attribute__ ((section(".ramfunc")))
250 #else
251 # define RAMFUNC
252 #endif
253 
254 #endif
255 
256 #ifndef UNMASK
257 #define UNMASK(_word, _prefix) (((_word) & (_prefix##_MASK)) >> (_prefix##_SHIFT))
258 #endif
259 
260 #ifndef MASK
261 #define MASK(_prefix, _val) ((_prefix##_MASK) & ((_val) << (_prefix##_SHIFT)))
262 #endif
263 
264 #ifndef SWAP16
265 #define SWAP16(v) ((uint16_t)(((uint16_t)(v) >> 8) | ((uint16_t)(v) << 8)))
266 #endif
267 
268 #ifndef SWAP32
269 #if defined(__GNUC__)
270 #define SWAP32 __builtin_bswap32
271 #define SWAP64 __builtin_bswap64
272 #elif defined(__ICCAVR32__)
273 #define SWAP32 __swap_bytes
274 #elif defined(_MSC_VER)
275 #include "intrin.h"
276 #define SWAP32 _byteswap_ulong
277 #define SWAP64 _byteswap_uint64
278 #endif
279 #endif
280 
281 #ifndef SWAP32
282 #define SWAP32(v) ((uint32_t)(((uint32_t)SWAP16((uint32_t)(v) >> 16)) | ((uint32_t)SWAP16((uint32_t)(v)) << 16)))
283 #endif
284 
285 #ifndef SWAP64
286 #define SWAP64(v) ((uint64_t)(((uint64_t)SWAP32((uint64_t)(v) >> 32)) | ((uint64_t)SWAP32((uint64_t)(v)) << 32)))
287 #endif
288 
289 #ifndef _ABS
290 #define _ABS(a) (a < 0 ? -a : a)
291 #endif
292 
293 #ifndef _MAX
294 #define _MAX(a,b) (((a) > (b)) ? (a) : (b))
295 #endif
296 
297 #ifndef _MIN
298 #define _MIN(a,b) (((a) < (b)) ? (a) : (b))
299 #endif
300 
301 #ifndef _CLAMP
302 #define _CLAMP(v, minV, maxV) (v < minV ? minV : (v > maxV ? maxV : v))
303 #endif
304 
305 #ifndef _SATURATE
306 #define _SATURATE(v) _CLAMP(v, 0, 1)
307 #endif
308 
309 #ifndef _LIMIT
310 #define _LIMIT(x, lim) {if(!((x)>(-lim))){(x)=(-lim);}else{if(!((x)<(lim))){(x)=(lim);}}} // Works w/ NAN
311 #endif
312 
313 #ifndef _LIMIT2
314 #define _LIMIT2(x, xmin, xmax) { if ((x) < (xmin)) { (x) = (xmin); } else { if ((x) > (xmax)) { (x) = (xmax); } } }
315 #endif
316 
317 #ifndef _ISNAN
318 #define _ISNAN(a) ((a)!=(a))
319 #endif
320 
321 #ifndef _ARRAY_BYTE_COUNT
322 #define _ARRAY_BYTE_COUNT(a) sizeof(a)
323 #endif
324 
325 #ifndef _ARRAY_ELEMENT_COUNT
326 #define _ARRAY_ELEMENT_COUNT(a) (sizeof(a) / sizeof(a[0]))
327 #endif
328 
329 #ifndef _MEMBER_ARRAY_ELEMENT_COUNT
330 #define _MEMBER_ARRAY_ELEMENT_COUNT(type, member) _ARRAY_ELEMENT_COUNT(((type*)0)->member)
331 #endif
332 
333 #ifndef MEMBERSIZE
334 #define MEMBERSIZE(type, member) sizeof(((type*)0)->member)
335 #endif
336 
337 #ifndef MEMBER_ITEM_SIZE
338 #define MEMBER_ITEM_SIZE(type, member) sizeof(((type*)NULL)->member[0])
339 #endif
340 
341 /* equivalent to `offsetof(type, member[i])`, but does not require that `i` is a constant expression.*/
342 #ifndef OFFSET_OF_MEMBER_INDEX
343 #define OFFSET_OF_MEMBER_INDEX(type, member, i) (offsetof(type, member) + (i) * MEMBER_ITEM_SIZE(type, member))
344 #endif
345 
346 /* equivalent to `offsetof(type, member[i].submember)`, but does not require that `i` is a constant expression. */
347 #ifndef OFFSET_OF_MEMBER_INDEX_SUBMEMBER
348 #define OFFSET_OF_MEMBER_INDEX_SUBMEMBER(type, member, i, submember) (offsetof(type, member[0].submember) + (i) * MEMBER_ITEM_SIZE(type, member))
349 #endif
350 
351 #ifndef STRINGIFY
352 #define STRINGIFY(x) #x
353 #endif
354 
355 #ifndef M_PI
356 #define M_PI (3.14159265358979323846f)
357 #endif
358 
359 #ifndef RAD2DEG
360 #define RAD2DEG(rad) ((rad)*(180.0f/M_PI))
361 #endif
362 #ifndef DEG2RAD
363 #define DEG2RAD(deg) ((deg)*(M_PI/180.0f))
364 #endif
365 #ifndef DEG2RADMULT
366 #define DEG2RADMULT (M_PI/180.0f)
367 #endif
368 #ifndef RAD2DEGMULT
369 #define RAD2DEGMULT (180.0f/M_PI)
370 #endif
371 #define ATanH(x) (0.5 * log((1 + x) / (1 - x)))
372 
373 #if defined(__cplusplus)
374 
375 #define PURE_VIRTUAL = 0
376 
377 #endif
378 
379 #if ((defined(_MSC_VER) && _MSC_VER >= 1900) || (defined(__cplusplus) && ((__cplusplus >= 201103L || (__cplusplus < 200000 && __cplusplus > 199711L)))))
380 
381 #ifndef CPP11_IS_ENABLED
382 #define CPP11_IS_ENABLED 1
383 #endif
384 #ifndef CONST_EXPRESSION
385 #define CONST_EXPRESSION constexpr static
386 #endif
387 #ifndef STATIC_ASSERT
388 #define STATIC_ASSERT(exp) static_assert(exp, "STATIC ASSERT FAILED!")
389 #endif
390 #ifndef STATIC_ASSERT_MSG
391 #define STATIC_ASSERT_MSG(exp, msg) static_assert(exp, msg)
392 #endif
393 #ifndef OVERRIDE
394 #define OVERRIDE override
395 #endif
396 #ifndef NULLPTR
397 #define NULLPTR nullptr
398 #endif
399 
400 #else
401 
402 // #if defined(__GNUC__)
403 // #pragma GCC diagnostic push
404 // #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
405 // #endif
406 
407 #ifndef CPP11_IS_ENABLED
408 #define CPP11_IS_ENABLED 0
409 #endif
410 #ifndef CONST_EXPRESSION
411 #define CONST_EXPRESSION static const
412 #endif
413 #define PRE_PROC_COMBINE(X, Y) X##Y
414 #ifndef STATIC_ASSERT
415 // #define STATIC_ASSERT(exp) typedef char PRE_PROC_COMBINE(STATIC_ASSERT_FAILED_, __LINE__)[(exp) ? 1 : -1]
416 #define STATIC_ASSERT(exp) static_assert(exp, "STATIC ASSERT FAILED!")
417 #endif
418 #ifndef STATIC_ASSERT_MSG
419 // #define STATIC_ASSERT_MSG(exp, msg) typedef char PRE_PROC_COMBINE(msg, __LINE__)[(exp) ? 1 : -1]
420 #define STATIC_ASSERT_MSG(exp, msg) static_assert(exp, msg)
421 #endif
422 #ifndef OVERRIDE
423 #define OVERRIDE
424 #endif
425 #ifndef NULLPTR
426 #define NULLPTR 0
427 #endif
428 
429 // #if defined(__GNUC__)
430 // #pragma GCC diagnostic pop
431 // #endif
432 
433 #endif
434 
435 
437 // Time
438 // diff two times as uint32_t, handling wrap-around
439 #define UINT32_TIME_DIFF(current, prev) ((uint32_t)(current) - (uint32_t)(prev))
440 
441 #define DT_TO_HZ(dt) (((dt) == (0.0)) ? (0) : (1.0/dt))
442 
443 #define C_WEEKS_TO_SECONDS 604800.0 // Seconds per week
444 #define C_WEEKS_TO_MILLISECONDS 604800000 // Milliseconds per week
445 
446 #define MS2SEC_D(ms) ((static_cast<double>(ms))*1.0E-3) // Convert milliseconds to seconds
447 
449 // Distance
450 
451 #define C_IN2M 0.0254 // inches to meters
452 #define C_FT2M 0.3048 // (C_IN2M*12) feet to meters
453 #define C_M2FT 3.2808398950131233595800524934383 // (1.0/C_FT2M)
454 
455 #define C_YD2M 0.9144 // (C_FT2M*3) yards to meters
456 
457 #define C_IN2M_F 0.0254f // inches to meters
458 #define C_FT2M_F 0.3048f // (C_IN2M*12) feet to meters
459 #define C_M2FT_F 3.2808398950131233595800524934383f // (1.0/C_FT2M)
460 #define C_YD2M_F 0.9144f // (C_FT2M*3) yards to meters
461 
462 
463 #define C_NMI2M 1852.0 // nautical miles to meters
464 #define C_MI2M 1609.344 // (C_FT2M*5280) miles to meters
465 
466 #define C_NMI2M_F 1852.0f // nautical miles to meters
467 #define C_MI2M_F 1609.344f // (C_FT2M*5280) miles to meters
468 
469 #define C_METERS_KNOTS 1.943844 // Meters/sec squared to knots
470 #define C_METERS_KNOTS_F 1.943844f // Meters/sec squared to knots
471 
472 #define C_KNOTS_METERS_F 0.514444444f // Knots to meters/sec
473 
475 // Acceleration / Force
476 
477 // Local gravity available as = gravity_igf80(lattitude_rad, altitude_m);
478 #if 1
479 
480 // Standard Gravity (at sea level)
481 #define C_G_TO_MPS2 9.80665 // (m/s^2) standard gravity
482 #define C_MPS2_TO_G 0.101971621297793
483 #define C_G_TO_FTPS2 32.17404856 // (ft/s^2) standard gravity
484 
485 #define C_G_TO_MPS2_F 9.80665f // (m/s^2) standard gravity
486 #define C_MPS2_TO_G_F 0.101971621297793f
487 #define C_G_TO_FTPS2_F 32.17404856f // (ft/s^2) standard gravity
488 #endif
489 
491 // Pressure
492 
493 // Standard Atmospheric Pressure (at sea level)
494  // standard atmospheric pressure
495 #define C_P0N_M2 1.01325e5 // p0 in N/m^2
496 #define C_P0N_M2_F 1.01325e5f // p0 in N/m^2
497 #define C_P0 14.692125 // (C_P0N_M2*1.450e-4)
498 #define C_P0_F 14.692125f // (C_P0N_M2*1.450e-4)
499 
500 #define C_P0_PA_F 101325f // (Pa) Sea level standard atmospheric pressure
501 #define C_P0_KPA_F 101.325f // (kPa) Sea level standard atmospheric pressure
502 #define C_P0_MBAR_F 1013.25f // (mbar) Sea level standard atmospheric pressure
503 
504 #define C_INV_P0_KPA_F 9.8692326671601283e-3f // (1/kPa) Inverse of Sea level standard atmospheric pressure
505 
506 #define C_MBAR_TO_KPA_F 0.1f // (kpa/mbar) absolute pressure
507 #define C_KPA_TO_MBAR_F 10.0f // (mbar/kpa) absolute pressure
508 #define C_MBAR_TO_PA_F 100.0f // (kpa/mbar) absolute pressure
509 
511 // Temperature
512 
513 #define C_T0_F 288.15f // (K) Sea level standard temperature
514 
516 // Mass
517 
518 #define C_LBM2KG 0.45359237 // lb mass
519 #define C_KG2LBM 2.204622622 // (1.0/C_LBM2KG)
520 #define C_LBF2N 4.448221615 // (C_LBM2KG*C_G0MPERSEC2) lb force
521 #define C_SLUG2KG 14.59390294 // (C_LBM2KG*C_G0) slugs
522 
523 #define C_LBM2KG_F 0.45359237f // lb mass
524 #define C_KG2LBM_F 2.204622622f // (1.0/C_LBM2KG)
525 #define C_LBF2N_F 4.448221615f // (C_LBM2KG*C_G0MPERSEC2) lb force
526 #define C_SLUG2KG_F 14.59390294f // (C_LBM2KG*C_G0) slugs
527 
528 // Math constants
529 // from CRC Standard Mathematical Tables, 27th edition, 1984
530 
531 #define C_ROOT2 1.41421356237309504880168872420969807856967187537695
532 #define C_ROOT3 1.73205080756887729352744634150587236694280525381039
533 #define C_E 2.71828182845904523536028747135266249775724709369996
534 #define C_DIVROOT2 0.70710678118654752440084436210485
535 
536 #define C_ROOT2_F 1.41421356237309504880168872420969807856967187537695f
537 #define C_ROOT3_F 1.73205080756887729352744634150587236694280525381039f
538 #define C_E_F 2.71828182845904523536028747135266249775724709369996f
539 #define C_DIVROOT_F 0.70710678118654752440084436210485f
540 
541 #define C_PIDIV16 0.19634954084936207740391521145497 // 11.25 deg
542 #define C_PIDIV8 0.39269908169872415480783042290994 // 22.5 deg
543 #define C_PIDIV4 0.78539816339744830961566084581988
544 #define C_PIDIV2 1.5707963267948966192313216916398
545 #define C_PI 3.14159265358979323846264338327950288419716939937511
546 #define C_TWOPI 6.283185307179586476925286766559
547 #define C_DIVTWOPI 0.15915494309189533576888376337251
548 #define C_DIVPI 0.31830988618379067153776752674503
549 
550 #define C_PIDIV16_F 0.19634954084936207740391521145497f // 11.25 deg
551 #define C_PIDIV8_F 0.39269908169872415480783042290994f // 22.5 deg
552 #define C_PIDIV4_F 0.78539816339744830961566084581988f // 45 deg
553 #define C_PIDIV2_F 1.5707963267948966192313216916398f // 90 deg
554 #define C_PI_F 3.14159265358979323846264338327950288419716939937511f // 180 deg
555 #define C_TWOPI_F 6.283185307179586476925286766559f // 360 deg
556 #define C_DIVTWOPI_F 0.15915494309189533576888376337251f
557 #define C_DIVPI_F 0.31830988618379067153776752674503f
558 
559 #define C_DEG2RAD 0.017453292519943295769236907684886
560 #define C_DEG2RAD_F 0.017453292519943295769236907684886f
561 #define C_RAD2DEG 57.295779513082320876798154814105
562 #define C_RAD2DEG_F 57.295779513082320876798154814105f
563 
564 #define C_MM2M 0.001
565 #define C_MM2M_F 0.001f
566 #define C_M2MM 1000.0
567 #define C_M2MM_F 1000.0f
568 
569 #define C_CM2M 0.01
570 #define C_CM2M_F 0.01f
571 
572 #define C_IN2M 0.0254
573 #define C_IN2M_F 0.0254f
574 #define C_M2IN 39.37007874
575 #define C_M2IN_F 39.37007874f
576 
577 #define C_IN2MM 25.4
578 #define C_IN2MM_F 25.4f
579 #define C_MM2IN 0.03937007874
580 #define C_MM2IN_F 0.03937007874f
581 
582 #define C_FPS2KT 0.5924838
583 #define C_FPS2KT_F 0.5924838f
584 #define C_KT2FPS 1.68780986
585 #define C_KT2FPS_F 1.68780986f
586 
587 #define C_SQIN2SQFT 0.00694444444444444444444
588 #define C_SQIN2SQFT_F 0.00694444444444444444444f
589 #define C_SQFT2SQIN 144.0
590 #define C_SQFT2SQIN_F 144.0f
591 
592 #define C_GPM2CFS 0.0022280093
593 #define C_GPM2CFS_F 0.0022280093f
594 #define C_CFS2GPM 448.83117
595 #define C_CFS2GPM_F 448.83117f
596 
597 #define C_DEGF0_R 459.69
598 #define C_DEGC0_T 273.16
599 #define C_DEGC0_DEGF 32.0
600 #define C_DEGF_PER_DEGC 1.8
601 
602 #define C_LN_2 0.69314718055994530941723212145818
603 #define C_LN_2_F 0.69314718055994530941723212145818f
604 
605 #define C_C2K 273.16
606 #define C_C2K_F 273.16f
607 #define C_F2R 459.69
608 #define C_F2R_F 459.69f
609 
610 #define C_G_CONST 1.068944098e-09 // 6.6732e-11*CUBE(C_M2FT)/C_KG2LBM
611 #define C_EARTH_MASS 1.317041554e25 // 5.974e24*C_KG2LBM
612 #define C_N0_AVOGADRO 6.02205e23
613 #define C_R_IDEAL_SU 8.31434
614 #define C_K_BOLTZMANN 1.380622e-23
615 #define C_C_LIGHT 983571194.2 // 2.9979250e+8*C_M2FT
616 #define C_ECHARGE 1.6021917e-19
617 
618 #define C_DOFA 0.080719353 // 1.293*C_KG2LBM/CUBE(C_M2FT)
619 #define C_DOFH2O 62.427960576 // 1.000e3*C_KG2LBM/CUBE(C_M2FT)
620 #define C_STOFH2O 75.6
621 #define C_VOFH2O 1.787e-3
622 #define C_SOUND0VEL 1087.598425 // 331.5*C_M2FT
623 #define C_SOUND20VEL 1126.64042 // 343.4*C_M2FT
624 
625 #define C_G_CONST_F 1.068944098e-09f // 6.6732e-11*CUBE(C_M2FT)/C_KG2LBM
626 #define C_EARTH_MASS_F 1.317041554e25f // 5.974e24*C_KG2LBM
627 #define C_N0_AVOGADRO_F 6.02205e23f
628 #define C_R_IDEAL_SU_F 8.31434f
629 #define C_K_BOLTZMANN_F 1.380622e-23f
630 #define C_C_LIGHT_F 983571194.2f // 2.9979250e+8*C_M2FT
631 #define C_ECHARGE_F 1.6021917e-19f
632 
633 #define C_DOFA_F 0.080719353f // 1.293*C_KG2LBM/CUBE(C_M2FT)
634 #define C_DOFH2O_F 62.427960576f // 1.000e3*C_KG2LBM/CUBE(C_M2FT)
635 #define C_STOFH2O_F 75.6f
636 #define C_VOFH2O_F 1.787e-3f
637 #define C_SOUND0VEL_F 1087.598425f // 331.5*C_M2FT
638 #define C_SOUND20VEL_F 1126.64042f // 343.4*C_M2FT
639 
640 #define C_WGS84_a 6378137.0 // WGS-84 semimajor axis (m)
641 #define C_WGS84_a_F 6378137.0f
642 #define C_WGS84_b 6356752.3142 // WGS-84 semiminor axis (m)
643 #define C_WGS84_b_F 6356752.3142f
644 #define C_WIE 7.2321151467e-05 // WGS-84 earth rotation rate (rad/s)
645 #define C_WIE_F 7.2321151467e-05f
646 
647 #define C_TESLA2GAUSS_F 10000.0
648 #define C_UTESLA2GAUSS_F 0.01
649 
650 #define C_0p1_DEG2RAD_F 0.00174532925199433f // = 0.1f * C_0pDEG2RAD_F
651 #define C_0p11_DEG2RAD_F 0.00191986217719376f
652 #define C_0p12_DEG2RAD_F 0.00209439510239320f
653 #define C_0p13_DEG2RAD_F 0.00226892802759263f
654 #define C_0p14_DEG2RAD_F 0.00244346095279206f
655 #define C_0p15_DEG2RAD_F 0.00261799387799149f
656 #define C_0p16_DEG2RAD_F 0.00279252680319093f
657 #define C_0p17_DEG2RAD_F 0.00296705972839036f
658 #define C_0p18_DEG2RAD_F 0.00314159265358979f
659 #define C_0p19_DEG2RAD_F 0.00331612557878923f
660 #define C_0p2_DEG2RAD_F 0.00349065850398866f
661 #define C_0p21_DEG2RAD_F 0.00366519142918809f
662 #define C_0p22_DEG2RAD_F 0.00383972435438753f
663 #define C_0p23_DEG2RAD_F 0.00401425727958696f
664 #define C_0p24_DEG2RAD_F 0.00418879020478639f
665 #define C_0p25_DEG2RAD_F 0.00436332312998582f
666 #define C_0p26_DEG2RAD_F 0.00453785605518526f
667 #define C_0p27_DEG2RAD_F 0.00471238898038469f
668 #define C_0p28_DEG2RAD_F 0.00488692190558412f
669 #define C_0p29_DEG2RAD_F 0.00506145483078356f
670 #define C_0p3_DEG2RAD_F 0.00523598775598299f
671 #define C_0p31_DEG2RAD_F 0.00541052068118242f
672 #define C_0p32_DEG2RAD_F 0.00558505360638185f
673 #define C_0p33_DEG2RAD_F 0.00575958653158129f
674 #define C_0p34_DEG2RAD_F 0.00593411945678072f
675 #define C_0p35_DEG2RAD_F 0.00610865238198015f
676 #define C_0p36_DEG2RAD_F 0.00628318530717959f
677 #define C_0p37_DEG2RAD_F 0.00645771823237902f
678 #define C_0p38_DEG2RAD_F 0.00663225115757845f
679 #define C_0p39_DEG2RAD_F 0.00680678408277788f
680 #define C_0p4_DEG2RAD_F 0.00698131700797732f
681 #define C_0p41_DEG2RAD_F 0.00715584993317675f
682 #define C_0p42_DEG2RAD_F 0.00733038285837618f
683 #define C_0p43_DEG2RAD_F 0.00750491578357562f
684 #define C_0p44_DEG2RAD_F 0.00767944870877505f
685 #define C_0p45_DEG2RAD_F 0.00785398163397448f
686 #define C_0p46_DEG2RAD_F 0.00802851455917391f
687 #define C_0p47_DEG2RAD_F 0.00820304748437335f
688 #define C_0p48_DEG2RAD_F 0.00837758040957278f
689 #define C_0p49_DEG2RAD_F 0.00855211333477222f
690 #define C_0p5_DEG2RAD_F 0.00872664625997165f // = 5.0f * C_0pDEG2RAD_F
691 #define C_0p6_DEG2RAD_F 0.01047197551196600f
692 #define C_0p7_DEG2RAD_F 0.01221730476396030f
693 #define C_0p8_DEG2RAD_F 0.01396263401595460f
694 #define C_0p9_DEG2RAD_F 0.01570796326794900f
695 #define C_1p0_DEG2RAD_F 0.0174532925199433f // = 1.0f * C_DEG2RAD_F
696 #define C_1p1_DEG2RAD_F 0.0191986217719376f
697 #define C_1p2_DEG2RAD_F 0.0209439510239320f
698 #define C_1p3_DEG2RAD_F 0.0226892802759263f
699 #define C_1p4_DEG2RAD_F 0.0244346095279206f
700 #define C_1p5_DEG2RAD_F 0.0261799387799149f
701 #define C_1p6_DEG2RAD_F 0.0279252680319093f
702 #define C_1p7_DEG2RAD_F 0.0296705972839036f
703 #define C_1p8_DEG2RAD_F 0.0314159265358979f
704 #define C_1p9_DEG2RAD_F 0.0331612557878923f
705 #define C_2p0_DEG2RAD_F 0.0349065850398866f
706 #define C_2p1_DEG2RAD_F 0.0366519142918809f
707 #define C_2p2_DEG2RAD_F 0.0383972435438753f
708 #define C_2p3_DEG2RAD_F 0.0401425727958696f
709 #define C_2p4_DEG2RAD_F 0.0418879020478639f
710 #define C_2p5_DEG2RAD_F 0.0436332312998582f
711 #define C_2p6_DEG2RAD_F 0.0453785605518526f
712 #define C_2p7_DEG2RAD_F 0.0471238898038469f
713 #define C_2p8_DEG2RAD_F 0.0488692190558412f
714 #define C_2p9_DEG2RAD_F 0.0506145483078356f
715 #define C_3p0_DEG2RAD_F 0.0523598775598299f
716 #define C_3p1_DEG2RAD_F 0.0541052068118242f
717 #define C_3p2_DEG2RAD_F 0.0558505360638185f
718 #define C_3p3_DEG2RAD_F 0.0575958653158129f
719 #define C_3p4_DEG2RAD_F 0.0593411945678072f
720 #define C_3p5_DEG2RAD_F 0.0610865238198015f
721 #define C_3p6_DEG2RAD_F 0.0628318530717959f
722 #define C_3p7_DEG2RAD_F 0.0645771823237902f
723 #define C_3p8_DEG2RAD_F 0.0663225115757845f
724 #define C_3p9_DEG2RAD_F 0.0680678408277788f
725 #define C_4p0_DEG2RAD_F 0.0698131700797732f
726 #define C_4p1_DEG2RAD_F 0.0715584993317675f
727 #define C_4p2_DEG2RAD_F 0.0733038285837618f
728 #define C_4p3_DEG2RAD_F 0.0750491578357562f
729 #define C_4p4_DEG2RAD_F 0.0767944870877505f
730 #define C_4p5_DEG2RAD_F 0.0785398163397448f
731 #define C_4p6_DEG2RAD_F 0.0802851455917391f
732 #define C_4p7_DEG2RAD_F 0.0820304748437335f
733 #define C_4p8_DEG2RAD_F 0.0837758040957278f
734 #define C_4p9_DEG2RAD_F 0.0855211333477222f
735 #define C_5p0_DEG2RAD_F 0.0872664625997165f // = 5.0f * C_DEG2RAD_F
736 #define C_6p0_DEG2RAD_F 0.1047197551196600f
737 #define C_7p0_DEG2RAD_F 0.1221730476396030f
738 #define C_8p0_DEG2RAD_F 0.1396263401595460f
739 #define C_9p0_DEG2RAD_F 0.1570796326794900f
740 #define C_10p0_DEG2RAD_F 0.1745329251994330f
741 #define C_15p0_DEG2RAD_F 0.2617993877991490f
742 #define C_20p0_DEG2RAD_F 0.3490658503988660f // = 20.0f * C_DEG2RAD_F
743 #define C_25p0_DEG2RAD_F 0.4363323129985820f
744 #define C_30p0_DEG2RAD_F 0.5235987755982990f
745 #define C_35p0_DEG2RAD_F 0.6108652381980150f
746 #define C_40p0_DEG2RAD_F 0.6981317007977320f
747 #define C_45p0_DEG2RAD_F 0.7853981633974480f
748 #define C_50p0_DEG2RAD_F 0.8726646259971650f
749 #define C_55p0_DEG2RAD_F 0.9599310885968810f
750 #define C_60p0_DEG2RAD_F 1.0471975511966000f
751 #define C_65p0_DEG2RAD_F 1.1344640137963100f
752 #define C_70p0_DEG2RAD_F 1.2217304763960300f
753 #define C_75p0_DEG2RAD_F 1.3089969389957500f
754 #define C_80p0_DEG2RAD_F 1.3962634015954600f
755 #define C_85p0_DEG2RAD_F 1.4835298641951800f
756 #define C_90p0_DEG2RAD_F 1.5707963267949000f
757 #define C_135p0_DEG2RAD_F 2.3561944901923400f
758 #define C_180p0_DEG2RAD_F 3.1415926535897900f
759 
760 // Angle Unwrap
761 #define UNWRAP_DEG_F64(x) { if((x) < (-180.0 )) { (x) += (360.0 ); } if((x) > (180.0 )) { (x) -= (360.0 ); } } // unwrap to +- 180
762 #define UNWRAP_DEG_F32(x) { if((x) < (-180.0f)) { (x) += (360.0f); } if((x) > (180.0f)) { (x) -= (360.0f); } } // unwrap to +- 180
763 #define UNWRAP_90DEG_F64(x) { if((x) < (-90.0 )) { (x) += (180.0 ); } if((x) > (90.0 )) { (x) -= (180.0 ); } } // unwrap to +- 90
764 #define UNWRAP_90DEG_F32(x) { if((x) < (-90.0f)) { (x) += (180.0f); } if((x) > (90.0f)) { (x) -= (180.0f); } } // unwrap to +- 90
765 #define UNWRAP_F64(x) { if((x) < (-C_PI)) { (x) += (C_TWOPI); } if((x) > (C_PI)) { (x) -= (C_TWOPI); } } // unwrap to +- PI
766 #define UNWRAP_F32(x) { if((x) < (-C_PI_F)) { (x) += (C_TWOPI_F); } if((x) > (C_PI_F)) { (x) -= (C_TWOPI_F); } } // unwrap to +- PI
767 #define UNWRAP_ZERO_TWOPI_F64(x) { if((x) < (0.0)) { (x) += (C_TWOPI); } if((x) > (C_TWOPI)) { (x) -= (C_TWOPI); } } // unwrap to 0 to TWOPI
768 #define UNWRAP_ZERO_TWOPI_F32(x) { if((x) < (0.f)) { (x) += (C_TWOPI_F); } if((x) > (C_TWOPI_F)) { (x) -= (C_TWOPI_F); } } // unwrap to 0 to TWOPI
769 
770 #define _SIN sinf
771 #define _COS cosf
772 #define _TAN tanf
773 #define _ASIN asinf
774 #define _ACOS acosf
775 #define _ATAN2 atan2f
776 #define _SQRT sqrtf
777 #define _FABS fabsf
778 #define _LOG logf
779 
780 #define _DEG2RAD C_DEG2RAD_F
781 #define _RAD2DEG C_RAD2DEG_F
782 #define _ZERO 0.0f
783 
784 #define FLOAT2DOUBLE (double) // Used to prevent warning when compiling with -Wdouble-promotion in Linux
785 
786 typedef float f_t;
787 typedef int i_t;
788 typedef double ixVector2d[2]; // V = | 0 1 |
789 typedef f_t ixVector2[2]; // V = | 0 1 |
790 typedef double ixVector3d[3]; // V = | 0 1 2 |
791 typedef f_t ixVector3[3]; // V = | 0 1 2 |
792 typedef double ixVector4d[4]; // V = | 0 1 2 3 |
793 typedef f_t ixVector4[4]; // V = | 0 1 2 3 |
794 typedef f_t ixVector5[5]; // V = | 0 1 2 3 4 |
795 typedef f_t ixVector6[6]; // V = | 0 1 2 3 4 5 |
796 typedef ixVector4 ixQuat; // w,x,y,z
797 typedef ixVector3 ixEuler; // roll,pitch,yaw
798 typedef f_t ixMatrix2[4];
799 typedef f_t ixMatrix3[9];
800 typedef f_t ixMatrix4[16];
801 typedef f_t ixMatrix5[25];
802 typedef double ixMatrix3d[9];
803 
804 #ifdef __cplusplus
805 } // extern "C"
806 #endif
807 
808 #endif // CONSTANTS_H_
void vPortFree(void *pv) PRIVILEGED_FUNCTION
Definition: heap_4.c:311
f_t ixMatrix5[25]
Definition: ISConstants.h:801
double ixVector2d[2]
Definition: ISConstants.h:788
ixVector4 ixQuat
Definition: ISConstants.h:796
f_t ixVector3[3]
Definition: ISConstants.h:791
float f_t
Definition: ISConstants.h:786
void * pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION
Definition: heap_4.c:155
f_t ixMatrix4[16]
Definition: ISConstants.h:800
int i_t
Definition: ISConstants.h:787
f_t ixVector2[2]
Definition: ISConstants.h:789
f_t ixVector6[6]
Definition: ISConstants.h:795
double ixVector3d[3]
Definition: ISConstants.h:790
f_t ixMatrix2[4]
Definition: ISConstants.h:798
double ixVector4d[4]
Definition: ISConstants.h:792
double ixMatrix3d[9]
Definition: ISConstants.h:802
ixVector3 ixEuler
Definition: ISConstants.h:797
f_t ixMatrix3[9]
Definition: ISConstants.h:799
f_t ixVector5[5]
Definition: ISConstants.h:794
f_t ixVector4[4]
Definition: ISConstants.h:793


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57