Apollo planning模块 (一)

1.Navigation模式

参考文档:/apollo-3.5.0/docs/howto/how_to_use_apollo_2.5_navigation_mode_cn.md

高精地图制作难度大、需要特殊权限,因此为了使Apollo系统摆脱对高精地图的依赖,设置了Navigation模式。Navigation模式的基本思路如下:

 记录人类驾驶员的行驶路径作为参考路径,在车辆行驶过程中通过感知模块生成实时的relative map来进行规划。

 2.Apollo Planning模块的输入、输出、整体架构

输入信息:定位、感知、预测、高精地图、路由、任务管理模块

输出信息:控制模块可执行的顺滑无碰撞轨迹

 /apollo-7.0.0/modules/planning/proto/planning_config.proto:Apollo planning 模块将行驶场景分为如下16类。每种场景由若干个stage组成,stage又包含若干task。

/apollo-7.0.0/modules/planning/conf/scenario/lane_follow_config.pb.txt: lane follow scenerio 的stage 和 task

 

/apollo-7.0.0/docs/technical_documents/tasks/path_bounds_decider_cn.md:规划任务的整体流程

 

 

3.navi_planning 和 on_lane_planning

planning_base有navi_planning和 on_lane_planning两个子类。在planning_component.h  Init函数中确定使用哪个planning

if (FLAGS_use_navigation_mode) {
    planning_base_ = std::make_unique<NaviPlanning>(injector_);
  } else {
    planning_base_ = std::make_unique<OnLanePlanning>(injector_);
  }

4.ScenarioManager场景选择:/apollo-7.0.0/modules/planning/scenarios/scenario_manager.cc

Interception:拦截
pad message:外界输入信号?????
ScenarioConfig::ScenarioType ScenarioManager::ScenarioDispatchNonLearning(
    const Frame& frame) {
  ////////////////////////////////////////
  // default: LANE_FOLLOW
  ScenarioConfig::ScenarioType scenario_type = default_scenario_type_;
  ////////////////////////////////////////
  // Pad Msg scenario
  scenario_type = SelectPadMsgScenario(frame);

  const auto vehicle_state_provider = injector_->vehicle_state();
  common::VehicleState vehicle_state = vehicle_state_provider->vehicle_state();
  const common::PointENU& target_point =
  frame.local_view().routing->routing_request().dead_end_info().target_point();
  const common::VehicleState& car_position = frame.vehicle_state();
  if (scenario_type == default_scenario_type_) {
    // check current_scenario (not switchable)
    switch (current_scenario_->scenario_type()) {
      case ScenarioConfig::LANE_FOLLOW:
      case ScenarioConfig::PULL_OVER:
        break;
      case ScenarioConfig::BARE_INTERSECTION_UNPROTECTED:
      case ScenarioConfig::EMERGENCY_PULL_OVER:
      case ScenarioConfig::PARK_AND_GO:
      case ScenarioConfig::STOP_SIGN_PROTECTED:
      case ScenarioConfig::STOP_SIGN_UNPROTECTED:
      case ScenarioConfig::TRAFFIC_LIGHT_PROTECTED:
      case ScenarioConfig::TRAFFIC_LIGHT_UNPROTECTED_LEFT_TURN:
      case ScenarioConfig::TRAFFIC_LIGHT_UNPROTECTED_RIGHT_TURN:
      case ScenarioConfig::VALET_PARKING:
      case ScenarioConfig::DEADEND_TURNAROUND:
        // transfer dead_end to lane follow, should enhance transfer logic
        if (JudgeReachTargetPoint(car_position, target_point)) {
          scenario_type = ScenarioConfig::LANE_FOLLOW;
          reach_target_pose_ = true;
        }
      case ScenarioConfig::YIELD_SIGN:
        // must continue until finish
        if (current_scenario_->GetStatus() !=
            Scenario::ScenarioStatus::STATUS_DONE) {
          scenario_type = current_scenario_->scenario_type();
        }
        break;
      default:
        break;
    }
  }
  ////////////////////////////////////////
  // ParkAndGo / starting scenario
  if (scenario_type == default_scenario_type_) {
    if (FLAGS_enable_scenario_park_and_go && !reach_target_pose_) {
      scenario_type = SelectParkAndGoScenario(frame);
    }
  }

  ////////////////////////////////////////
  // intersection scenarios
  if (scenario_type == default_scenario_type_) {
    scenario_type = SelectInterceptionScenario(frame);
  }

  ////////////////////////////////////////
  // pull-over scenario
  if (scenario_type == default_scenario_type_) {
    if (FLAGS_enable_scenario_pull_over) {
      scenario_type = SelectPullOverScenario(frame);
    }
  }

  ////////////////////////////////////////
  // VALET_PARKING scenario
  if (scenario_type == default_scenario_type_) {
    scenario_type = SelectValetParkingScenario(frame);
  }
  ////////////////////////////////////////
  // dead end
  if (scenario_type == default_scenario_type_) {
    scenario_type = SelectDeadEndScenario(frame);
  }
  ////////////////////////////////////////
  return scenario_type;
}
ScenarioConfig::ScenarioType ScenarioManager::SelectPadMsgScenario(
    const Frame& frame) {
  const auto& pad_msg_driving_action = frame.GetPadMsgDrivingAction();
  switch (pad_msg_driving_action) {
    case DrivingAction::PULL_OVER:
      if (FLAGS_enable_scenario_emergency_pull_over) {
        return ScenarioConfig::EMERGENCY_PULL_OVER;
      }
      break;
    case DrivingAction::STOP:
      if (FLAGS_enable_scenario_emergency_stop) {
        return ScenarioConfig::EMERGENCY_STOP;
      }
      break;
    case DrivingAction::RESUME_CRUISE:
      if (current_scenario_->scenario_type() ==
              ScenarioConfig::EMERGENCY_PULL_OVER ||
          current_scenario_->scenario_type() ==
              ScenarioConfig::EMERGENCY_STOP) {
        return ScenarioConfig::PARK_AND_GO;
      }
      break;
    default:
      break;
  }
  return default_scenario_type_;
}

 5.planner文件夹

planner类继承关系:

基类:Planner,派生类:PlannerWithReferenceLine

基类:PlannerWithReferenceLine,派生类:LatticePlannerNaviPlannerPublicRoadPlanner

planner_dispatcher类继承关系(采用Dispatcher设计模式!!!):

基类PlannerDispatcher,派生类NaviPlannerDispatcherOnLanePlannerDispatcher

 

 

 

 

 

posted @ 2023-05-02 20:37  huidaoqingdao  Views(237)  Comments(0Edit  收藏  举报