IDConfig.hpp 3.1 KB

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