提交 d616cad1 编写于 作者: K kechxu 提交者: Kecheng Xu

Prediction: move some constants to gflags

上级 a5531edc
......@@ -51,6 +51,8 @@ DEFINE_double(lane_search_radius_in_junction, 15.0,
DEFINE_double(junction_search_radius, 1.0, "Search radius for a junction");
DEFINE_double(pedestrian_nearby_lane_search_radius, 5.0,
"Radius to determine if pedestrian-like obstacle is near lane.");
DEFINE_int32(road_graph_max_search_horizon, 20,
"Maximal search depth for building road graph");
// Scenario
DEFINE_double(junction_distance_threshold, 10.0,
......@@ -251,8 +253,17 @@ DEFINE_double(cost_function_sigma, 5.0,
DEFINE_bool(use_bell_curve_for_cost_function, false,
"Whether to use bell curve for the cost function or not.");
DEFINE_int32(road_graph_max_search_horizon, 20,
"Maximal search depth for building road graph");
// interaction predictor
DEFINE_double(collision_cost_time_resolution, 1.0,
"The time resolution used to compute the collision cost");
DEFINE_double(centripedal_acceleration_cost_weight, 1.0,
"The weight of the cost related to centripedal acceleration");
DEFINE_double(collision_cost_weight, 1.0,
"The weight of the cost related to collision");
DEFINE_double(collision_cost_exp_coefficient, 1.0,
"The coefficient in the collision exponential cost function");
DEFINE_double(likelihood_exp_coefficient, 1.0,
"The coefficient in the likelihood exponential function");
DEFINE_double(lane_distance_threshold, 3.0,
"The threshold for distance to ego/neighbor lane "
......
......@@ -40,6 +40,7 @@ DECLARE_double(lane_search_radius);
DECLARE_double(lane_search_radius_in_junction);
DECLARE_double(junction_search_radius);
DECLARE_double(pedestrian_nearby_lane_search_radius);
DECLARE_int32(road_graph_max_search_horizon);
// Scenario
DECLARE_double(junction_distance_threshold);
......@@ -147,7 +148,12 @@ DECLARE_double(cost_function_alpha);
DECLARE_double(cost_function_sigma);
DECLARE_bool(use_bell_curve_for_cost_function);
DECLARE_int32(road_graph_max_search_horizon);
// interaction predictor
DECLARE_double(collision_cost_time_resolution);
DECLARE_double(centripedal_acceleration_cost_weight);
DECLARE_double(collision_cost_weight);
DECLARE_double(collision_cost_exp_coefficient);
DECLARE_double(likelihood_exp_coefficient);
// scenario feature extraction
DECLARE_double(lane_distance_threshold);
......
......@@ -39,8 +39,7 @@ using apollo::prediction::math_util::EvaluateQuarticPolynomial;
using apollo::prediction::math_util::EvaluateQuinticPolynomial;
InteractionPredictor::InteractionPredictor() {
// TODO(kechxu) move constants to gflags
BuildADCTrajectory(1.0);
BuildADCTrajectory(FLAGS_collision_cost_time_resolution);
}
void InteractionPredictor::Predict(Obstacle* obstacle) {
......@@ -99,6 +98,10 @@ void InteractionPredictor::BuildADCTrajectory(const double time_resolution) {
auto adc_trajectory_container =
ContainerManager::Instance()->GetContainer<ADCTrajectoryContainer>(
AdapterConfig::PLANNING_TRAJECTORY);
if (adc_trajectory_container == nullptr) {
AERROR << "Null adc trajectory container";
return;
}
const auto& adc_trajectory = adc_trajectory_container->adc_trajectory();
double curr_timestamp = 0.0;
for (const TrajectoryPoint& point : adc_trajectory.trajectory_point()) {
......@@ -243,9 +246,8 @@ double InteractionPredictor::ComputeTrajectoryCost(
const Obstacle& obstacle,
const LaneSequence& lane_sequence,
const LatLonPolynomialBundle& lat_lon_polynomial_bundle) {
// TODO(kechxu) adjust and move to gflags
double centri_acc_weight = 1.0;
double collision_weight = 1.0;
double centri_acc_weight = FLAGS_centripedal_acceleration_cost_weight;
double collision_weight = FLAGS_collision_cost_weight;
double total_cost = 0.0;
double centri_acc_cost =
CentripetalAccelerationCost(lane_sequence, lat_lon_polynomial_bundle);
......@@ -267,8 +269,6 @@ double InteractionPredictor::CentripetalAccelerationCost(
double cost_abs_sum = 0.0;
double cost_sqr_sum = 0.0;
// TODO(kechxu) use flags
double time_resolution = 1.0;
double curr_time = 0.0;
while (curr_time < FLAGS_prediction_trajectory_time_length) {
double s = EvaluateQuarticPolynomial(lon_coeffs, curr_time, 0,
......@@ -279,7 +279,7 @@ double InteractionPredictor::CentripetalAccelerationCost(
double centri_acc = v * v * kappa;
cost_abs_sum += std::abs(centri_acc);
cost_sqr_sum += centri_acc * centri_acc;
curr_time += time_resolution;
curr_time += FLAGS_collision_cost_time_resolution;
}
return cost_sqr_sum / (cost_abs_sum + FLAGS_double_precision);
}
......@@ -303,8 +303,8 @@ double InteractionPredictor::CollisionWithEgoVehicleCost(
double adc_x = adc_trajectory_point.path_point().x();
double adc_y = adc_trajectory_point.path_point().y();
double distance = std::hypot(adc_x - pos_x, adc_y - pos_y);
// TODO(kechxu) adjust parameter
double cost = std::exp(-1.0 * distance * distance);
double cost = std::exp(-FLAGS_collision_cost_exp_coefficient *
distance * distance);
cost_abs_sum += std::abs(cost);
cost_sqr_sum += cost * cost;
}
......@@ -317,8 +317,7 @@ bool InteractionPredictor::LowerRightOfWayThanEgo(
}
double InteractionPredictor::ComputeLikelihood(const double cost) {
// TODO(kechxu) adjust alpha
double alpha = 1.0;
double alpha = FLAGS_likelihood_exp_coefficient;
return std::exp(-alpha * cost);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册