95 {
96 auto obstacles_container =
97 container_manager_->GetContainer<ObstaclesContainer>(
99 if (obstacles_container == nullptr) {
100 AERROR <<
"Obstacles container pointer is a null pointer.";
101 return;
102 }
103
104 Obstacle* ego_obstacle_ptr =
105 obstacles_container->GetObstacle(FLAGS_ego_vehicle_id);
106 if (ego_obstacle_ptr == nullptr) {
107 AERROR <<
"Ego obstacle nullptr found";
108 return;
109 }
110
111 const Feature& ego_feature = ego_obstacle_ptr->latest_feature();
112 double ego_theta = ego_feature.theta();
113 double ego_x = ego_feature.position().x();
114 double ego_y = ego_feature.position().y();
115 ADEBUG <<
"Get pose (" << ego_x <<
", " << ego_y <<
", " << ego_theta <<
")";
116
117
118 Box2d scan_box({ego_x + FLAGS_scan_length / 2.0 * std::cos(ego_theta),
119 ego_y + FLAGS_scan_length / 2.0 * std::sin(ego_theta)},
120 ego_theta, FLAGS_scan_length, FLAGS_scan_width);
121
122 const auto& obstacle_ids =
123 obstacles_container->curr_frame_movable_obstacle_ids();
124 for (const int obstacle_id : obstacle_ids) {
125 Obstacle* obstacle_ptr = obstacles_container->GetObstacle(obstacle_id);
126 if (obstacle_ptr == nullptr) {
127 AERROR <<
"Null obstacle pointer found.";
128 continue;
129 }
130 if (obstacle_ptr->history_size() == 0) {
131 AERROR <<
"Obstacle [" << obstacle_ptr->id() <<
"] has no feature.";
132 continue;
133 }
134 Feature* latest_feature_ptr = obstacle_ptr->mutable_latest_feature();
135 double obstacle_x = latest_feature_ptr->position().x();
136 double obstacle_y = latest_feature_ptr->position().y();
137 Vec2d ego_to_obstacle_vec(obstacle_x - ego_x, obstacle_y - ego_y);
139 double s = ego_to_obstacle_vec.InnerProd(ego_vec);
140
141 double pedestrian_like_nearby_lane_radius =
142 FLAGS_pedestrian_nearby_lane_search_radius;
144 obstacle_x, obstacle_y, pedestrian_like_nearby_lane_radius);
145
146
147 bool is_in_scan_area = scan_box.IsPointIn({obstacle_x, obstacle_y});
148 bool is_on_lane = obstacle_ptr->IsOnLane();
149 bool is_pedestrian_like_in_front_near_lanes =
150 s > FLAGS_back_dist_ignore_ped &&
155 is_near_lane;
156 bool is_near_junction = obstacle_ptr->IsNearJunction();
157
158 bool need_consider = is_in_scan_area || is_on_lane || is_near_junction ||
159 is_pedestrian_like_in_front_near_lanes;
160
161 if (!need_consider) {
162 latest_feature_ptr->mutable_priority()->set_priority(
164 } else {
165 latest_feature_ptr->mutable_priority()->set_priority(
167 }
168 }
169 obstacles_container->SetConsideredObstacleIds();
170}
static Vec2d CreateUnitVec2d(const double angle)
Creates a unit-vector with a given angle to the positive x semi-axis
static bool HasNearbyLane(const double x, const double y, const double radius)
If there is a lane in the range with radius