Apollo 10.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
47
48namespace apollo {
49namespace planning {
50
56 public:
58 ReferenceLineInfo() = default;
59
61 const common::TrajectoryPoint& adc_planning_point,
63 const hdmap::RouteSegments& segments);
64
65 bool Init(const std::vector<const Obstacle*>& obstacles, double target_speed);
66
67 bool AddObstacles(const std::vector<const Obstacle*>& obstacles);
68 Obstacle* AddObstacle(const Obstacle* obstacle);
69
70 const common::VehicleState& vehicle_state() const { return vehicle_state_; }
71
73 const PathDecision& path_decision() const;
74
75 const ReferenceLine& reference_line() const;
77
78 double SDistanceToDestination() const;
79 double SDistanceToRefEnd() const;
80
81 bool ReachedDestination() const;
82
84 const DiscretizedTrajectory& trajectory() const;
85
86 double Cost() const { return cost_; }
87 void AddCost(double cost) { cost_ += cost; }
88 void SetCost(double cost) { cost_ = cost; }
89 double PriorityCost() const { return priority_cost_; }
90 void SetPriorityCost(double cost) { priority_cost_ = cost; }
91 // For lattice planner'speed planning target
92 void SetLatticeStopPoint(const StopPoint& stop_point);
93 void SetLatticeCruiseSpeed(double speed);
94 const PlanningTarget& planning_target() const { return planning_target_; }
95
96 void SetCruiseSpeed(double speed) {
97 cruise_speed_ = speed;
98 base_cruise_speed_ = speed;
99 }
105 void LimitCruiseSpeed(double speed);
106
107 double GetBaseCruiseSpeed() const;
108
109 double GetCruiseSpeed() const;
110
111 hdmap::LaneInfoConstPtr LocateLaneInfo(const double s) const;
112
114 const double s, hdmap::Id* ptr_lane_id,
115 double* ptr_lane_width) const;
116
124 bool IsStartFrom(const ReferenceLineInfo& previous_reference_line_info) const;
125
127 const planning_internal::Debug& debug() const { return debug_; }
128 LatencyStats* mutable_latency_stats() { return &latency_stats_; }
129 const LatencyStats& latency_stats() const { return latency_stats_; }
130
131 const PathData& path_data() const;
132 const PathData& fallback_path_data() const;
133 const SpeedData& speed_data() const;
137
138 const RSSInfo& rss_info() const;
140 // aggregate final result together by some configuration
142 const double relative_time, const double start_s,
143 DiscretizedTrajectory* discretized_trajectory);
144
145 // adjust trajectory if it starts from cur_vehicle postion rather planning
146 // init point from upstream
148 const common::TrajectoryPoint& planning_start_point,
149 const std::vector<common::TrajectoryPoint>& trajectory,
150 DiscretizedTrajectory* adjusted_trajectory);
151
152 const SLBoundary& AdcSlBoundary() const;
153 std::string PathSpeedDebugString() const;
155
160 bool IsChangeLanePath() const;
161
166 bool IsNeighborLanePath() const;
167
172 void SetDrivable(bool drivable);
173 bool IsDrivable() const;
174
175 void ExportEngageAdvice(common::EngageAdvice* engage_advice,
176 PlanningContext* planning_context) const;
177
178 const hdmap::RouteSegments& Lanes() const;
179 std::list<hdmap::Id> TargetLaneId() const;
180
181 void ExportDecision(DecisionResult* decision_result,
182 PlanningContext* planning_context) const;
183
184 void SetJunctionRightOfWay(const double junction_s,
185 const bool is_protected) const;
186
188
189 hdmap::Lane::LaneTurn GetPathTurnType(const double s) const;
190
192 const hdmap::PathOverlap& pnc_junction_overlap) const;
193
195 return offset_to_other_reference_line_;
196 }
197 void SetOffsetToOtherReferenceLine(const double offset) {
198 offset_to_other_reference_line_ = offset;
199 }
200
201 const std::vector<PathBoundary>& GetCandidatePathBoundaries() const;
202
204 std::vector<PathBoundary>&& candidate_path_boundaries);
205
206 const std::vector<PathData>& GetCandidatePathData() const;
207 std::vector<PathData>* MutableCandidatePathData();
208 void SetCandidatePathData(std::vector<PathData>&& candidate_path_data);
209
210 Obstacle* GetBlockingObstacle() const { return blocking_obstacle_; }
211 void SetBlockingObstacle(const std::string& blocking_obstacle_id);
212
213 bool is_path_lane_borrow() const { return is_path_lane_borrow_; }
215 is_path_lane_borrow_ = is_path_lane_borrow;
216 }
217
218 void set_is_on_reference_line() { is_on_reference_line_ = true; }
219
220 uint32_t GetPriority() const { return reference_line_.GetPriority(); }
221
222 void SetPriority(uint32_t priority) { reference_line_.SetPriority(priority); }
223
228
230 return trajectory_type_;
231 }
232
233 StGraphData* mutable_st_graph_data() { return &st_graph_data_; }
234
235 const StGraphData& st_graph_data() { return st_graph_data_; }
236
237 // different types of overlaps that can be handled by different scenarios.
249
250 const std::vector<std::pair<OverlapType, hdmap::PathOverlap>>&
252 return first_encounter_overlaps_;
253 }
254
255 int GetPnCJunction(const double s,
256 hdmap::PathOverlap* pnc_junction_overlap) const;
257 int GetJunction(const double s, hdmap::PathOverlap* junction_overlap) const;
258 int GetArea(const double s, hdmap::PathOverlap* area_overlap) const;
259 std::vector<common::SLPoint> GetAllStopDecisionSLPoint() const;
260
261 void SetTurnSignal(const common::VehicleSignal::TurnSignal& turn_signal);
262 void SetEmergencyLight();
263
265 path_reusable_ = path_reusable;
266 }
267
268 bool path_reusable() const { return path_reusable_; }
270 const std::string& overlap_id, const OverlapType& overlap_type) const;
271
272 void set_key(std::size_t key) { key_ = key; }
273 std::size_t key() const { return key_; }
274
275 void set_index(std::size_t index) { index_ = index; }
276 std::size_t index() const { return index_; }
277
278 void set_id(std::string id) { id_ = id; }
279 std::string id() const { return id_; }
280
281 void GetRangeOverlaps(std::vector<hdmap::PathOverlap>* path_overlaps,
282 double start_s, double end_s);
283
284 const std::vector<double>& reference_line_towing_l() const;
285 std::vector<double>* mutable_reference_line_towing_l();
288
289 private:
290 void InitFirstOverlaps();
291
292 bool CheckChangeLane() const;
293
294 void SetTurnSignalBasedOnLaneTurnType(
295 common::VehicleSignal* vehicle_signal) const;
296
297 void ExportVehicleSignal(common::VehicleSignal* vehicle_signal) const;
298
299 bool IsIrrelevantObstacle(const Obstacle& obstacle);
300
301 void MakeDecision(DecisionResult* decision_result,
302 PlanningContext* planning_context) const;
303
304 int MakeMainStopDecision(DecisionResult* decision_result) const;
305
306 void MakeMainMissionCompleteDecision(DecisionResult* decision_result,
307 PlanningContext* planning_context) const;
308
309 void MakeEStopDecision(DecisionResult* decision_result) const;
310
311 void SetObjectDecisions(ObjectDecisions* object_decisions) const;
312
313 bool AddObstacleHelper(const std::shared_ptr<Obstacle>& obstacle);
314
315 bool GetFirstOverlap(const std::vector<hdmap::PathOverlap>& path_overlaps,
316 hdmap::PathOverlap* path_overlap);
317
318 bool IsEgoOnRoutingLane() const;
319
320 private:
321 static std::unordered_map<std::string, bool> junction_right_of_way_map_;
322 const common::VehicleState vehicle_state_;
323 const common::TrajectoryPoint adc_planning_point_;
324 ReferenceLine reference_line_;
325
330 double cost_ = 0.0;
331
332 bool is_drivable_ = true;
333
334 PathDecision path_decision_;
335
336 Obstacle* blocking_obstacle_ = nullptr;
337
338 std::vector<PathBoundary> candidate_path_boundaries_;
339 std::vector<PathData> candidate_path_data_;
340
341 std::vector<double> reference_line_towing_l_;
342 PathBoundary reference_line_towing_path_boundary_;
343
344 PathData path_data_;
345 PathData fallback_path_data_;
346 SpeedData speed_data_;
347
348 DiscretizedTrajectory discretized_trajectory_;
349
350 RSSInfo rss_info_;
351
356 SLBoundary adc_sl_boundary_;
357
359 LatencyStats latency_stats_;
360
362
363 bool is_on_reference_line_ = false;
364
365 bool is_path_lane_borrow_ = false;
366
368
369 double offset_to_other_reference_line_ = 0.0;
370
371 double priority_cost_ = 0.0;
372
373 PlanningTarget planning_target_;
374
376
381 std::vector<std::pair<OverlapType, hdmap::PathOverlap>>
382 first_encounter_overlaps_;
383
388 StGraphData st_graph_data_;
389
390 common::VehicleSignal vehicle_signal_;
391
392 double cruise_speed_ = 0.0;
393 double base_cruise_speed_ = 0.0;
394
395 bool path_reusable_ = false;
396 std::string id_ = "";
397 std::size_t key_ = 0;
398 std::size_t index_ = 0;
399
401};
402
403} // namespace planning
404} // 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)
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
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