Apollo  6.0
Open source self driving car software
obstacles_container.h
Go to the documentation of this file.
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 <memory>
25 #include <string>
26 #include <vector>
27 
33 #include "modules/prediction/proto/prediction_obstacle.pb.h"
35 
36 namespace apollo {
37 namespace prediction {
38 
39 class ObstaclesContainer : public Container {
40  public:
45 
49  explicit ObstaclesContainer(const SubmoduleOutput& submodule_output);
50 
54  virtual ~ObstaclesContainer() = default;
55 
60  void Insert(const ::google::protobuf::Message& message) override;
61 
68  const perception::PerceptionObstacle& perception_obstacle,
69  const double timestamp);
70 
75  void InsertFeatureProto(const Feature& feature);
76 
80  void BuildLaneGraph();
81 
85  void BuildJunctionFeature();
86 
92  Obstacle* GetObstacle(const int id);
93 
97  void Clear();
98 
99  void CleanUp();
100 
101  size_t NumOfObstacles() { return ptr_obstacles_.size(); }
102 
103  const apollo::perception::PerceptionObstacle& GetPerceptionObstacle(
104  const int id);
105 
110  const std::vector<int>& curr_frame_movable_obstacle_ids();
111 
116  const std::vector<int>& curr_frame_unmovable_obstacle_ids();
117 
122  const std::vector<int>& curr_frame_considered_obstacle_ids();
123 
124  /*
125  * @brief Set non-ignore obstacle IDs in the current frame
126  */
128 
133  std::vector<int> curr_frame_obstacle_ids();
134 
135  double timestamp() const;
136 
138  const size_t history_size, const apollo::cyber::Time& frame_start_time);
139 
143  const Scenario& curr_scenario() const;
144 
150 
151  private:
152  Obstacle* GetObstacleWithLRUUpdate(const int obstacle_id);
153 
159  bool IsMovable(const perception::PerceptionObstacle& perception_obstacle);
160 
161  private:
162  double timestamp_ = -1.0;
164  std::vector<int> curr_frame_movable_obstacle_ids_;
165  std::vector<int> curr_frame_unmovable_obstacle_ids_;
166  std::vector<int> curr_frame_considered_obstacle_ids_;
167  Scenario curr_scenario_;
168  std::unique_ptr<ObstacleClusters> clusters_;
169  JunctionAnalyzer junction_analyzer_;
170 };
171 
172 } // namespace prediction
173 } // namespace apollo
void Insert(const ::google::protobuf::Message &message) override
Insert a data message into the container.
Obstacle * GetObstacle(const int id)
Get obstacle pointer.
void InsertPerceptionObstacle(const perception::PerceptionObstacle &perception_obstacle, const double timestamp)
Insert an perception obstacle.
Prediction obstacle.
Definition: obstacle.h:52
void Clear()
Clear obstacle container.
const std::vector< int > & curr_frame_movable_obstacle_ids()
Get movable obstacle IDs in the current frame.
Definition: obstacles_container.h:39
Definition: lru_cache.h:43
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
const Scenario & curr_scenario() const
Get current scenario.
Obstacle.
Definition: container.h:33
void BuildJunctionFeature()
Build junction feature for obstacles.
const std::vector< int > & curr_frame_considered_obstacle_ids()
Get non-ignore obstacle IDs in the current frame.
std::vector< int > curr_frame_obstacle_ids()
Get current frame obstacle IDs in the current frame.
const std::vector< int > & curr_frame_unmovable_obstacle_ids()
Get unmovable obstacle IDs in the current frame.
Definition: submodule_output.h:35
Definition: obstacle_clusters.h:33
Define the data container base class.
JunctionAnalyzer * GetJunctionAnalyzer()
size_t NumOfObstacles()
Definition: obstacles_container.h:101
Definition: junction_analyzer.h:30
const apollo::perception::PerceptionObstacle & GetPerceptionObstacle(const int id)
SubmoduleOutput GetSubmoduleOutput(const size_t history_size, const apollo::cyber::Time &frame_start_time)
virtual ~ObstaclesContainer()=default
Destructor.
Output information of prediction container submodule.
void BuildLaneGraph()
Build lane graph for obstacles.
void InsertFeatureProto(const Feature &feature)
Insert a feature proto message into the container.
Cyber has builtin time type Time.
Definition: time.h:31
ObstacleClusters * GetClustersPtr() const
Get the raw pointer of clusters_.