Apollo 11.0
自动驾驶开放平台
lane_follow_map.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
21#pragma once
22
23#include <list>
24#include <memory>
25#include <string>
26#include <unordered_set>
27#include <vector>
28
29#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
30#include "modules/common_msgs/routing_msgs/routing.pb.h"
31
37
38namespace apollo {
39namespace planning {
40
41class LaneFollowMap : public PncMapBase {
42 public:
44
45 virtual ~LaneFollowMap() = default;
46
47 bool CanProcess(const planning::PlanningCommand &command) const override;
48
49 bool UpdatePlanningCommand(const planning::PlanningCommand &command) override;
54 const common::VehicleState &vehicle_state,
55 std::list<apollo::hdmap::RouteSegments> *const route_segments) override;
56
57 bool ExtendSegments(
58 const apollo::hdmap::RouteSegments &segments, double start_s,
59 double end_s,
60 apollo::hdmap::RouteSegments *const truncated_segments) const override;
61
62 std::vector<routing::LaneWaypoint> FutureRouteWaypoints() const override;
68 std::shared_ptr<routing::LaneWaypoint> &end_point) const override;
73 hdmap::LaneInfoConstPtr GetLaneById(const hdmap::Id &id) const override;
74
76 const common::VehicleState &state,
77 apollo::hdmap::LaneWaypoint *waypoint) const override;
78
79 double GetDistanceToDestination() const override;
81
82 private:
88 bool IsValid(const planning::PlanningCommand &command) const override;
89
91 const common::VehicleState &vehicle_state, const double backward_length,
92 const double forward_length,
93 std::list<apollo::hdmap::RouteSegments> *const route_segments);
94
96 const common::PointENU &point, double look_forward,
97 double look_backward,
98 apollo::hdmap::RouteSegments *extended_segments);
99
100 bool UpdateVehicleState(const common::VehicleState &vehicle_state);
107 int GetWaypointIndex(const apollo::hdmap::LaneWaypoint &waypoint) const;
108
109 bool PassageToSegments(routing::Passage passage,
110 apollo::hdmap::RouteSegments *segments) const;
111
112 bool ProjectToSegments(const common::PointENU &point_enu,
113 const apollo::hdmap::RouteSegments &segments,
114 apollo::hdmap::LaneWaypoint *waypoint) const;
115
116 static void AppendLaneToPoints(
117 apollo::hdmap::LaneInfoConstPtr lane, const double start_s,
118 const double end_s,
119 std::vector<apollo::hdmap::MapPathPoint> *const points);
120
121 apollo::hdmap::LaneInfoConstPtr GetRoutePredecessor(
123 apollo::hdmap::LaneInfoConstPtr GetRouteSuccessor(
125
133 std::vector<int> GetNeighborPassages(const routing::RoadSegment &road,
134 int start_passage) const;
135
141 apollo::hdmap::LaneWaypoint ToLaneWaypoint(
142 const routing::LaneWaypoint &waypoint) const;
143
149 apollo::hdmap::LaneSegment ToLaneSegment(
150 const routing::LaneSegment &segment) const;
151
161 void UpdateNextRoutingWaypointIndex(int cur_index);
162
168 int SearchForwardWaypointIndex(
169 int start, const apollo::hdmap::LaneWaypoint &waypoint) const;
170 int SearchBackwardWaypointIndex(
171 int start, const apollo::hdmap::LaneWaypoint &waypoint) const;
172
173 void UpdateRoutingRange(int adc_index);
174 void UpdateRouteSegmentsLaneIds(
175 const std::list<hdmap::RouteSegments> *route_segments);
176
177 private:
178 struct RouteIndex {
180 std::array<int, 3> index;
181 };
182 std::vector<RouteIndex> route_indices_;
183 int range_start_ = 0;
184 int range_end_ = 0;
185 // routing ids in range
186 std::unordered_set<std::string> range_lane_ids_;
187 std::unordered_set<std::string> all_lane_ids_;
188 std::unordered_set<std::string> route_segments_lane_ids_;
189 routing::LaneSegment dest_lane_segment_;
190
194 struct WaypointIndex {
196 int index;
197 WaypointIndex(const apollo::hdmap::LaneWaypoint &waypoint, int index)
198 : waypoint(waypoint), index(index) {}
199 };
200
201 // return the segment of an index
202 int NextWaypointIndex(int index) const;
203
204 std::vector<WaypointIndex> routing_waypoint_index_;
208 std::size_t next_routing_waypoint_index_ = 0;
209
210 const hdmap::HDMap *hdmap_ = nullptr;
211 bool is_same_routing_ = false;
212
216 common::VehicleState adc_state_;
220 int adc_route_index_ = -1;
229 bool stop_for_destination_ = false;
230};
231
233 PncMapBase)
234
235} // namespace planning
236} // namespace apollo
std::vector< routing::LaneWaypoint > FutureRouteWaypoints() const override
apollo::hdmap::LaneWaypoint GetAdcWaypoint() const override
bool GetRouteSegments(const common::VehicleState &vehicle_state, std::list< apollo::hdmap::RouteSegments > *const route_segments) override
use heuristic forward length and backward length
hdmap::LaneInfoConstPtr GetLaneById(const hdmap::Id &id) const override
Get the Lane with the given id.
virtual ~LaneFollowMap()=default
bool CanProcess(const planning::PlanningCommand &command) const override
bool UpdatePlanningCommand(const planning::PlanningCommand &command) override
double GetDistanceToDestination() const override
void GetEndLaneWayPoint(std::shared_ptr< routing::LaneWaypoint > &end_point) const override
Get the end point of PlanningCommand.
bool ExtendSegments(const apollo::hdmap::RouteSegments &segments, double start_s, double end_s, apollo::hdmap::RouteSegments *const truncated_segments) const override
bool GetNearestPointFromRouting(const common::VehicleState &state, apollo::hdmap::LaneWaypoint *waypoint) const override
Planning module main class.
#define CYBER_PLUGIN_MANAGER_REGISTER_PLUGIN(name, base)
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
class register implement
Definition arena_queue.h:37