36 #include "modules/common/proto/geometry.pb.h" 37 #include "modules/common/proto/pnc_point.pb.h" 46 template <
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;
96 template <
typename U,
typename V>
98 return std::hypot(u.x() - v.x(), u.y() - v.y());
108 template <
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);
121 template <
typename T>
122 typename 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();
135 template <
typename T>
138 typedef int (T::*Function)();
143 template <
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) 157 template <
typename A,
typename B>
158 std::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)); \
bool SamePointXY(const U &u, const V &v)
Definition: util.h:109
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
size_t operator()(const std::pair< T, U > &pair) const
Definition: util.h:56
bool ExcuteAllFunctions(T *obj, FunctionInfo< T > fun_list[])
Definition: util.h:144
void uniform_slice(const T start, const T end, uint32_t num, std::vector< T > *sliced)
Definition: util.h:74
std::string fun_name_
Definition: util.h:140
double DistanceXY(const U &u, const V &v)
Definition: util.h:97
Implements a class of 2-dimensional vectors.
Definition: vec2d.h:42
bool IsProtoEqual(const ProtoA &a, const ProtoB &b)
Definition: util.h:47
bool WithinBound(T start, T end, T value)
Definition: util.h:62
PointENU operator+(const PointENU enu, const math::Vec2d &xy)
apollo::cyber::base::std value
#define AERROR
Definition: log.h:44
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type IsFloatEqual(T x, T y, int ulp=2)
Definition: util.h:123
PathPoint GetWeightedAverageOfTwoPathPoints(const PathPoint &p1, const PathPoint &p2, const double w1, const double w2)
Function function_
Definition: util.h:139