Apollo 11.0
自动驾驶开放平台
reference_line_info.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 <limits>
24#include <list>
25#include <memory>
26#include <string>
27#include <unordered_map>
28#include <utility>
29#include <vector>
30
31#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
32#include "modules/common_msgs/basic_msgs/drive_state.pb.h"
33#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
34#include "modules/common_msgs/planning_msgs/planning.pb.h"
35#include "modules/planning/planning_base/proto/lattice_structure.pb.h"
36
48
49namespace apollo {
50namespace planning {
51
57 public:
59 ReferenceLineInfo() = default;
60
62 const common::TrajectoryPoint& adc_planning_point,
64 const hdmap::RouteSegments& segments);
65
66 bool Init(const std::vector<const Obstacle*>& obstacles, double target_speed);
67
68 bool AddObstacles(const std::vector<const Obstacle*>& obstacles);
69 Obstacle* AddObstacle(const Obstacle* obstacle);
70
71 const common::VehicleState& vehicle_state() const { return vehicle_state_; }
72
74 const PathDecision& path_decision() const;
75
76 const ReferenceLine& reference_line() const;
78
79 double SDistanceToDestination() const;
80 double SDistanceToRefEnd() const;
81
82 bool ReachedDestination() const;
83
85 const DiscretizedTrajectory& trajectory() const;
86
87 double Cost() const { return cost_; }
88 void AddCost(double cost) { cost_ += cost; }
89 void SetCost(double cost) { cost_ = cost; }
90 double PriorityCost() const { return priority_cost_; }
91 void SetPriorityCost(double cost) { priority_cost_ = cost; }
92 // For lattice planner'speed planning target
93 void SetLatticeStopPoint(const StopPoint& stop_point);
94 void SetLatticeCruiseSpeed(double speed);
95 const PlanningTarget& planning_target() const { return planning_target_; }
96
97 void SetCruiseSpeed(double speed) {
98 cruise_speed_ = speed;
99 base_cruise_speed_ = speed;
100 }
106 void LimitCruiseSpeed(double speed);
107
108 double GetBaseCruiseSpeed() const;
109
110 double GetCruiseSpeed() const;
111
112 hdmap::LaneInfoConstPtr LocateLaneInfo(const double s) const;
113
115 const double s, hdmap::Id* ptr_lane_id,
116 double* ptr_lane_width) const;
117
125 bool IsStartFrom(const ReferenceLineInfo& previous_reference_line_info) const;
126
128 const planning_internal::Debug& debug() const { return debug_; }
129 LatencyStats* mutable_latency_stats() { return &latency_stats_; }
130 const LatencyStats& latency_stats() const { return latency_stats_; }
131
132 const PathData& path_data() const;
133 const PathData& fallback_path_data() const;
134 const SpeedData& speed_data() const;
138
139 const RSSInfo& rss_info() const;
141 // aggregate final result together by some configuration
143 const double relative_time, const double start_s,
144 DiscretizedTrajectory* discretized_trajectory);
145
146 // adjust trajectory if it starts from cur_vehicle postion rather planning
147 // init point from upstream
149 const common::TrajectoryPoint& planning_start_point,
150 const std::vector<common::TrajectoryPoint>& trajectory,
151 DiscretizedTrajectory* adjusted_trajectory);
152
153 const SLBoundary& AdcSlBoundary() const;
154 std::string PathSpeedDebugString() const;
156
161 bool IsChangeLanePath() const;
162
167 bool IsNeighborLanePath() const;
168
173 void SetDrivable(bool drivable);
174 bool IsDrivable() const;
175
176 void ExportEngageAdvice(common::EngageAdvice* engage_advice,
177 PlanningContext* planning_context) const;
178
179 const hdmap::RouteSegments& Lanes() const;
180 std::list<hdmap::Id> TargetLaneId() const;
181
182 void ExportDecision(DecisionResult* decision_result,
183 PlanningContext* planning_context) const;
184
185 void SetJunctionRightOfWay(const double junction_s,
186 const bool is_protected) const;
187
189
190 hdmap::Lane::LaneTurn GetPathTurnType(const double s) const;
191
193 const hdmap::PathOverlap& pnc_junction_overlap) const;
194
196 return offset_to_other_reference_line_;
197 }
198 void SetOffsetToOtherReferenceLine(const double offset) {
199 offset_to_other_reference_line_ = offset;
200 }
201
202 const std::vector<PathBoundary>& GetCandidatePathBoundaries() const;
203
205 std::vector<PathBoundary>&& candidate_path_boundaries);
206
207 const std::vector<PathData>& GetCandidatePathData() const;
208 std::vector<PathData>* MutableCandidatePathData();
209 void SetCandidatePathData(std::vector<PathData>&& candidate_path_data);
210
211 Obstacle* GetBlockingObstacle() const { return blocking_obstacle_; }
212 void SetBlockingObstacle(const std::string& blocking_obstacle_id);
213
214 bool is_path_lane_borrow() const { return is_path_lane_borrow_; }
216 is_path_lane_borrow_ = is_path_lane_borrow;
217 }
218
219 void set_is_on_reference_line() { is_on_reference_line_ = true; }
220
221 uint32_t GetPriority() const { return reference_line_.GetPriority(); }
222
223 void SetPriority(uint32_t priority) { reference_line_.SetPriority(priority); }
224
229
231 return trajectory_type_;
232 }
233
234 StGraphData* mutable_st_graph_data() { return &st_graph_data_; }
235
236 const StGraphData& st_graph_data() { return st_graph_data_; }
237
238 // different types of overlaps that can be handled by different scenarios.
250
251 const std::vector<std::pair<OverlapType, hdmap::PathOverlap>>&
253 return first_encounter_overlaps_;
254 }
255
256 int GetPnCJunction(const double s,
257 hdmap::PathOverlap* pnc_junction_overlap) const;
258 int GetJunction(const double s, hdmap::PathOverlap* junction_overlap) const;
259 int GetArea(const double s, hdmap::PathOverlap* area_overlap) const;
260 std::vector<common::SLPoint> GetAllStopDecisionSLPoint() const;
261
262 void SetTurnSignal(const common::VehicleSignal::TurnSignal& turn_signal);
263 void SetEmergencyLight();
264
266 path_reusable_ = path_reusable;
267 }
268
269 bool path_reusable() const { return path_reusable_; }
271 const std::string& overlap_id, const OverlapType& overlap_type) const;
272
273 void set_key(std::size_t key) { key_ = key; }
274 std::size_t key() const { return key_; }
275
276 void set_index(std::size_t index) { index_ = index; }
277 std::size_t index() const { return index_; }
278
279 void set_id(std::string id) { id_ = id; }
280 std::string id() const { return id_; }
281
282 void GetRangeOverlaps(std::vector<hdmap::PathOverlap>* path_overlaps,
283 double start_s, double end_s);
284
285 const std::vector<double>& reference_line_towing_l() const;
286 std::vector<double>* mutable_reference_line_towing_l();
289
290 const std::vector<SLPolygon>& obs_sl_polygons() const;
291 std::vector<SLPolygon>* mutable_obs_sl_polygons();
292
293 private:
294 void InitFirstOverlaps();
295
296 bool CheckChangeLane() const;
297
298 void SetTurnSignalBasedOnLaneTurnType(
299 common::VehicleSignal* vehicle_signal) const;
300
301 void ExportVehicleSignal(common::VehicleSignal* vehicle_signal) const;
302
303 bool IsIrrelevantObstacle(const Obstacle& obstacle);
304
305 void MakeDecision(DecisionResult* decision_result,
306 PlanningContext* planning_context) const;
307
308 int MakeMainStopDecision(DecisionResult* decision_result) const;
309
310 void MakeMainMissionCompleteDecision(DecisionResult* decision_result,
311 PlanningContext* planning_context) const;
312
313 void MakeEStopDecision(DecisionResult* decision_result) const;
314
315 void SetObjectDecisions(ObjectDecisions* object_decisions) const;
316
317 bool AddObstacleHelper(const std::shared_ptr<Obstacle>& obstacle);
318
319 bool GetFirstOverlap(const std::vector<hdmap::PathOverlap>& path_overlaps,
320 hdmap::PathOverlap* path_overlap);
321
322 bool IsEgoOnRoutingLane() const;
323
324 private:
325 static std::unordered_map<std::string, bool> junction_right_of_way_map_;
326 const common::VehicleState vehicle_state_;
327 const common::TrajectoryPoint adc_planning_point_;
328 ReferenceLine reference_line_;
329
334 double cost_ = 0.0;
335
336 bool is_drivable_ = true;
337
338 PathDecision path_decision_;
339
340 Obstacle* blocking_obstacle_ = nullptr;
341
342 std::vector<PathBoundary> candidate_path_boundaries_;
343 std::vector<PathData> candidate_path_data_;
344
345 std::vector<double> reference_line_towing_l_;
346 PathBoundary reference_line_towing_path_boundary_;
347
348 PathData path_data_;
349 PathData fallback_path_data_;
350 SpeedData speed_data_;
351
352 DiscretizedTrajectory discretized_trajectory_;
353
354 RSSInfo rss_info_;
355
360 SLBoundary adc_sl_boundary_;
361
363 LatencyStats latency_stats_;
364
366
367 bool is_on_reference_line_ = false;
368
369 bool is_path_lane_borrow_ = false;
370
372
373 double offset_to_other_reference_line_ = 0.0;
374
375 double priority_cost_ = 0.0;
376
377 PlanningTarget planning_target_;
378
380
385 std::vector<std::pair<OverlapType, hdmap::PathOverlap>>
386 first_encounter_overlaps_;
387
392 StGraphData st_graph_data_;
393
394 common::VehicleSignal vehicle_signal_;
395
396 double cruise_speed_ = 0.0;
397 double base_cruise_speed_ = 0.0;
398
399 bool path_reusable_ = false;
400 std::string id_ = "";
401 std::size_t key_ = 0;
402 std::size_t index_ = 0;
403 std::vector<SLPolygon> obs_sl_polygons_;
404
406};
407
408} // namespace planning
409} // namespace apollo
This is the class that associates an Obstacle with its path properties.
Definition obstacle.h:62
PathDecision represents all obstacle decisions on one path.
ReferenceLineInfo holds all data for one reference line.
void SetBlockingObstacle(const std::string &blocking_obstacle_id)
std::list< hdmap::Id > TargetLaneId() const
std::vector< double > * mutable_reference_line_towing_l()
void GetRangeOverlaps(std::vector< hdmap::PathOverlap > *path_overlaps, double start_s, double end_s)
const PathBoundary & reference_line_towing_path_boundary() const
void SetCandidatePathData(std::vector< PathData > &&candidate_path_data)
void SetTrajectory(const DiscretizedTrajectory &trajectory)
const std::vector< SLPolygon > & obs_sl_polygons() const
void set_is_path_lane_borrow(const bool is_path_lane_borrow)
void SetLatticeStopPoint(const StopPoint &stop_point)
const common::VehicleState & vehicle_state() const
bool GetNeighborLaneInfo(const ReferenceLineInfo::LaneType lane_type, const double s, hdmap::Id *ptr_lane_id, double *ptr_lane_width) const
const LatencyStats & latency_stats() const
int GetJunction(const double s, hdmap::PathOverlap *junction_overlap) const
const std::vector< PathData > & GetCandidatePathData() const
hdmap::Lane::LaneTurn GetPathTurnType(const double s) const
void set_trajectory_type(const ADCTrajectory::TrajectoryType trajectory_type)
void SetDrivable(bool drivable)
Set if the vehicle can drive following this reference line A planner need to set this value to true i...
const std::vector< PathBoundary > & GetCandidatePathBoundaries() const
bool AddObstacles(const std::vector< const Obstacle * > &obstacles)
bool CombinePathAndSpeedProfile(const double relative_time, const double start_s, DiscretizedTrajectory *discretized_trajectory)
bool IsNeighborLanePath() const
Check if the current reference line is the neighbor of the vehicle current position
void ExportDecision(DecisionResult *decision_result, PlanningContext *planning_context) const
const std::vector< double > & reference_line_towing_l() const
bool GetIntersectionRightofWayStatus(const hdmap::PathOverlap &pnc_junction_overlap) const
std::vector< SLPolygon > * mutable_obs_sl_polygons()
const PlanningTarget & planning_target() const
void LimitCruiseSpeed(double speed)
Limit the cruise speed based on the "base_cruise_speed_".
void SetTurnSignal(const common::VehicleSignal::TurnSignal &turn_signal)
bool IsStartFrom(const ReferenceLineInfo &previous_reference_line_info) const
check if current reference line is started from another reference line info line.
const planning_internal::Debug & debug() const
const hdmap::RouteSegments & Lanes() const
bool Init(const std::vector< const Obstacle * > &obstacles, double target_speed)
ADCTrajectory::RightOfWayStatus GetRightOfWayStatus() const
const ReferenceLine & reference_line() const
std::vector< common::SLPoint > GetAllStopDecisionSLPoint() const
hdmap::PathOverlap * GetOverlapOnReferenceLine(const std::string &overlap_id, const OverlapType &overlap_type) const
const PathData & fallback_path_data() const
void SetCandidatePathBoundaries(std::vector< PathBoundary > &&candidate_path_boundaries)
const std::vector< std::pair< OverlapType, hdmap::PathOverlap > > & FirstEncounteredOverlaps() const
void set_path_reusable(const bool path_reusable)
void ExportEngageAdvice(common::EngageAdvice *engage_advice, PlanningContext *planning_context) const
const DiscretizedTrajectory & trajectory() const
Obstacle * AddObstacle(const Obstacle *obstacle)
planning_internal::Debug * mutable_debug()
hdmap::LaneInfoConstPtr LocateLaneInfo(const double s) const
std::vector< PathData > * MutableCandidatePathData()
const SLBoundary & AdcSlBoundary() const
int GetArea(const double s, hdmap::PathOverlap *area_overlap) const
void SetJunctionRightOfWay(const double junction_s, const bool is_protected) const
bool AdjustTrajectoryWhichStartsFromCurrentPos(const common::TrajectoryPoint &planning_start_point, const std::vector< common::TrajectoryPoint > &trajectory, DiscretizedTrajectory *adjusted_trajectory)
ADCTrajectory::TrajectoryType trajectory_type() const
void SetOffsetToOtherReferenceLine(const double offset)
bool IsChangeLanePath() const
Check if the current reference line is a change lane reference line, i.e., ADC's current position is ...
int GetPnCJunction(const double s, hdmap::PathOverlap *pnc_junction_overlap) const
void SetPriority(uint32_t priority)
Planning module main class.
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
class register implement
Definition arena_queue.h:37
: data with map info and obstacle info