Apollo 10.0
自动驾驶开放平台
reference_line_provider.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
23#pragma once
24
25#include <list>
26#include <memory>
27#include <queue>
28#include <string>
29#include <unordered_set>
30#include <vector>
31
32#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
33#include "modules/common_msgs/planning_msgs/navigation.pb.h"
34#include "modules/common_msgs/routing_msgs/routing.pb.h"
35#include "modules/planning/planning_base/proto/planning_config.pb.h"
36
37#include "cyber/cyber.h"
48
53namespace apollo {
54namespace planning {
55
62 public:
64
66 const common::VehicleStateProvider* vehicle_state_provider,
67 const ReferenceLineConfig* reference_line_config,
68 const std::shared_ptr<relative_map::MapMsg>& relative_map = nullptr);
69
74
81
82 void UpdateVehicleState(const common::VehicleState& vehicle_state);
83
84 bool Start();
85
86 void Stop();
87
88 void Reset();
89
90 bool GetReferenceLines(std::list<ReferenceLine>* reference_lines,
91 std::list<hdmap::RouteSegments>* segments);
92
93 double LastTimeDelay();
94
95 std::vector<routing::LaneWaypoint> FutureRouteWaypoints();
96
97 bool UpdatedReferenceLine() { return is_reference_line_updated_.load(); }
98
100 std::shared_ptr<routing::LaneWaypoint>& end_point) const;
101
103
104 bool GetAdcWaypoint(hdmap::LaneWaypoint* waypoint) const;
105 bool GetAdcDis2Destination(double *dis) const;
106
107 private:
115 bool CreateReferenceLine(std::list<ReferenceLine>* reference_lines,
116 std::list<hdmap::RouteSegments>* segments);
117
122 void UpdateReferenceLine(
123 const std::list<ReferenceLine>& reference_lines,
124 const std::list<hdmap::RouteSegments>& route_segments);
125
126 void GenerateThread();
127 void IsValidReferenceLine();
128 void PrioritizeChangeLane(std::list<hdmap::RouteSegments>* route_segments);
129
130 bool CreateRouteSegments(const common::VehicleState& vehicle_state,
131 std::list<hdmap::RouteSegments>* segments);
132
133 bool IsReferenceLineSmoothValid(const ReferenceLine& raw,
134 const ReferenceLine& smoothed) const;
135
136 bool SmoothReferenceLine(const ReferenceLine& raw_reference_line,
137 ReferenceLine* reference_line);
138
139 bool SmoothPrefixedReferenceLine(const ReferenceLine& prefix_ref,
140 const ReferenceLine& raw_ref,
141 ReferenceLine* reference_line);
142
143 void GetAnchorPoints(const ReferenceLine& reference_line,
144 std::vector<AnchorPoint>* anchor_points) const;
145
146 bool SmoothRouteSegment(const hdmap::RouteSegments& segments,
147 ReferenceLine* reference_line);
148
153 bool ExtendReferenceLine(const common::VehicleState& state,
154 hdmap::RouteSegments* segments,
155 ReferenceLine* reference_line);
156
157 AnchorPoint GetAnchorPoint(const ReferenceLine& reference_line,
158 double s) const;
159
160 bool GetReferenceLinesFromRelativeMap(
161 std::list<ReferenceLine>* reference_lines,
162 std::list<hdmap::RouteSegments>* segments);
163
168 bool GetNearestWayPointFromNavigationPath(
169 const common::VehicleState& state,
170 const std::unordered_set<std::string>& navigation_lane_ids,
171 hdmap::LaneWaypoint* waypoint);
172
173 bool Shrink(const common::SLPoint& sl, ReferenceLine* ref,
174 hdmap::RouteSegments* segments);
175
176 private:
177 bool is_initialized_ = false;
178 std::atomic<bool> is_stop_{false};
179
180 std::unique_ptr<ReferenceLineSmoother> smoother_;
181 ReferenceLineSmootherConfig smoother_config_;
182
183 std::mutex pnc_map_mutex_;
184 // The loaded pnc map plugin which can create referene line from
185 // PlanningCommand.
186 std::vector<std::shared_ptr<planning::PncMapBase>> pnc_map_list_;
187 std::shared_ptr<planning::PncMapBase> current_pnc_map_;
188
189 // Used in Navigation mode
190 std::shared_ptr<relative_map::MapMsg> relative_map_;
191
192 std::mutex vehicle_state_mutex_;
193 common::VehicleState vehicle_state_;
194
195 std::mutex routing_mutex_;
196 planning::PlanningCommand planning_command_;
197 bool has_planning_command_ = false;
198 bool is_new_command_ = false;
199
200 std::mutex reference_lines_mutex_;
201 std::list<ReferenceLine> reference_lines_;
202 std::list<hdmap::RouteSegments> route_segments_;
203 double last_calculation_time_ = 0.0;
204
205 std::queue<std::list<ReferenceLine>> reference_line_history_;
206 std::queue<std::list<hdmap::RouteSegments>> route_segments_history_;
207
208 std::future<void> task_future_;
209
210 std::atomic<bool> is_reference_line_updated_{true};
211
212 const common::VehicleStateProvider* vehicle_state_provider_ = nullptr;
213};
214
215} // namespace planning
216} // namespace apollo
The class of ReferenceLineProvider.
bool GetReferenceLines(std::list< ReferenceLine > *reference_lines, std::list< hdmap::RouteSegments > *segments)
void UpdateVehicleState(const common::VehicleState &vehicle_state)
void GetEndLaneWayPoint(std::shared_ptr< routing::LaneWaypoint > &end_point) const
bool GetAdcWaypoint(hdmap::LaneWaypoint *waypoint) const
bool UpdatePlanningCommand(const planning::PlanningCommand &command)
Update when new PlanningCommand is received.
hdmap::LaneInfoConstPtr GetLaneById(const hdmap::Id &id) const
std::vector< routing::LaneWaypoint > FutureRouteWaypoints()
Planning module main class.
Defines the Factory class.
Some util functions.
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
class register implement
Definition arena_queue.h:37