Apollo 10.0
自动驾驶开放平台
apollo::prediction::JunctionAnalyzer类 参考

#include <junction_analyzer.h>

apollo::prediction::JunctionAnalyzer 的协作图:

Public 成员函数

void Init (const std::string &junction_id)
 Initialize by junction ID, if junction id differs from prev cycle
 
void Clear ()
 Clear all stored data
 
const std::string & GetJunctionId ()
 Get junction ID
 
double ComputeJunctionRange ()
 Compute junction range
 
const JunctionFeatureGetJunctionFeature (const std::string &start_lane_id)
 Get junction feature starting from start_lane_id
 
JunctionFeature GetJunctionFeature (const std::vector< std::string > &start_lane_ids)
 Get junction feature starting from start_lane_ids
 

详细描述

在文件 junction_analyzer.h30 行定义.

成员函数说明

◆ Clear()

void apollo::prediction::JunctionAnalyzer::Clear ( )

Clear all stored data

在文件 junction_analyzer.cc44 行定义.

44 {
45 // Clear all data
46 junction_info_ptr_ = nullptr;
47 junction_exits_.clear();
48 junction_features_.clear();
49}

◆ ComputeJunctionRange()

double apollo::prediction::JunctionAnalyzer::ComputeJunctionRange ( )

Compute junction range

返回
Junction range

在文件 junction_analyzer.cc175 行定义.

175 {
176 CHECK_NOTNULL(junction_info_ptr_);
177 if (!junction_info_ptr_->junction().has_polygon() ||
178 junction_info_ptr_->junction().polygon().point_size() < 3) {
179 AERROR << "Junction [" << GetJunctionId()
180 << "] has not enough polygon points to compute range";
181 return FLAGS_defualt_junction_range;
182 }
183 double x_min = std::numeric_limits<double>::infinity();
184 double x_max = -std::numeric_limits<double>::infinity();
185 double y_min = std::numeric_limits<double>::infinity();
186 double y_max = -std::numeric_limits<double>::infinity();
187 for (const auto& point : junction_info_ptr_->junction().polygon().point()) {
188 x_min = std::min(x_min, point.x());
189 x_max = std::max(x_max, point.x());
190 y_min = std::min(y_min, point.y());
191 y_max = std::max(y_max, point.y());
192 }
193 double dx = std::abs(x_max - x_min);
194 double dy = std::abs(y_max - y_min);
195 double range = std::sqrt(dx * dx + dy * dy);
196 return range;
197}
const std::string & GetJunctionId()
Get junction ID
#define AERROR
Definition log.h:44

◆ GetJunctionFeature() [1/2]

const JunctionFeature & apollo::prediction::JunctionAnalyzer::GetJunctionFeature ( const std::string &  start_lane_id)

Get junction feature starting from start_lane_id

参数
startlane ID
返回
junction

在文件 junction_analyzer.cc119 行定义.

120 {
121 if (junction_features_.find(start_lane_id) != junction_features_.end()) {
122 return junction_features_[start_lane_id];
123 }
124 JunctionFeature junction_feature;
125 junction_feature.set_junction_id(GetJunctionId());
126 junction_feature.set_junction_range(ComputeJunctionRange());
127 // Find all junction-exit-lanes that are successors of the start_lane_id.
128 std::vector<JunctionExit> junction_exits = GetJunctionExits(start_lane_id);
129
130 for (const auto& junction_exit : junction_exits) {
131 junction_feature.add_junction_exit()->CopyFrom(junction_exit);
132 }
133 junction_feature.mutable_enter_lane()->set_lane_id(start_lane_id);
134 junction_feature.add_start_lane_id(start_lane_id);
135 junction_features_[start_lane_id] = junction_feature;
136 return junction_features_[start_lane_id];
137}
double ComputeJunctionRange()
Compute junction range

◆ GetJunctionFeature() [2/2]

JunctionFeature apollo::prediction::JunctionAnalyzer::GetJunctionFeature ( const std::vector< std::string > &  start_lane_ids)

Get junction feature starting from start_lane_ids

参数
startlane IDs
返回
junction

在文件 junction_analyzer.cc139 行定义.

140 {
141 JunctionFeature merged_junction_feature;
142 bool initialized = false;
143 std::unordered_map<std::string, JunctionExit> junction_exits_map;
144 for (const std::string& start_lane_id : start_lane_ids) {
145 JunctionFeature junction_feature = GetJunctionFeature(start_lane_id);
146 if (!initialized) {
147 merged_junction_feature.set_junction_id(junction_feature.junction_id());
148 merged_junction_feature.set_junction_range(
149 junction_feature.junction_range());
150 initialized = true;
151 }
152 for (const JunctionExit& junction_exit : junction_feature.junction_exit()) {
153 if (junction_exits_map.find(junction_exit.exit_lane_id()) ==
154 junction_exits_map.end()) {
155 junction_exits_map[junction_exit.exit_lane_id()] = junction_exit;
156 }
157 }
158 }
159 for (const auto& exit : junction_exits_map) {
160 merged_junction_feature.add_start_lane_id(exit.first);
161 merged_junction_feature.add_junction_exit()->CopyFrom(exit.second);
162 }
163 return merged_junction_feature;
164}
const JunctionFeature & GetJunctionFeature(const std::string &start_lane_id)
Get junction feature starting from start_lane_id

◆ GetJunctionId()

const std::string & apollo::prediction::JunctionAnalyzer::GetJunctionId ( )

Get junction ID

返回
Junction ID

在文件 junction_analyzer.cc170 行定义.

170 {
171 CHECK_NOTNULL(junction_info_ptr_);
172 return junction_info_ptr_->id().id();
173}

◆ Init()

void apollo::prediction::JunctionAnalyzer::Init ( const std::string &  junction_id)

Initialize by junction ID, if junction id differs from prev cycle

参数
junctionID

在文件 junction_analyzer.cc34 行定义.

34 {
35 if (junction_info_ptr_ != nullptr &&
36 junction_info_ptr_->id().id() == junction_id) {
37 return;
38 }
39 Clear();
40 junction_info_ptr_ = PredictionMap::JunctionById(junction_id);
41 SetAllJunctionExits();
42}
void Clear()
Clear all stored data
static std::shared_ptr< const hdmap::JunctionInfo > JunctionById(const std::string &id)
Get a shared pointer to a junction by junction ID.

该类的文档由以下文件生成: