提交 356f3727 编写于 作者: K kechxu 提交者: Jiangtao Hu

small coding style fix for private data members in dp_st_cost.cc

上级 5f329995
......@@ -29,11 +29,11 @@ namespace apollo {
namespace planning {
DpStCost::DpStCost(const DpStSpeedConfig& dp_st_speed_config)
: _dp_st_speed_config(dp_st_speed_config) {
_unit_s = _dp_st_speed_config.total_path_length() /
_dp_st_speed_config.matrix_dimension_s();
_unit_t = _dp_st_speed_config.total_time() /
_dp_st_speed_config.matrix_dimension_t();
: dp_st_speed_config_(dp_st_speed_config) {
unit_s_ = dp_st_speed_config_.total_path_length() /
dp_st_speed_config_.matrix_dimension_s();
unit_t_ = dp_st_speed_config_.total_time() /
dp_st_speed_config_.matrix_dimension_t();
}
// TODO(all): normalize cost with time
......@@ -43,11 +43,11 @@ double DpStCost::GetObstacleCost(
double total_cost = 0.0;
for (const StGraphBoundary& boundary : st_graph_boundaries) {
if (point.s() < 0 || boundary.IsPointInBoundary(point)) {
total_cost += _dp_st_speed_config.st_graph_default_point_cost();
total_cost += dp_st_speed_config_.st_graph_default_point_cost();
} else {
double distance = boundary.DistanceTo(point);
total_cost += _dp_st_speed_config.st_graph_default_point_cost() *
std::exp(_dp_st_speed_config.obstacle_cost_factor() /
total_cost += dp_st_speed_config_.st_graph_default_point_cost() *
std::exp(dp_st_speed_config_.obstacle_cost_factor() /
boundary.characteristic_length() * distance);
}
}
......@@ -56,26 +56,26 @@ double DpStCost::GetObstacleCost(
double DpStCost::GetReferenceCost(const STPoint& point,
const STPoint& reference_point) const {
return _dp_st_speed_config.reference_weight() *
return dp_st_speed_config_.reference_weight() *
(point.s() - reference_point.s()) * (point.s() - reference_point.s()) *
_unit_t;
unit_t_;
}
double DpStCost::GetSpeedCost(const STPoint& first, const STPoint& second,
const double speed_limit) const {
double cost = 0.0;
double speed = (second.s() - first.s()) / _unit_t;
double speed = (second.s() - first.s()) / unit_t_;
if (Double::Compare(speed, 0.0) < 0) {
cost = _dp_st_speed_config.st_graph_default_point_cost();
cost = dp_st_speed_config_.st_graph_default_point_cost();
}
double det_speed = (speed - speed_limit) / speed_limit;
if (Double::Compare(det_speed, 0.0) > 0) {
cost = _dp_st_speed_config.exceed_speed_penalty() *
_dp_st_speed_config.default_speed_cost() * fabs(speed * speed) *
_unit_t;
cost = dp_st_speed_config_.exceed_speed_penalty() *
dp_st_speed_config_.default_speed_cost() * fabs(speed * speed) *
unit_t_;
} else if (Double::Compare(det_speed, 0.0) < 0) {
cost = _dp_st_speed_config.low_speed_penalty() *
_dp_st_speed_config.default_speed_cost() * -det_speed * _unit_t;
cost = dp_st_speed_config_.low_speed_penalty() *
dp_st_speed_config_.default_speed_cost() * -det_speed * unit_t_;
} else {
cost = 0.0;
}
......@@ -84,15 +84,15 @@ double DpStCost::GetSpeedCost(const STPoint& first, const STPoint& second,
double DpStCost::GetAccelCost(const double accel) const {
double accel_sq = accel * accel;
double max_acc = _dp_st_speed_config.max_acceleration();
double max_dec = _dp_st_speed_config.max_deceleration();
double accel_penalty = _dp_st_speed_config.accel_penalty();
double decel_penalty = _dp_st_speed_config.decel_penalty();
double max_acc = dp_st_speed_config_.max_acceleration();
double max_dec = dp_st_speed_config_.max_deceleration();
double accel_penalty = dp_st_speed_config_.accel_penalty();
double decel_penalty = dp_st_speed_config_.decel_penalty();
double cost = 0.0;
if (accel > 0.0) {
cost = accel_penalty * accel_sq * _unit_t;
cost = accel_penalty * accel_sq * unit_t_;
} else {
cost = decel_penalty * accel_sq * _unit_t;
cost = decel_penalty * accel_sq * unit_t_;
}
cost += accel_sq * decel_penalty * decel_penalty /
(1 + std::exp(1.0 * (accel - max_dec))) +
......@@ -104,15 +104,15 @@ double DpStCost::GetAccelCost(const double accel) const {
double DpStCost::GetAccelCostByThreePoints(const STPoint& first,
const STPoint& second,
const STPoint& third) const {
double accel = (first.s() + third.s() - 2 * second.s()) / (_unit_t * _unit_t);
double accel = (first.s() + third.s() - 2 * second.s()) / (unit_t_ * unit_t_);
return GetAccelCost(accel);
}
double DpStCost::GetAccelCostByTwoPoints(const double pre_speed,
const STPoint& pre_point,
const STPoint& curr_point) const {
double current_speed = (curr_point.s() - pre_point.s()) / _unit_t;
double accel = (current_speed - pre_speed) / _unit_t;
double current_speed = (curr_point.s() - pre_point.s()) / unit_t_;
double accel = (current_speed - pre_speed) / unit_t_;
return GetAccelCost(accel);
}
......@@ -120,9 +120,9 @@ double DpStCost::JerkCost(const double jerk) const {
double jerk_sq = jerk * jerk;
double cost = 0.0;
if (Double::Compare(jerk, 0.0) > 0) {
cost = _dp_st_speed_config.positive_jerk_coeff() * jerk_sq * _unit_t;
cost = dp_st_speed_config_.positive_jerk_coeff() * jerk_sq * unit_t_;
} else if (Double::Compare(jerk, 0.0) < 0) {
cost = _dp_st_speed_config.negative_jerk_coeff() * jerk_sq * _unit_t;
cost = dp_st_speed_config_.negative_jerk_coeff() * jerk_sq * unit_t_;
} else {
cost = 0.0;
}
......@@ -134,7 +134,7 @@ double DpStCost::GetJerkCostByFourPoints(const STPoint& first,
const STPoint& third,
const STPoint& fourth) const {
double jerk = (fourth.s() - 3 * third.s() + 3 * second.s() - first.s()) /
(_unit_t * _unit_t * _unit_t);
(unit_t_ * unit_t_ * unit_t_);
return JerkCost(jerk);
}
......@@ -142,9 +142,9 @@ double DpStCost::GetJerkCostByTwoPoints(const double pre_speed,
const double pre_acc,
const STPoint& pre_point,
const STPoint& curr_point) const {
double curr_speed = (curr_point.s() - pre_point.s()) / _unit_t;
double curr_accel = (curr_speed - pre_speed) / _unit_t;
double jerk = (curr_accel - pre_acc) / _unit_t;
double curr_speed = (curr_point.s() - pre_point.s()) / unit_t_;
double curr_accel = (curr_speed - pre_speed) / unit_t_;
double jerk = (curr_accel - pre_acc) / unit_t_;
return JerkCost(jerk);
}
......@@ -152,11 +152,11 @@ double DpStCost::GetJerkCostByThreePoints(const double first_speed,
const STPoint& first,
const STPoint& second,
const STPoint& third) const {
double pre_speed = (second.s() - first.s()) / _unit_t;
double pre_acc = (pre_speed - first_speed) / _unit_t;
double curr_speed = (third.s() - second.s()) / _unit_t;
double curr_acc = (curr_speed - pre_speed) / _unit_t;
double jerk = (curr_acc - pre_acc) / _unit_t;
double pre_speed = (second.s() - first.s()) / unit_t_;
double pre_acc = (pre_speed - first_speed) / unit_t_;
double curr_speed = (third.s() - second.s()) / unit_t_;
double curr_acc = (curr_speed - pre_speed) / unit_t_;
double jerk = (curr_acc - pre_acc) / unit_t_;
return JerkCost(jerk);
}
......
......@@ -67,9 +67,9 @@ class DpStCost {
double GetAccelCost(const double accel) const;
double JerkCost(const double jerk) const;
const DpStSpeedConfig& _dp_st_speed_config;
double _unit_s = 0.0;
double _unit_t = 0.0;
const DpStSpeedConfig& dp_st_speed_config_;
double unit_s_ = 0.0;
double unit_t_ = 0.0;
};
} // namespace planning
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册