Apollo 10.0
自动驾驶开放平台
cyclist_keep_lane_evaluator.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
19namespace apollo {
20namespace prediction {
21
25
27 Obstacle* obstacle_ptr, ObstaclesContainer* obstacles_container) {
28 CHECK_NOTNULL(obstacle_ptr);
29
30 obstacle_ptr->SetEvaluatorType(evaluator_type_);
31
32 int id = obstacle_ptr->id();
33 if (!obstacle_ptr->latest_feature().IsInitialized()) {
34 AERROR << "Obstacle [" << id << "] has no latest feature.";
35 return false;
36 }
37
38 Feature* latest_feature_ptr = obstacle_ptr->mutable_latest_feature();
39 CHECK_NOTNULL(latest_feature_ptr);
40 if (!latest_feature_ptr->has_lane() ||
41 !latest_feature_ptr->lane().has_lane_graph() ||
42 !latest_feature_ptr->lane().has_lane_feature()) {
43 ADEBUG << "Obstacle [" << id << "] has no lane graph.";
44 return false;
45 }
46
47 LaneGraph* lane_graph_ptr =
48 latest_feature_ptr->mutable_lane()->mutable_lane_graph();
49 CHECK_NOTNULL(lane_graph_ptr);
50 if (lane_graph_ptr->lane_sequence().empty()) {
51 AERROR << "Obstacle [" << id << "] has no lane sequences.";
52 return false;
53 }
54
55 std::string curr_lane_id =
56 latest_feature_ptr->lane().lane_feature().lane_id();
57
58 for (auto& lane_sequence : *lane_graph_ptr->mutable_lane_sequence()) {
59 const double probability = ComputeProbability(curr_lane_id, lane_sequence);
60 lane_sequence.set_probability(probability);
61 }
62 return true;
63}
64
65double CyclistKeepLaneEvaluator::ComputeProbability(
66 const std::string& curr_lane_id, const LaneSequence& lane_sequence) {
67 if (lane_sequence.lane_segment().empty()) {
68 AWARN << "Empty lane sequence.";
69 return 0.0;
70 }
71 std::string lane_seq_first_id = lane_sequence.lane_segment(0).lane_id();
72 if (curr_lane_id == lane_seq_first_id) {
73 return 1.0;
74 }
75 return 0.0;
76}
77
78} // namespace prediction
79} // namespace apollo
bool Evaluate(Obstacle *obstacle_ptr, ObstaclesContainer *obstacles_container) override
Override Evaluate
ObstacleConf::EvaluatorType evaluator_type_
Definition evaluator.h:156
Prediction obstacle.
Definition obstacle.h:52
Feature * mutable_latest_feature()
Get a pointer to the latest feature.
Definition obstacle.cc:88
int id() const
Get the obstacle's ID.
Definition obstacle.cc:60
void SetEvaluatorType(const ObstacleConf::EvaluatorType &evaluator_type)
Definition obstacle.cc:1484
const Feature & latest_feature() const
Get the latest feature.
Definition obstacle.cc:78
Define the cyclist keep lane predictor class
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
#define AWARN
Definition log.h:43
class register implement
Definition arena_queue.h:37
repeated LaneSequence lane_sequence
repeated LaneSegment lane_segment