Apollo 10.0
自动驾驶开放平台
README_cn

planning-pnc_map-lane_follow_map

简介

LaneFollowMap: PncMapBase的一个子类,在lane_follow_command指令下,从routing结果转换到ReferenceLine的过程中做前期准备,主要功能是处理routing结果,将routing数据处理并存储在map相关的数据结构中;根据routing结果及当前车辆位置,计算可行驶的passage信息,并转换成RouteSegments结构,为ReferenceLine提供数据传入参数。封装在reference_line_provider中。

基本结构说明

LaneFollowMap中对路径进行RoadSegment,Passage,LaneSegment的存储如下图所示

主要成员变量说明

数据结构说明

  • 定义存储lane数据,其中index为当前lane_segment 的 {road_index, passage_index, lane_index}的三元组。
    struct RouteIndex {
    apollo::hdmap::LaneSegment segment;
    std::array<int, 3> index;
    };
  • 定义存储waypoint,以及该waypoint在route_indices_中的序号index。
    struct WaypointIndex {
    apollo::hdmap::LaneWaypoint waypoint;
    int index;
    WaypointIndex(const apollo::hdmap::LaneWaypoint &waypoint, int index)
    : waypoint(waypoint), index(index) {}
    };
成员变量 说明
std::vector<RouteIndex> route_indices_ 存储routing所有road,passage,lane的信息
int range_start_ 主车根据routing结果更新搜索区间的起始序号
int range_end_ 主车根据routing结果更新搜索区间的终止序号
std::unordered_set<std::string> range_lane_ids_ 在搜索区间内的所有lane的id
std::unordered_set<std::string> all_lane_ids_ 当前routing结果的所有lane的id
std::vector<WaypointIndex> routing_waypoint_index_ 当前routing结果的所有waypoint及对应序号
std::size_t next_routing_waypoint_index_ 下一个经过的waypoint
common::VehicleState adc_state_ 主车状态
int adc_route_index_ 主车所处的route的序号
apollo::hdmap::LaneWaypoint adc_waypoint_ 主车所处的waypoint

主要成员函数说明

1. UpdatePlanningCommand

  • 传入参数为planning::PlanningCommand &command,每当有新的routing结果时,用最新的RoutingResponse对LaneFollowMap里的数据进行更新。用三个for循环分别剥离出routing结果里的road,passage,lane,将每条lane的id存进all_lane_ids_这个数组中;将每个lane_segment{road_index, passage_index, lane_index}存进route_indices_中。
  • 重置range_start_range_end_adc_route_index_next_routing_waypoint_index_,调用UpdateRoutingRange成员函数将routing结果的lane_id存放进range_lane_ids_中。
  • 将routing_request中的waypoint信息存储进routing_waypoint_index_中,routing信息的转换完毕。

2. UpdateVehicleState

  • 传入参数为VehicleState &vehicle_state,根据主车状态,调用GetNearestPointFromRouting成员函数从routing中查找到最近的道路点adc_waypoint_
  • 并根据adc_waypoint_调用GetWaypointIndex成员函数查找到当前行驶的LaneSegment在route_indices_中的序号route_index,并更新至adc_route_index_
  • 调用UpdateNextRoutingWaypointIndex成员函数,传入参数route_index, 计算主车下一个必经的waypoint点,并赋给next_routing_waypoint_index_
  • 调用UpdateRoutingRange成员函数,传入参数adc_route_index_,更新主车未经过的路线存放进range_lane_ids_中。

3. GetRouteSegments

  • ReferenceLineProvider中被调用,用于更新获取当前route_segments,为参考线构建提供数据支持。
  • 传入参数const VehicleState &vehicle_state, std::list<hdmap::RouteSegments> *const route_segments,引用传参route_segments更新route数据。
  • 调用LookForwardDistance,根据车辆当前速度计算前向搜索距离look_forward_distance。后向搜索look_backward_distance由参数控制。
  • 调用GetRouteSegments的重载函数获取route_segments,传入参数为vehicle_state, look_backward_distance, look_forward_distance, route_segments

4. <tt>GetRouteSegments</tt>重载

  • 传入参数为vehicle_state, look_backward_distance, look_forward_distance, route_segments
  • 调用UpdateVehicleState,更新route状态。
  • 由更新的adc_route_index_,获得当前出车所处的RoadSegmentPassage的序号road_indexpassage_index,根据当前road和passage,调用GetNeighborPassages计算当前车道的所有相邻passage的信息drive_passages
  • for循环遍历drive_passages进行操作。调用PassageToSegments成员函数,将passage转换为hdmap::RouteSegments segments,并且计算主车到当前segments的投影点,从该投影点,按照前向搜索距离look_forward_distance,后向搜索距离look_backward_distance,进行segments的扩展。从而得到当前passage的segments,并且保存至route_segments

5. GetNeighborPassages

  • 传入参数为const routing::RoadSegment &road, int start_passage,被GetRouteSegments调用,实线从主车当前所在start_passage获取临近passage。
  • 如果source_passage.change_lane_type() == routing::FORWARD,当前passage可以不经过变道直达目标点;或者 source_passage.can_exit(),当前passage可退出,到达目标点,则不需要搜索临近passages,return退出。
  • 根据source_passage获取source_segments,并根据当前lane_segemnts,以及目标通路的方向,分别向左右搜索临近的车道,将id保存至neighbor_lanes
  • 遍历road的所有passages,保存与neighbor_lanes相同id的lane_segment

6. PassageToSegments

  • 传入参数routing::Passage passage, hdmap::RouteSegments *segments
  • 遍历passage中的lane_segment,将其类型转换为RouteSegments,保存至segments

7. UpdateRoutingRange

  • 传入参数adc_index
  • 遍历route_indices_,从主车当前adc_index开始的route id保存至range_lane_ids_

8. GetNearestPointFromRouting

  • 传入参数const VehicleState &state, hdmap::LaneWaypoint *waypoint,根据主车位置获取最近waypoint
  • 遍历all_lane_ids_,获取所有可用lane,保存至valid_lanes
  • 遍历valid_lanes,获取所有主车纵向所处车道内的waypoints,保存至valid_way_points
  • 遍历valid_way_points,获取所有主车纵向所处车道内的waypoints,保存至valid_way_points
  • 遍历valid_way_points,获取最近的waypoint

9. GetWaypointIndex

  • 传入参数const hdmap::LaneWaypoint &waypoint,通过前向和后向搜索,返回该waypoint在route_indices_中的index。

10.UpdateNextRoutingWaypointIndex

  • 传入参数int cur_index,从当前index,计算routing结果中的下一个需要经过的waypoint,更新next_routing_waypoint_index_

目录结构

modules/planning/pnc_map/lane_follow_map/
├── BUILD
├── cyberfile.xml
├── images
│ └── map_road_info.png
├── lane_follow_map.cc
├── lane_follow_map.h
├── lane_follow_map_test.cc
├── plugins.xml
└── README_cn.md

模块

LaneFollowMap

apollo::planning::LaneFollowMap

使用方式

配置使用 LaneFollowMap

modules/planning/planning_component/conf/planning_config.pb.txt文件中修改reference_line_config的配置,配置使用LaneFollowMap

shell
# modules/planning/planning_component/conf/planning_config.pb.txt
reference_line_config {
pnc_map_class: "apollo::planning::LaneFollowMap"
}

文档意见反馈

如果您在使用文档的过程中,遇到任何问题,请到我们在【开发者社区】建立的 反馈意见收集问答页面,反馈相关的问题。我们会根据反馈意见对文档进行迭代优化。