Apollo 10.0
自动驾驶开放平台
obstacle.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
22#pragma once
23
24#include <deque>
25#include <list>
26#include <memory>
27#include <string>
28#include <unordered_set>
29#include <vector>
30
37#include "modules/common_msgs/prediction_msgs/feature.pb.h"
38#include "modules/prediction/proto/prediction_conf.pb.h"
39#include "modules/common_msgs/prediction_msgs/prediction_obstacle.pb.h"
40
45namespace apollo {
46namespace prediction {
47
52class Obstacle {
53 public:
57 static std::unique_ptr<Obstacle> Create(
58 const perception::PerceptionObstacle& perception_obstacle,
59 const double timestamp, const int prediction_id,
60 ObstacleClusters* clusters_ptr);
61
62 static std::unique_ptr<Obstacle> Create(const Feature& feature,
63 ObstacleClusters* clusters_ptr);
64
65 Obstacle() = default;
66
70 virtual ~Obstacle() = default;
71
72 void SetJunctionAnalyzer(JunctionAnalyzer* junction_analyzer) {
73 junction_analyzer_ = junction_analyzer;
74 }
75
81 bool Insert(const perception::PerceptionObstacle& perception_obstacle,
82 const double timestamp, const int prediction_id);
83
88 bool InsertFeature(const Feature& feature);
89
91
92 void TrimHistory(const size_t remain_size);
93
99
100 bool IsPedestrian() const;
101
106 int id() const;
107
112 double timestamp() const;
113
114 bool ReceivedOlderMessage(const double timestamp) const;
115
121 const Feature& feature(const size_t i) const;
122
128 Feature* mutable_feature(const size_t i);
129
134 const Feature& latest_feature() const;
135
140 const Feature& earliest_feature() const;
141
147
151 void SetNearbyObstacles();
152
157 size_t history_size() const;
158
163 bool IsStill();
164
169 bool IsSlow();
170
175 bool IsOnLane() const;
176
181 bool ToIgnore();
182
187 bool IsNearJunction();
188
194 bool IsInJunction(const std::string& junction_id) const;
195
200 bool IsCloseToJunctionExit() const;
201
206 bool HasJunctionFeatureWithExits() const;
207
212
216 void BuildLaneGraph();
217
223
227 void SetCaution();
228
229 bool IsCaution() const;
230
234 void SetInteractiveTag();
239
240 bool IsInteractiveObstacle() const;
241
242 void SetEvaluatorType(const ObstacleConf::EvaluatorType& evaluator_type);
243
244 void SetPredictorType(const ObstacleConf::PredictorType& predictor_type);
245
246 const ObstacleConf& obstacle_conf() { return obstacle_conf_; }
247
249
250 private:
251 void SetStatus(const perception::PerceptionObstacle& perception_obstacle,
252 double timestamp, Feature* feature);
253
254 bool SetId(const perception::PerceptionObstacle& perception_obstacle,
255 Feature* feature, const int prediction_id = -1);
256
257 void SetType(const perception::PerceptionObstacle& perception_obstacle,
259
260 void SetIsNearJunction(
261 const perception::PerceptionObstacle& perception_obstacle,
263
264 void SetTimestamp(const perception::PerceptionObstacle& perception_obstacle,
265 const double timestamp, Feature* feature);
266
267 void SetPolygonPoints(
268 const perception::PerceptionObstacle& perception_obstacle,
270
271 void SetPosition(const perception::PerceptionObstacle& perception_obstacle,
273
274 void SetVelocity(const perception::PerceptionObstacle& perception_obstacle,
276
277 void AdjustHeadingByLane(Feature* feature);
278
279 void UpdateVelocity(const double theta, double* velocity_x,
280 double* velocity_y, double* velocity_heading,
281 double* speed);
282
283 void SetAcceleration(Feature* feature);
284
285 void SetTheta(const perception::PerceptionObstacle& perception_obstacle,
287
288 void SetLengthWidthHeight(
289 const perception::PerceptionObstacle& perception_obstacle,
291
292 void UpdateLaneBelief(Feature* feature);
293
294 void SetCurrentLanes(Feature* feature);
295
296 void SetNearbyLanes(Feature* feature);
297
298 void SetSurroundingLaneIds(Feature* feature, const double radius);
299
300 void SetLaneSequenceStopSign(LaneSequence* lane_sequence_ptr);
301
305 void SetLanePoints(Feature* feature);
306 void SetLanePoints(const Feature* feature, const double lane_point_spacing,
307 const uint64_t max_num_lane_point,
308 const bool is_bidirection, LaneGraph* const lane_graph);
309
312 void SetLaneSequencePath(LaneGraph* const lane_graph);
313
314 void SetMotionStatus();
315
316 void SetMotionStatusBySpeed();
317
318 void InsertFeatureToHistory(const Feature& feature);
319
320 void SetJunctionFeatureWithEnterLane(const std::string& enter_lane_id,
321 Feature* const feature_ptr);
322
323 void SetJunctionFeatureWithoutEnterLane(Feature* const feature_ptr);
324
325 void DiscardOutdatedHistory();
326
327 void GetNeighborLaneSegments(
328 std::shared_ptr<const apollo::hdmap::LaneInfo> center_lane_info,
329 bool is_left, int recursion_depth,
330 std::list<std::string>* const lane_ids_ordered,
331 std::unordered_set<std::string>* const existing_lane_ids);
332
333 bool HasJunctionExitLane(
334 const LaneSequence& lane_sequence,
335 const std::unordered_set<std::string>& exit_lane_id_set);
336
337 void SetClusters(ObstacleClusters* clusters_ptr);
338
339 private:
340 int id_ = FLAGS_ego_vehicle_id;
341
344
345 std::deque<Feature> feature_history_;
346
347 std::vector<std::shared_ptr<const hdmap::LaneInfo>> current_lanes_;
348
349 ObstacleConf obstacle_conf_;
350
351 ObstacleClusters* clusters_ptr_ = nullptr;
352 JunctionAnalyzer* junction_analyzer_ = nullptr;
353};
354
355} // namespace prediction
356} // namespace apollo
Prediction obstacle.
Definition obstacle.h:52
bool IsInJunction(const std::string &junction_id) const
Check if the obstacle is a junction.
Definition obstacle.cc:223
double timestamp() const
Get the obstacle's timestamp.
Definition obstacle.cc:62
bool HasJunctionFeatureWithExits() const
Check if the obstacle has junction feature.
Definition obstacle.cc:622
bool ReceivedOlderMessage(const double timestamp) const
Definition obstacle.cc:1425
bool IsNearJunction()
Check if the obstacle is near a junction.
Definition obstacle.cc:130
void SetNearbyObstacles()
Set nearby obstacles.
Definition obstacle.cc:1279
Feature * mutable_feature(const size_t i)
Get a pointer to the ith feature from latest to earliest.
Definition obstacle.cc:72
Feature * mutable_latest_feature()
Get a pointer to the latest feature.
Definition obstacle.cc:88
void BuildLaneGraphFromLeftToRight()
Build obstacle's lane graph with lanes being ordered.
Definition obstacle.cc:981
void BuildLaneGraph()
Build obstacle's lane graph
Definition obstacle.cc:804
perception::PerceptionObstacle::Type type() const
Get the type of perception obstacle's type.
Definition obstacle.cc:54
bool IsCloseToJunctionExit() const
Check if the obstacle is close to a junction exit.
Definition obstacle.cc:274
void TrimHistory(const size_t remain_size)
Definition obstacle.cc:217
bool IsStill()
Check if the obstacle is still.
Definition obstacle.cc:95
bool InsertFeature(const Feature &feature)
Insert a feature proto message.
Definition obstacle.cc:198
void SetNonInteractiveTag()
Set the obstacle as noninteractive obstacle.
Definition obstacle.cc:1468
void SetInteractiveTag()
Set the obstacle as interactive obstacle.
Definition obstacle.cc:1461
int id() const
Get the obstacle's ID.
Definition obstacle.cc:60
bool ToIgnore()
Check if the obstacle can be ignored.
Definition obstacle.cc:123
size_t history_size() const
Get the number of historical features.
Definition obstacle.cc:93
virtual ~Obstacle()=default
Destructor
const Feature & feature(const size_t i) const
Get the ith feature from latest to earliest.
Definition obstacle.cc:67
bool IsInteractiveObstacle() const
Definition obstacle.cc:1475
PredictionObstacle GeneratePredictionObstacle()
Definition obstacle.cc:1494
bool Insert(const perception::PerceptionObstacle &perception_obstacle, const double timestamp, const int prediction_id)
Insert a perception obstacle with its timestamp.
Definition obstacle.cc:140
void BuildJunctionFeature()
Build junction feature.
Definition obstacle.cc:242
void SetJunctionAnalyzer(JunctionAnalyzer *junction_analyzer)
Definition obstacle.h:72
void SetEvaluatorType(const ObstacleConf::EvaluatorType &evaluator_type)
Definition obstacle.cc:1484
bool IsOnLane() const
Check if the obstacle is on any lane.
Definition obstacle.cc:107
void SetPredictorType(const ObstacleConf::PredictorType &predictor_type)
Definition obstacle.cc:1489
const Feature & earliest_feature() const
Get the earliest feature.
Definition obstacle.cc:83
bool IsSlow()
Check if the obstacle is slow.
Definition obstacle.cc:102
void SetCaution()
Set the obstacle as caution level
Definition obstacle.cc:1447
static std::unique_ptr< Obstacle > Create(const perception::PerceptionObstacle &perception_obstacle, const double timestamp, const int prediction_id, ObstacleClusters *clusters_ptr)
Constructor
Definition obstacle.cc:1406
const Feature & latest_feature() const
Get the latest feature.
Definition obstacle.cc:78
const ObstacleConf & obstacle_conf()
Definition obstacle.h:246
Defines the templated KalmanFilter class.
Defines the DigitalFilter class.
class register implement
Definition arena_queue.h:37