43 #ifndef ILQGAMES_UTILS_TYPES_H 44 #define ILQGAMES_UTILS_TYPES_H 57 #include <unordered_map> 60 #include <Eigen/Dense> 61 #include <Eigen/Geometry> 62 #include <Eigen/StdVector> 68 using Eigen::MatrixXf;
69 using Eigen::VectorXf;
73 using PlayerIndex =
unsigned short;
74 using Dimension = int;
75 using Point2 = Eigen::Vector2f;
78 using Clock = std::chrono::system_clock;
81 using PointList2 = std::vector<Point2, Eigen::aligned_allocator<Point2>>;
84 using PointList2 = std::vector<Point2>;
89 using PlayerPtrMap = std::unordered_map<PlayerIndex, std::shared_ptr<T>>;
92 using PlayerPtrMultiMap =
93 std::unordered_multimap<PlayerIndex, std::shared_ptr<T>>;
96 using PlayerMap = std::unordered_map<PlayerIndex, T>;
99 using PlayerMultiMap = std::unordered_multimap<PlayerIndex, T>;
101 using PlayerDualMap = std::unordered_map<PlayerIndex, float*>;
103 template <
typename T>
104 using PtrVector = std::vector<std::shared_ptr<T>>;
106 using RefVector = std::vector<Eigen::Ref<VectorXf>>;
113 namespace constants {
116 static constexpr
float kGravity = 9.81;
119 static constexpr
float kSmallNumber = 1e-4;
122 static constexpr
float kInfinity = std::numeric_limits<float>::infinity();
125 static constexpr
float kInvalidValue = std::numeric_limits<float>::quiet_NaN();
128 static constexpr
float kDefaultLambda = 0.0;
129 static constexpr
float kDefaultMu = 10.0;
135 static constexpr Time kTimeStep = 0.1;
138 static constexpr Time kTimeHorizon = 10.0;
141 static constexpr
size_t kNumTimeSteps =
142 static_cast<size_t>((kTimeHorizon + constants::kSmallNumber) / kTimeStep);
147 template <
typename T,
typename... Args>
148 std::unique_ptr<T> make_unique(Args&&... args) {
149 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
152 template <
typename T>
153 inline constexpr T sgn(T x, std::false_type is_signed) {
157 template <
typename T>
158 inline constexpr T sgn(T x, std::true_type is_signed) {
159 return (T(0) < x) - (x < T(0));
162 template <
typename T>
163 inline constexpr T sgn(T x) {
164 return sgn(x, std::is_signed<T>());
167 template <
typename T>
168 inline constexpr T signed_sqrt(T x) {
169 return sgn(x) * std::sqrt(std::abs(x));