Apollo 10.0
自动驾驶开放平台
util.h 文件参考

Some util functions. 更多...

#include <algorithm>
#include <iostream>
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "cyber/common/log.h"
#include "cyber/common/types.h"
#include "modules/common/configs/config_gflags.h"
#include "modules/common/math/vec2d.h"
#include "modules/common_msgs/basic_msgs/geometry.pb.h"
#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
util.h 的引用(Include)关系图:

浏览源代码.

struct  apollo::common::util::PairHash
 
class  FunctionInfo< T >
 

命名空间

namespace  apollo::common::util
 apollo::common::util
 
namespace  apollo
 class register implement
 
namespace  apollo::common
 apollo::common
 

宏定义

#define EXEC_ALL_FUNS(type, obj, list)    ExcuteAllFunctions<type, sizeof(list) / sizeof(FunctionInfo<type>)>(obj, list)
 
#define UNIQUE_LOCK_MULTITHREAD(mutex_type)
 

函数

template<typename ProtoA , typename ProtoB >
bool apollo::common::util::IsProtoEqual (const ProtoA &a, const ProtoB &b)
 
template<typename T >
bool apollo::common::util::WithinBound (T start, T end, T value)
 
PointENU apollo::common::util::operator+ (const PointENU enu, const math::Vec2d &xy)
 
template<typename T >
void apollo::common::util::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 points that slices the provided segment.
 
template<typename U , typename V >
double apollo::common::util::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() in XY dimension.
 
template<typename U , typename V >
bool apollo::common::util::SamePointXY (const U &u, const V &v)
 Check if two points u and v are the same point on XY dimension.
 
PathPoint apollo::common::util::GetWeightedAverageOfTwoPathPoints (const PathPoint &p1, const PathPoint &p2, const double w1, const double w2)
 
template<typename T >
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type apollo::common::util::IsFloatEqual (T x, T y, int ulp=2)
 
template<typename T , size_t count>
bool ExcuteAllFunctions (T *obj, FunctionInfo< T > fun_list[])
 
template<typename A , typename B >
std::ostream & operator<< (std::ostream &os, std::pair< A, B > &p)
 

详细描述

Some util functions.

在文件 util.h 中定义.

宏定义说明

◆ EXEC_ALL_FUNS

#define EXEC_ALL_FUNS (   type,
  obj,
  list 
)     ExcuteAllFunctions<type, sizeof(list) / sizeof(FunctionInfo<type>)>(obj, list)

在文件 util.h154 行定义.

157 {
158 return os << "first: " << p.first << ", second: " << p.second;
159}
160
161#define UNIQUE_LOCK_MULTITHREAD(mutex_type) \
162 std::unique_ptr<std::unique_lock<std::mutex>> lock_ptr = nullptr; \
163 if (FLAGS_multithread_run) { \
164 lock_ptr.reset(new std::unique_lock<std::mutex>(mutex_type)); \
165 }

◆ UNIQUE_LOCK_MULTITHREAD

#define UNIQUE_LOCK_MULTITHREAD (   mutex_type)
值:
std::unique_ptr<std::unique_lock<std::mutex>> lock_ptr = nullptr; \
if (FLAGS_multithread_run) { \
lock_ptr.reset(new std::unique_lock<std::mutex>(mutex_type)); \
}

在文件 util.h162 行定义.

164 { \
165 lock_ptr.reset(new std::unique_lock<std::mutex>(mutex_type)); \
166 }

函数说明

◆ ExcuteAllFunctions()

template<typename T , size_t count>
bool ExcuteAllFunctions ( T *  obj,
FunctionInfo< T >  fun_list[] 
)

在文件 util.h144 行定义.

144 {
145 for (size_t i = 0; i < count; i++) {
146 if ((obj->*(fun_list[i].function_))() != apollo::cyber::SUCC) {
147 AERROR << fun_list[i].fun_name_ << " failed.";
148 return false;
149 }
150 }
151 return true;
152}
std::string fun_name_
Definition util.h:140
#define AERROR
Definition log.h:44

◆ operator<<()

template<typename A , typename B >
std::ostream & operator<< ( std::ostream &  os,
std::pair< A, B > &  p 
)

在文件 util.h158 行定义.

158 {
159 return os << "first: " << p.first << ", second: " << p.second;
160}