modules/planning/pnc_map/lane_follow_map/README_cn.md
LaneFollowMap: PncMapBase的一个子类,在lane_follow_command指令下,从routing结果转换到ReferenceLine的过程中做前期准备,主要功能是处理routing结果,将routing数据处理并存储在map相关的数据结构中;根据routing结果及当前车辆位置,计算可行驶的passage信息,并转换成RouteSegments结构,为ReferenceLine提供数据传入参数。封装在reference_line_provider中。
LaneFollowMap中对路径进行RoadSegment,Passage,LaneSegment的存储如下图所示
index为当前lane_segment 的 {road_index, passage_index, lane_index}的三元组。struct RouteIndex {
apollo::hdmap::LaneSegment segment;
std::array<int, 3> index;
};
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 |
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_waypoint_index_中,routing信息的转换完毕。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_中。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。GetRouteSegments重载vehicle_state, look_backward_distance, look_forward_distance, route_segments。UpdateVehicleState,更新route状态。adc_route_index_,获得当前出车所处的RoadSegment和Passage的序号road_index、passage_index,根据当前road和passage,调用GetNeighborPassages计算当前车道的所有相邻passage的信息drive_passages。drive_passages进行操作。调用PassageToSegments成员函数,将passage转换为hdmap::RouteSegments segments,并且计算主车到当前segments的投影点,从该投影点,按照前向搜索距离look_forward_distance,后向搜索距离look_backward_distance,进行segments的扩展。从而得到当前passage的segments,并且保存至route_segments。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。routing::Passage passage, hdmap::RouteSegments *segmentspassage中的lane_segment,将其类型转换为RouteSegments,保存至segments。adc_indexroute_indices_,从主车当前adc_index开始的route id保存至range_lane_ids_。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。const hdmap::LaneWaypoint &waypoint,通过前向和后向搜索,返回该waypoint在route_indices_中的index。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
apollo::planning::LaneFollowMap
在modules/planning/planning_component/conf/planning_config.pb.txt文件中修改reference_line_config的配置,配置使用LaneFollowMap。
# modules/planning/planning_component/conf/planning_config.pb.txt
reference_line_config {
pnc_map_class: "apollo::planning::LaneFollowMap"
}