Apollo 11.0
自动驾驶开放平台
apollo::planning::NaviObstacleDecider类 参考

NaviObstacleDecider is used to make appropriate decisions for obstacles around the vehicle in navigation mode. 更多...

#include <navi_obstacle_decider.h>

类 apollo::planning::NaviObstacleDecider 继承关系图:
apollo::planning::NaviObstacleDecider 的协作图:

Public 成员函数

 NaviObstacleDecider ()
 
virtual ~NaviObstacleDecider ()=default
 
bool Init (const PlannerNaviConfig &config) override
 Initialization parameters
 
double GetNudgeDistance (const std::vector< const Obstacle * > &obstacles, const ReferenceLine &reference_line, const PathDecision &path_decision, const std::vector< common::PathPoint > &path_data_points, const common::VehicleState &vehicle_state, int *lane_obstacles_num)
 get the actual nudgable distance according to the position of the obstacle
 
void GetUnsafeObstaclesInfo (const std::vector< common::PathPoint > &path_data_points, const std::vector< const Obstacle * > &obstacles)
 get the unsafe obstacles between trajectory and reference line.
 
const std::vector< std::tuple< std::string, double, double > > & UnsafeObstacles ()
 Get unsafe obstacles' ID
 
- Public 成员函数 继承自 apollo::planning::NaviTask
 NaviTask (const std::string &name)
 
virtual ~NaviTask ()=default
 
virtual const std::string & Name () const
 
virtual apollo::common::Status Execute (Frame *frame, ReferenceLineInfo *reference_line_info)
 

额外继承的成员函数

- Protected 属性 继承自 apollo::planning::NaviTask
bool is_init_ = false
 
Frame * frame_ = nullptr
 
ReferenceLineInfo * reference_line_info_ = nullptr
 

详细描述

NaviObstacleDecider is used to make appropriate decisions for obstacles around the vehicle in navigation mode.

Note that NaviObstacleDecider is only used in navigation mode (turn on navigation mode by setting "FLAGS_use_navigation_mode" to "true") and do not use it in standard mode.

在文件 navi_obstacle_decider.h 第 53 行定义.

构造及析构函数说明

◆ NaviObstacleDecider()

apollo::planning::NaviObstacleDecider::NaviObstacleDecider ( )

在文件 navi_obstacle_decider.cc 第 45 行定义.

45: NaviTask("NaviObstacleDecider") {}
NaviTask(const std::string &name)
Definition navi_task.cc:30

◆ ~NaviObstacleDecider()

virtual apollo::planning::NaviObstacleDecider::~NaviObstacleDecider ( )
virtualdefault

成员函数说明

◆ GetNudgeDistance()

double apollo::planning::NaviObstacleDecider::GetNudgeDistance ( const std::vector< const Obstacle * > &  obstacles,
const ReferenceLine &  reference_line,
const PathDecision &  path_decision,
const std::vector< common::PathPoint > &  path_data_points,
const common::VehicleState &  vehicle_state,
int *  lane_obstacles_num 
)

get the actual nudgable distance according to the position of the obstacle

返回
actual nudgable distance

在文件 navi_obstacle_decider.cc 第 261 行定义.

265 {
266 CHECK_NOTNULL(lane_obstacles_num);
267
268 // Calculating the left and right nudgeable distance on the lane
269 double left_nudge_lane = 0.0;
270 double right_nudge_lane = 0.0;
271 double routing_y = path_data_points[0].y();
272 double min_lane_width = GetMinLaneWidth(path_data_points, reference_line);
273
274 ADEBUG << "get min_lane_width: " << min_lane_width;
275 if (routing_y <= 0.0) {
276 left_nudge_lane = min_lane_width / 2.0 - std::fabs(routing_y) -
277 VehicleParam().left_edge_to_center();
278 right_nudge_lane = -1.0 * (min_lane_width / 2.0 + std::fabs(routing_y) -
279 VehicleParam().right_edge_to_center());
280 } else {
281 left_nudge_lane = min_lane_width / 2.0 + std::fabs(routing_y) -
282 VehicleParam().left_edge_to_center();
283 right_nudge_lane = -1.0 * (min_lane_width / 2.0 - std::fabs(routing_y) -
284 VehicleParam().right_edge_to_center());
285 }
286
287 // Calculating the left and right nudgable distance according to the
288 // position of the obstacle.
289 double left_nudge_obstacle = 0.0;
290 double right_nudge_obstacle = 0.0;
291
292 // Calculation of the number of current Lane obstacles
293 obstacle_lat_dist_.clear();
294 ProcessObstacle(obstacles, path_data_points, path_decision, min_lane_width,
295 vehicle_state);
296 for (auto iter = obstacle_lat_dist_.begin(); iter != obstacle_lat_dist_.end();
297 ++iter) {
298 auto actual_dist = GetObstacleActualOffsetDistance(
299 iter, right_nudge_lane, left_nudge_lane, lane_obstacles_num);
300 auto lat_dist = iter->second;
301 if (actual_dist > config_.min_nudge_distance() &&
302 actual_dist < config_.max_nudge_distance()) {
303 auto need_nudge_dist = config_.max_nudge_distance() - actual_dist;
304 if (lat_dist >= 0.0) {
305 right_nudge_obstacle =
306 -1.0 * std::max(std::fabs(right_nudge_obstacle), need_nudge_dist);
307 } else {
308 left_nudge_obstacle =
309 std::max(std::fabs(left_nudge_obstacle), need_nudge_dist);
310 }
311 }
312 }
313 ADEBUG << "get left_nudge_lane: " << left_nudge_lane
314 << "get right_nudge_lane : " << right_nudge_lane
315 << "get left_nudge_obstacle: " << left_nudge_obstacle
316 << "get right_nudge_obstacle : " << right_nudge_obstacle;
317 // Get the appropriate value of the nudge distance
318 double nudge_dist = 0.0;
319 if (std::fabs(left_nudge_obstacle) > kEpislon &&
320 std::fabs(right_nudge_obstacle) <= kEpislon) {
321 nudge_dist = std::min(left_nudge_lane, left_nudge_obstacle);
322 } else if (std::fabs(right_nudge_obstacle) > kEpislon &&
323 std::fabs(left_nudge_obstacle) <= kEpislon) {
324 nudge_dist = std::max(right_nudge_lane, right_nudge_obstacle);
325 }
326
327 ADEBUG << "get nudge distance : " << nudge_dist
328 << "get lane_obstacles_num : " << *lane_obstacles_num;
329 RecordLastNudgeDistance(nudge_dist);
330 SmoothNudgeDistance(vehicle_state, &nudge_dist);
331 KeepNudgePosition(nudge_dist, lane_obstacles_num);
332 ADEBUG << "last nudge distance : " << nudge_dist;
333 return nudge_dist;
334}
#define ADEBUG
Definition log.h:41

