36#include "modules/common_msgs/basic_msgs/geometry.pb.h"
37#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
46template <
typename ProtoA,
typename ProtoB>
48 return a.GetTypeName() == b.GetTypeName() &&
49 a.SerializeAsString() == b.SerializeAsString();
55 template <
typename T,
typename U>
57 return std::hash<T>()(pair.first) ^ std::hash<U>()(pair.second);
63 return value >= start && value <= end;
75 std::vector<T>* sliced) {
76 if (!sliced || num == 0) {
79 const T delta = (end - start) / num;
80 sliced->resize(num + 1);
82 for (uint32_t i = 0; i < num; ++i, s += delta) {
85 sliced->at(num) = end;
96template <
typename U,
typename V>
98 return std::hypot(u.x() - v.x(), u.y() - v.y());
108template <
typename U,
typename V>
110 static constexpr double kMathEpsilonSqr = 1e-8 * 1e-8;
111 return (u.x() - v.x()) * (u.x() - v.x()) < kMathEpsilonSqr &&
112 (u.y() - v.y()) * (u.y() - v.y()) < kMathEpsilonSqr;
117 const double w1,
const double w2);
122typename std::enable_if<!std::numeric_limits<T>::is_integer,
bool>::type
126 return std::fabs(x - y) <
127 std::numeric_limits<T>::epsilon() * std::fabs(x + y) * ulp
129 || std::fabs(x - y) < std::numeric_limits<T>::min();
143template <
typename T,
size_t count>
145 for (
size_t i = 0; i < count; i++) {
154#define EXEC_ALL_FUNS(type, obj, list) \
155 ExcuteAllFunctions<type, sizeof(list) / sizeof(FunctionInfo<type>)>(obj, list)
157template <
typename A,
typename B>
158std::ostream&
operator<<(std::ostream& os, std::pair<A, B>& p) {
159 return os <<
"first: " << p.first <<
", second: " << p.second;
162#define UNIQUE_LOCK_MULTITHREAD(mutex_type) \
163 std::unique_ptr<std::unique_lock<std::mutex>> lock_ptr = nullptr; \
164 if (FLAGS_multithread_run) { \
165 lock_ptr.reset(new std::unique_lock<std::mutex>(mutex_type)); \
Implements a class of 2-dimensional vectors.
std::ostream & operator<<(std::ostream &os, std::pair< A, B > &p)
bool ExcuteAllFunctions(T *obj, FunctionInfo< T > fun_list[])
bool IsProtoEqual(const ProtoA &a, const ProtoB &b)
bool WithinBound(T start, T end, T value)
bool SamePointXY(const U &u, const V &v)
Check if two points u and v are the same point on XY dimension.
double DistanceXY(const U &u, const V &v)
calculate the distance beteween Point u and Point v, which are all have member function x() and y() i...
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type IsFloatEqual(T x, T y, int ulp=2)
void uniform_slice(const T start, const T end, uint32_t num, std::vector< T > *sliced)
uniformly slice a segment [start, end] to num + 1 pieces the result sliced will contain the n + 1 poi...
PathPoint GetWeightedAverageOfTwoPathPoints(const PathPoint &p1, const PathPoint &p2, const double w1, const double w2)
size_t operator()(const std::pair< T, U > &pair) const