Apollo  6.0
Open source self driving car software
gridded_path_time_graph.h
Go to the documentation of this file.
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 <memory>
24 #include <vector>
25 
26 #include "modules/common/configs/proto/vehicle_config.pb.h"
35 #include "modules/planning/proto/planning_config.pb.h"
36 #include "modules/planning/proto/task_config.pb.h"
39 
40 namespace apollo {
41 namespace planning {
42 
44  public:
45  GriddedPathTimeGraph(const StGraphData& st_graph_data,
46  const DpStSpeedOptimizerConfig& dp_config,
47  const std::vector<const Obstacle*>& obstacles,
48  const common::TrajectoryPoint& init_point);
49 
50  common::Status Search(SpeedData* const speed_data);
51 
52  private:
53  common::Status InitCostTable();
54 
55  common::Status InitSpeedLimitLookUp();
56 
57  common::Status RetrieveSpeedProfile(SpeedData* const speed_data);
58 
59  common::Status CalculateTotalCost();
60 
61  // defined for cyber task
62  struct StGraphMessage {
63  StGraphMessage(const uint32_t c_, const int32_t r_) : c(c_), r(r_) {}
64  uint32_t c;
65  uint32_t r;
66  };
67  void CalculateCostAt(const std::shared_ptr<StGraphMessage>& msg);
68 
69  double CalculateEdgeCost(const STPoint& first, const STPoint& second,
70  const STPoint& third, const STPoint& forth,
71  const double speed_limit, const double cruise_speed);
72  double CalculateEdgeCostForSecondCol(const uint32_t row,
73  const double speed_limit,
74  const double cruise_speed);
75  double CalculateEdgeCostForThirdCol(const uint32_t curr_row,
76  const uint32_t pre_row,
77  const double speed_limit,
78  const double cruise_speed);
79 
80  // get the row-range of next time step
81  void GetRowRange(const StGraphPoint& point, size_t* next_highest_row,
82  size_t* next_lowest_row);
83 
84  private:
85  const StGraphData& st_graph_data_;
86 
87  std::vector<double> speed_limit_by_index_;
88 
89  std::vector<double> spatial_distance_by_index_;
90 
91  // dp st configuration
92  DpStSpeedOptimizerConfig gridded_path_time_graph_config_;
93 
94  // obstacles based on the current reference line
95  const std::vector<const Obstacle*>& obstacles_;
96 
97  // vehicle configuration parameter
98  const common::VehicleParam& vehicle_param_ =
100 
101  // initial status
102  common::TrajectoryPoint init_point_;
103 
104  // cost utility with configuration;
105  DpStCost dp_st_cost_;
106 
107  double total_length_t_ = 0.0;
108  double unit_t_ = 0.0;
109  uint32_t dimension_t_ = 0;
110 
111  double total_length_s_ = 0.0;
112  double dense_unit_s_ = 0.0;
113  double sparse_unit_s_ = 0.0;
114  uint32_t dense_dimension_s_ = 0;
115  uint32_t sparse_dimension_s_ = 0;
116  uint32_t dimension_s_ = 0;
117 
118  double max_acceleration_ = 0.0;
119  double max_deceleration_ = 0.0;
120 
121  // cost_table_[t][s]
122  // row: s, col: t --- NOTICE: Please do NOT change.
123  std::vector<std::vector<StGraphPoint>> cost_table_;
124 };
125 
126 } // namespace planning
127 } // namespace apollo
GriddedPathTimeGraph(const StGraphData &st_graph_data, const DpStSpeedOptimizerConfig &dp_config, const std::vector< const Obstacle *> &obstacles, const common::TrajectoryPoint &init_point)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Planning module main class. It processes GPS and IMU as input, to generate planning info...
common::Status Search(SpeedData *const speed_data)
Definition: st_graph_point.h:30
Definition: gridded_path_time_graph.h:43
Definition: st_point.h:30
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
: data with map info and obstacle info
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
Definition: dp_st_cost.h:39
Definition: speed_data.h:30
Definition: st_graph_data.h:37