◆ GetUnsafeObstaclesInfo()

void apollo::planning::NaviObstacleDecider::GetUnsafeObstaclesInfo ( const std::vector< common::PathPoint > &  path_data_points,
const std::vector< const Obstacle * > &  obstacles 
)

get the unsafe obstacles between trajectory and reference line.

在文件 navi_obstacle_decider.cc 第 356 行定义.

358 {
359 // Find start point of the reference line.
360 double reference_line_y = path_data_points[0].y();
361
362 // Judging unsafed range according to the position of the reference line.
363 double unsafe_refline_pos_y = 0.0;
364 double unsafe_car_pos_y = 0.0;
365 std::pair<double, double> unsafe_range;
366 if (reference_line_y < 0.0) {
367 unsafe_refline_pos_y = reference_line_y -
368 VehicleParam().right_edge_to_center() -
370 unsafe_car_pos_y = VehicleParam().right_edge_to_center() +
372 unsafe_range = std::make_pair(unsafe_refline_pos_y, unsafe_car_pos_y);
373 } else {
374 unsafe_refline_pos_y = reference_line_y +
375 VehicleParam().left_edge_to_center() +
377 unsafe_car_pos_y = -1.0 * (VehicleParam().left_edge_to_center() +
379 unsafe_range = std::make_pair(unsafe_car_pos_y, unsafe_refline_pos_y);
380 }
381 // Get obstacles'ID.
382 unsafe_obstacle_info_.clear();
383 PathPoint vehicle_projection_point =
384 PathMatcher::MatchToPath(path_data_points, 0, 0);
385 for (const auto& iter : obstacles) {
386 const double obstacle_y = iter->Perception().position().y();
387 if ((obstacle_y > unsafe_range.first && obstacle_y < unsafe_range.second) ||
388 std::abs(iter->Perception().velocity().y()) >
389 config_.lateral_velocity_value()) {
390 auto projection_point = PathMatcher::MatchToPath(
391 path_data_points, iter->Perception().position().x(), obstacle_y);
392 if (vehicle_projection_point.s() >= projection_point.s()) {
393 continue;
394 }
395 auto front_distance =
396 (projection_point.s() - iter->Perception().length() / 2.0) -
397 vehicle_projection_point.s();
398 auto ref_theta = projection_point.theta();
399 auto project_velocity =
400 iter->Perception().velocity().x() * std::cos(ref_theta) +
401 iter->Perception().velocity().y() * std::sin(ref_theta);
402 ADEBUG << "Lateral speed : " << iter->Perception().velocity().y();
403 unsafe_obstacle_info_.emplace_back(iter->Id(), front_distance,
404 project_velocity);
405 }
406 }
407}
static PathPoint MatchToPath(const std::vector< PathPoint > &reference_line, const double x, const double y)

◆ Init()

bool apollo::planning::NaviObstacleDecider::Init ( const PlannerNaviConfig &  config)
overridevirtual

Initialization parameters

返回
Initialization success or not

重载 apollo::planning::NaviTask .

在文件 navi_obstacle_decider.cc 第 47 行定义.

47 {
48 config_ = config.navi_obstacle_decider_config();
49 return true;
50}

◆ UnsafeObstacles()

const std::vector< std::tuple< std::string, double, double > > & apollo::planning::NaviObstacleDecider::UnsafeObstacles ( )
inline

Get unsafe obstacles' ID

返回
unsafe_obstacle_ID_

在文件 navi_obstacle_decider.h 第 191 行定义.

191 {
192 return unsafe_obstacle_info_;
193}

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