Apollo 10.0
自动驾驶开放平台
apollo::dreamview::SimControlUtil类 参考

#include <sim_control_util.h>

apollo::dreamview::SimControlUtil 的协作图:

Public 成员函数

double interpolate_1d (const double &p1, const double &p2, const double &frac1)
 
double interpolated_find (const std::vector< double > &range_table, const std::vector< double > &val_table, double to_find)
 
double normalize (const double value, const double mean, const double std)
 
template<class P >
bool load_binary_file (const std::string &filename, P *pb_out)
 
template<class P >
bool load_text_file (const std::string &filename, P *pb_out)
 
template<class P >
bool load_file_to_proto (const std::string &filename, P *pb_out)
 
bool ends_with (const std::string &original, const std::string &pattern)
 
int delta_function (double value, double threshold)
 
double get_eta (double rise_time, double peak_time)
 
double get_tau_s (double peak_time, double eta)
 

静态 Public 成员函数

static double sigmoid (const double value)
 
static double relu (const double value)
 

详细描述

在文件 sim_control_util.h33 行定义.

成员函数说明

◆ delta_function()

int apollo::dreamview::SimControlUtil::delta_function ( double  value,
double  threshold 
)
inline

在文件 sim_control_util.h87 行定义.

87 {
88 return static_cast<int>(value > threshold);
89 }

◆ ends_with()

bool apollo::dreamview::SimControlUtil::ends_with ( const std::string &  original,
const std::string &  pattern 
)
inline

在文件 sim_control_util.h81 行定义.

81 {
82 return original.length() >= pattern.length() &&
83 original.substr(original.length() - pattern.length()) == pattern;
84 }

◆ get_eta()

double apollo::dreamview::SimControlUtil::get_eta ( double  rise_time,
double  peak_time 
)
inline

在文件 sim_control_util.h92 行定义.

92 {
93 if (peak_time <= 0.0) {
94 AFATAL << "peak_time should be positive";
95 }
96 return cos(M_PI - rise_time / (peak_time / M_PI));
97 }
#define AFATAL
Definition log.h:45
float cos(Angle16 a)
Definition angle.cc:42

◆ get_tau_s()

double apollo::dreamview::SimControlUtil::get_tau_s ( double  peak_time,
double  eta 
)
inline

在文件 sim_control_util.h100 行定义.

100 {
101 if (eta > 1.0) {
102 AFATAL << "not an underdamped system";
103 }
104 return peak_time / sqrt(1 - eta * eta);
105 }

◆ interpolate_1d()

double apollo::dreamview::SimControlUtil::interpolate_1d ( const double &  p1,
const double &  p2,
const double &  frac1 
)

在文件 sim_control_util.cc24 行定义.

25 {
26 return p1 * (1.0 - frac1) + p2 * frac1;
27}

◆ interpolated_find()

double apollo::dreamview::SimControlUtil::interpolated_find ( const std::vector< double > &  range_table,
const std::vector< double > &  val_table,
double  to_find 
)

在文件 sim_control_util.cc29 行定义.

31 {
32 int size = range_table.size();
33 int left = -1;
34 int right = size;
35 int mid = 0;
36
37 // assert range_table[right] >= to_find and range_table[left] < to_find
38 while (left + 1 != right) {
39 mid = ((right - left) >> 1) + left;
40
41 if (range_table[mid] >= to_find) {
42 right = mid;
43 } else {
44 left = mid;
45 }
46 }
47
48 if (left == -1) {
49 return val_table[0];
50 }
51
52 if (left == (size - 1)) {
53 return val_table[range_table.size() - 1];
54 }
55
56 double range = range_table[right] - range_table[left];
57
58 if (fabs(range) < 1e-6) {
59 return 0.0;
60 }
61
62 double fraction = (to_find - range_table[left]) / range;
63
64 return interpolate_1d(val_table[left], val_table[right], fraction);
65}
double interpolate_1d(const double &p1, const double &p2, const double &frac1)

◆ load_binary_file()

template<class P >
bool apollo::dreamview::SimControlUtil::load_binary_file ( const std::string &  filename,
P *  pb_out 
)
inline

在文件 sim_control_util.h46 行定义.

46 {
47 std::fstream input(filename, std::ios::in | std::ios::binary);
48 return pb_out->ParseFromIstream(&input);
49 }

◆ load_file_to_proto()

template<class P >
bool apollo::dreamview::SimControlUtil::load_file_to_proto ( const std::string &  filename,
P *  pb_out 
)
inline

在文件 sim_control_util.h65 行定义.

65 {
66 if (ends_with(filename, ".bin")) {
67 if (!load_binary_file(filename, pb_out) &&
68 !load_text_file(filename, pb_out)) {
69 return false;
70 }
71 } else {
72 if (!load_text_file(filename, pb_out) &&
73 !load_binary_file(filename, pb_out)) {
74 return false;
75 }
76 }
77
78 return true;
79 }
bool load_text_file(const std::string &filename, P *pb_out)
bool ends_with(const std::string &original, const std::string &pattern)
bool load_binary_file(const std::string &filename, P *pb_out)

◆ load_text_file()

template<class P >
bool apollo::dreamview::SimControlUtil::load_text_file ( const std::string &  filename,
P *  pb_out 
)
inline

在文件 sim_control_util.h52 行定义.

52 {
53 std::fstream input(filename, std::ios::in);
54 std::string input_data((std::istreambuf_iterator<char>(input)),
55 std::istreambuf_iterator<char>());
56
57 if (input_data.empty()) {
58 return false;
59 }
60
61 return google::protobuf::TextFormat::ParseFromString(input_data, pb_out);
62 }

◆ normalize()

double apollo::dreamview::SimControlUtil::normalize ( const double  value,
const double  mean,
const double  std 
)

在文件 sim_control_util.cc75 行定义.

76 {
77 double eps = 1e-10;
78 return (value - mean) / (std + eps);
79}
Definition future.h:29

◆ relu()

double apollo::dreamview::SimControlUtil::relu ( const double  value)
static

在文件 sim_control_util.cc71 行定义.

71 {
72 return (value > 0.0) ? value : 0.0;
73}

◆ sigmoid()

double apollo::dreamview::SimControlUtil::sigmoid ( const double  value)
static

在文件 sim_control_util.cc67 行定义.

67 {
68 return 1 / (1 + std::exp(-1.0 * value));
69}

该类的文档由以下文件生成: