29 CHECK_NOTNULL(obstacle_ptr);
33 int id = obstacle_ptr->
id();
35 AERROR <<
"Obstacle [" <<
id <<
"] has no latest feature.";
40 CHECK_NOTNULL(latest_feature_ptr);
41 if (!latest_feature_ptr->has_lane() ||
42 !latest_feature_ptr->
lane().has_lane_graph()) {
43 ADEBUG <<
"Obstacle [" <<
id <<
"] has no lane graph.";
47 double obstacle_length = 0.0;
48 if (latest_feature_ptr->has_length()) {
49 obstacle_length = latest_feature_ptr->
length();
51 double obstacle_width = 0.0;
52 if (latest_feature_ptr->has_width()) {
53 obstacle_width = latest_feature_ptr->
width();
57 latest_feature_ptr->mutable_lane()->mutable_lane_graph();
58 CHECK_NOTNULL(lane_graph_ptr);
60 AERROR <<
"Obstacle [" <<
id <<
"] has no lane sequences.";
64 for (
int i = 0; i < lane_graph_ptr->lane_sequence_size(); ++i) {
65 LaneSequence* lane_sequence_ptr = lane_graph_ptr->mutable_lane_sequence(i);
66 CHECK_NOTNULL(lane_sequence_ptr);
68 ComputeProbability(obstacle_length, obstacle_width, *lane_sequence_ptr);
69 lane_sequence_ptr->set_probability(probability);
74double CostEvaluator::ComputeProbability(
const double obstacle_length,
75 const double obstacle_width,
77 double front_lateral_distance_cost =
78 FrontLateralDistanceCost(obstacle_length, obstacle_width, lane_sequence);
82double CostEvaluator::FrontLateralDistanceCost(
83 const double obstacle_length,
const double obstacle_width,
84 const LaneSequence& lane_sequence) {
85 if (lane_sequence.lane_segment().empty() ||
86 lane_sequence.lane_segment(0).lane_point().empty()) {
87 AWARN <<
"Empty lane sequence.";
90 const LanePoint& lane_point = lane_sequence.lane_segment(0).lane_point(0);
91 double lane_l = -lane_point.relative_l();
92 double distance = std::abs(lane_l - obstacle_length / 2.0 *
93 std::sin(lane_point.angle_diff()));
94 double half_lane_width = lane_point.width() / 2.0;
95 return half_lane_width - distance;
CostEvaluator()
Constructor
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate
ObstacleConf::EvaluatorType evaluator_type_
Feature * mutable_latest_feature()
Get a pointer to the latest feature.
int id() const
Get the obstacle's ID.
void SetEvaluatorType(const ObstacleConf::EvaluatorType &evaluator_type)
const Feature & latest_feature() const
Get the latest feature.
double Sigmoid(const double x)
repeated LaneSequence lane_sequence