1 ///@file Configuration for Inverse Dynamics Library,
2 /// such as choice of linear algebra library and underlying scalar type
6 // If true, enable jacobian calculations.
7 // This adds a 3xN matrix to every body, + 2 3-Vectors.
8 // so it is not advised for large systems if it is not absolutely necessary.
9 // Also, this is not required for standard inverse dynamics calculations.
10 // Will only work with vector math libraries that support 3xN matrices.
11 #define BT_ID_WITH_JACOBIANS
13 // If we have a custom configuration, compile without using other parts of bullet.
14 #ifdef BT_CUSTOM_INVERSE_DYNAMICS_CONFIG_H
16 #define BT_ID_WO_BULLET
17 #define BT_ID_SQRT(x) std::sqrt(x)
18 #define BT_ID_FABS(x) std::fabs(x)
19 #define BT_ID_COS(x) std::cos(x)
20 #define BT_ID_SIN(x) std::sin(x)
21 #define BT_ID_ATAN2(x, y) std::atan2(x, y)
22 #define BT_ID_POW(x, y) std::pow(x, y)
23 #define BT_ID_SNPRINTF snprintf
25 #define BT_ID_USE_DOUBLE_PRECISION
27 #define BT_ID_SQRT(x) btSqrt(x)
28 #define BT_ID_FABS(x) btFabs(x)
29 #define BT_ID_COS(x) btCos(x)
30 #define BT_ID_SIN(x) btSin(x)
31 #define BT_ID_ATAN2(x, y) btAtan2(x, y)
32 #define BT_ID_POW(x, y) btPow(x, y)
33 #define BT_ID_PI SIMD_PI
35 #define BT_ID_SNPRINTF _snprintf
37 #define BT_ID_SNPRINTF snprintf
41 #include "IDErrorMessages.hpp"
43 #ifdef BT_CUSTOM_INVERSE_DYNAMICS_CONFIG_H
45 #include "IDConfigEigen.hpp"
46 #include "IDConfigBuiltin.hpp"
48 #define INVDYN_INCLUDE_HELPER_2(x) #x
49 #define INVDYN_INCLUDE_HELPER(x) INVDYN_INCLUDE_HELPER_2(x)
50 #include INVDYN_INCLUDE_HELPER(BT_CUSTOM_INVERSE_DYNAMICS_CONFIG_H)
51 #ifndef btInverseDynamics
52 #error "custom inverse dynamics config, but no custom namespace defined"
55 #define BT_ID_MAX(a, b) std::max(a, b)
56 #define BT_ID_MIN(a, b) std::min(a, b)
59 #define btInverseDynamics btInverseDynamicsBullet3
60 // Use default configuration with bullet's types
61 // Use the same scalar type as rest of bullet library
62 #include "LinearMath/btScalar.h"
63 typedef btScalar idScalar;
64 #include "LinearMath/btMinMax.h"
65 #define BT_ID_MAX(a, b) btMax(a, b)
66 #define BT_ID_MIN(a, b) btMin(a, b)
68 #ifdef BT_USE_DOUBLE_PRECISION
69 #define BT_ID_USE_DOUBLE_PRECISION
72 #ifndef BT_USE_INVERSE_DYNAMICS_WITH_BULLET2
74 // use bullet types for arrays and array indices
75 #include "Bullet3Common/b3AlignedObjectArray.h"
76 // this is to make it work with C++2003, otherwise we could do this:
77 // template <typename T>
78 // using idArray = b3AlignedObjectArray<T>;
82 typedef b3AlignedObjectArray<T> type;
84 typedef int idArrayIdx;
85 #define ID_DECLARE_ALIGNED_ALLOCATOR() B3_DECLARE_ALIGNED_ALLOCATOR()
87 #else // BT_USE_INVERSE_DYNAMICS_WITH_BULLET2
89 #include "LinearMath/btAlignedObjectArray.h"
93 typedef btAlignedObjectArray<T> type;
95 typedef int idArrayIdx;
96 #define ID_DECLARE_ALIGNED_ALLOCATOR() BT_DECLARE_ALIGNED_ALLOCATOR()
98 #endif // BT_USE_INVERSE_DYNAMICS_WITH_BULLET2
100 // use bullet's allocator functions
101 #define idMalloc btAllocFunc
102 #define idFree btFreeFunc
104 #define ID_LINEAR_MATH_USE_BULLET
105 #include "details/IDLinearMathInterface.hpp"