Apollo  6.0
Open source self driving car software
Classes | Functions
apollo::common::util Namespace Reference

apollo::common::util More...

Classes

struct  DebugStringFormatter
 
class  Factory
 Implements a Factory design pattern with Register and Create methods. More...
 
class  JsonUtil
 
class  LRUCache
 
struct  Node
 
struct  PairHash
 
class  PointFactory
 
class  Timer
 
class  TimerWrapper
 
class  TimeUtil
 

Functions

template<typename T , typename std::enable_if< std::is_base_of< google::protobuf::Message, T >::value, int >::type = 0>
bool DumpMessage (const std::shared_ptr< T > &msg, const std::string &dump_dir="/tmp")
 
size_t MessageFingerprint (const google::protobuf::Message &message)
 
std::string function_signature (const std::string &func_name, const std::string &indicator="")
 
template<typename Points >
double GetPathAngle (const Points &points, const size_t start, const size_t end)
 Calculate the angle between the directions of two points on the path. More...
 
template<typename Points >
std::vector< size_t > DownsampleByAngle (const Points &points, const double angle_threshold)
 Downsample the points on the path according to the angle. More...
 
template<typename Points >
std::vector< size_t > DownsampleByDistance (const Points &points, int downsampleDistance, int steepTurnDownsampleDistance)
 Downsample the points on the path based on distance. More...
 
std::string EncodeBase64 (std::string_view in)
 
template<typename ProtoA , typename ProtoB >
bool IsProtoEqual (const ProtoA &a, const ProtoB &b)
 
template<typename T >
bool WithinBound (T start, T end, T value)
 
PointENU operator+ (const PointENU enu, const math::Vec2d &xy)
 
template<typename T >
void uniform_slice (const T start, const T end, uint32_t num, std::vector< T > *sliced)
 
template<typename U , typename V >
double DistanceXY (const U &u, const V &v)
 
template<typename U , typename V >
bool SamePointXY (const U &u, const V &v)
 
PathPoint 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 IsFloatEqual (T x, T y, int ulp=2)
 

Detailed Description

apollo::common::util

Function Documentation

◆ DistanceXY()

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.

Parameters
uone point that has member function x() and y().
bone point that has member function x() and y().
Returns
sqrt((u.x-v.x)^2 + (u.y-v.y)^2), i.e., the Euclid distance on XY dimension.

◆ DownsampleByAngle()

template<typename Points >
std::vector<size_t> apollo::common::util::DownsampleByAngle ( const Points &  points,
const double  angle_threshold 
)

Downsample the points on the path according to the angle.

Parameters
pointsPoints on the path.
angle_thresholdPoints are sampled when the accumulated direction change exceeds the threshold.
Returns
sampled_indices Indices of all sampled points, or empty when fail.

◆ DownsampleByDistance()

template<typename Points >
std::vector<size_t> apollo::common::util::DownsampleByDistance ( const Points &  points,
int  downsampleDistance,
int  steepTurnDownsampleDistance 
)

Downsample the points on the path based on distance.

Parameters
pointsPoints on the path.
downsampleDistancedownsample rate for a normal path
steepTurnDownsampleDistancedownsample rate for a steep turn path
Returns
sampled_indices Indices of all sampled points, or empty when fail.

◆ DumpMessage()

template<typename T , typename std::enable_if< std::is_base_of< google::protobuf::Message, T >::value, int >::type = 0>
bool apollo::common::util::DumpMessage ( const std::shared_ptr< T > &  msg,
const std::string &  dump_dir = "/tmp" 
)

◆ EncodeBase64()

std::string apollo::common::util::EncodeBase64 ( std::string_view  in)

◆ function_signature()

std::string apollo::common::util::function_signature ( const std::string &  func_name,
const std::string &  indicator = "" 
)

◆ GetPathAngle()

template<typename Points >
double apollo::common::util::GetPathAngle ( const Points &  points,
const size_t  start,
const size_t  end 
)

Calculate the angle between the directions of two points on the path.

Parameters
pointsPoints on the path.
startThe index of the first point on the path.
endThe index of the second point on the path.
Returns
The angle between the directions of the start point and the end point.

◆ GetWeightedAverageOfTwoPathPoints()

PathPoint apollo::common::util::GetWeightedAverageOfTwoPathPoints ( const PathPoint &  p1,
const PathPoint &  p2,
const double  w1,
const double  w2 
)

◆ IsFloatEqual()

template<typename T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type apollo::common::util::IsFloatEqual ( x,
y,
int  ulp = 2 
)

◆ IsProtoEqual()

template<typename ProtoA , typename ProtoB >
bool apollo::common::util::IsProtoEqual ( const ProtoA &  a,
const ProtoB &  b 
)

◆ MessageFingerprint()

size_t apollo::common::util::MessageFingerprint ( const google::protobuf::Message &  message)
inline

◆ operator+()

PointENU apollo::common::util::operator+ ( const PointENU  enu,
const math::Vec2d xy 
)

◆ SamePointXY()

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.

Parameters
uone point that has member function x() and y().
vone point that has member function x() and y().
Returns
sqrt((u.x-v.x)^2 + (u.y-v.y)^2) < epsilon, i.e., the Euclid distance on XY dimension.

◆ uniform_slice()

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. start and end will be the first and last element in sliced.

◆ WithinBound()

template<typename T >
bool apollo::common::util::WithinBound ( start,
end,
value 
)