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

#include <right_of_way.h>

apollo::prediction::RightOfWay 的协作图:

Public 成员函数

 RightOfWay ()=delete
 Constructor
 

静态 Public 成员函数

static void Analyze (ContainerManager *container_manager)
 Set right_of_way for all lane_sequence
 

详细描述

在文件 right_of_way.h24 行定义.

构造及析构函数说明

◆ RightOfWay()

apollo::prediction::RightOfWay::RightOfWay ( )
delete

Constructor

成员函数说明

◆ Analyze()

void apollo::prediction::RightOfWay::Analyze ( ContainerManager container_manager)
static

Set right_of_way for all lane_sequence

返回
Scenario features

在文件 right_of_way.cc38 行定义.

38 {
39 ObstaclesContainer* obstacles_container =
40 container_manager->GetContainer<ObstaclesContainer>(
42 if (obstacles_container == nullptr) {
43 AERROR << "Null obstacles container found";
44 return;
45 }
46
47 ADCTrajectoryContainer* adc_trajectory_container =
48 container_manager->GetContainer<ADCTrajectoryContainer>(
50 if (adc_trajectory_container == nullptr) {
51 AERROR << "adc_trajectory_container is nullptr";
52 return;
53 }
54 const std::vector<std::string>& lane_ids =
55 adc_trajectory_container->GetADCLaneIDSequence();
56 if (lane_ids.empty()) {
57 return;
58 }
59
60 auto pose_container = container_manager->GetContainer<PoseContainer>(
62 if (pose_container == nullptr) {
63 AERROR << "Pose container pointer is a null pointer.";
64 return;
65 }
66 const PerceptionObstacle* pose_obstacle_ptr =
67 pose_container->ToPerceptionObstacle();
68 if (pose_obstacle_ptr == nullptr) {
69 AERROR << "Pose obstacle pointer is a null pointer.";
70 return;
71 }
72 double pose_x = pose_obstacle_ptr->position().x();
73 double pose_y = pose_obstacle_ptr->position().y();
74 double ego_vehicle_s = std::numeric_limits<double>::max();
75 double ego_vehicle_l = std::numeric_limits<double>::max();
76 double accumulated_s = 0.0;
77 std::string ego_lane_id = "";
78 // loop for lane_ids to findout ego_vehicle_s and lane_id
79 for (const std::string& lane_id : lane_ids) {
80 std::shared_ptr<const LaneInfo> lane_info_ptr =
82 if (lane_info_ptr == nullptr) {
83 AERROR << "Null lane info pointer found.";
84 continue;
85 }
86 double s = 0.0;
87 double l = 0.0;
88 if (PredictionMap::GetProjection({pose_x, pose_y}, lane_info_ptr, &s, &l)) {
89 if (std::fabs(l) < std::fabs(ego_vehicle_l)) {
90 ego_vehicle_s = accumulated_s + s;
91 ego_vehicle_l = l;
92 ego_lane_id = lane_id;
93 }
94 }
95 accumulated_s += lane_info_ptr->total_length();
96 }
97
98 // loop again to assign ego_back_lane_id_set_ & ego_front_lane_id_set_
99 accumulated_s = 0.0;
100 std::unordered_set<std::string> ego_back_lane_id_set_;
101 std::unordered_set<std::string> ego_front_lane_id_set_;
102 for (const std::string& lane_id : lane_ids) {
103 std::shared_ptr<const LaneInfo> lane_info_ptr =
105 if (lane_info_ptr == nullptr) {
106 AERROR << "Null lane info pointer found.";
107 continue;
108 }
109 accumulated_s += lane_info_ptr->total_length();
110 if (accumulated_s < ego_vehicle_s) {
111 ego_back_lane_id_set_.insert(lane_id);
112 } else if (accumulated_s > ego_vehicle_s) {
113 ego_front_lane_id_set_.insert(lane_id);
114 }
115 }
116
117 // then loop through all obstacle vehicles
118 for (const int id :
119 obstacles_container->curr_frame_considered_obstacle_ids()) {
120 Obstacle* obstacle_ptr = obstacles_container->GetObstacle(id);
121 if (obstacle_ptr == nullptr) {
122 continue;
123 }
124 Feature* latest_feature_ptr = obstacle_ptr->mutable_latest_feature();
125 if (latest_feature_ptr->type() != PerceptionObstacle::VEHICLE) {
126 continue;
127 }
128 ADEBUG << "RightOfWay for obstacle [" << latest_feature_ptr->id() << "], "
129 << "with lane_sequence_size: "
130 << latest_feature_ptr->lane().lane_graph().lane_sequence_size();
131 for (auto& lane_sequence : *latest_feature_ptr->mutable_lane()
132 ->mutable_lane_graph()
133 ->mutable_lane_sequence()) {
134 accumulated_s = 0.0;
135 for (auto lane_segment : lane_sequence.lane_segment()) {
136 accumulated_s += lane_segment.end_s() - lane_segment.start_s();
137 // set lower righ_of_way for turn lanes
138 if (lane_segment.lane_turn_type() == 2) { // left_turn
139 lane_sequence.set_right_of_way(-20);
140 } else if (lane_segment.lane_turn_type() == 3) { // right_turn
141 lane_sequence.set_right_of_way(-10);
142 }
143 if (accumulated_s > 50.0) {
144 break;
145 }
146 }
147 }
148 }
149}
static std::shared_ptr< const hdmap::LaneInfo > LaneById(const std::string &id)
Get a shared pointer to a lane by lane ID.
static bool GetProjection(const Eigen::Vector2d &position, const std::shared_ptr< const hdmap::LaneInfo > lane_info, double *s, double *l)
Get the frenet coordinates (s, l) on a lane by a position.
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44

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