Apollo  6.0
Open source self driving car software
navi_speed_decider.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 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 
22 #pragma once
23 
24 #include <string>
25 #include <vector>
26 
27 #include "gtest/gtest.h"
33 #include "modules/planning/proto/planning_config.pb.h"
34 
39 namespace apollo {
40 namespace planning {
41 
50 class NaviSpeedDecider : public NaviTask {
51  public:
53  virtual ~NaviSpeedDecider() = default;
54 
55  bool Init(const PlanningConfig& config) override;
56 
65  Frame* frame, ReferenceLineInfo* reference_line_info) override;
66 
67  private:
79  apollo::common::Status MakeSpeedDecision(
80  double start_v, double start_a, double start_da,
81  const std::vector<common::PathPoint>& path_points,
82  const std::vector<const Obstacle*>& obstacles,
83  const std::function<const Obstacle*(const std::string& id)>&
84  find_obstacle,
85  SpeedData* const speed_data);
86 
91  apollo::common::Status AddPerceptionRangeConstraints();
92 
102  apollo::common::Status AddObstaclesConstraints(
103  double vehicle_speed, double path_length,
104  const std::vector<common::PathPoint>& path_points,
105  const std::vector<const Obstacle*>& obstacles,
106  const std::function<const Obstacle*(const std::string& id)>&
107  find_obstacle);
108 
113  apollo::common::Status AddTrafficDecisionConstraints();
114 
120  apollo::common::Status AddCentricAccelerationConstraints(
121  const std::vector<common::PathPoint>& path_points);
122 
127  apollo::common::Status AddConfiguredConstraints();
128 
129  void RecordDebugInfo(const SpeedData& speed_data);
130 
131  private:
132  double preferred_speed_;
133  double max_speed_;
134  double preferred_accel_;
135  double preferred_decel_;
136  double preferred_jerk_;
137  double max_accel_;
138  double max_decel_;
139  double obstacle_buffer_;
140  double safe_distance_base_;
141  double safe_distance_ratio_;
142  double following_accel_ratio_;
143  double soft_centric_accel_limit_;
144  double hard_centric_accel_limit_;
145  double hard_speed_limit_;
146  double hard_accel_limit_;
147  bool enable_safe_path_;
148  bool enable_planning_start_point_;
149  bool enable_accel_auto_compensation_;
150  double kappa_preview_;
151  double kappa_threshold_;
152 
153  NaviObstacleDecider obstacle_decider_;
154  NaviSpeedTsGraph ts_graph_;
155 
156  double prev_v_ = 0.0;
157  double accel_compensation_ratio_ = 1.0;
158  double decel_compensation_ratio_ = 1.0;
159 
160  FRIEND_TEST(NaviSpeedDeciderTest, CreateSpeedData);
161  FRIEND_TEST(NaviSpeedDeciderTest, CreateSpeedDataForStaticObstacle);
162  FRIEND_TEST(NaviSpeedDeciderTest, CreateSpeedDataForObstacles);
163  FRIEND_TEST(NaviSpeedDeciderTest, CreateSpeedDataForCurve);
164 };
165 
166 } // namespace planning
167 } // namespace apollo
apollo::common::Status Execute(Frame *frame, ReferenceLineInfo *reference_line_info) override
Overrided implementation of the virtual function "Execute" in the base class "Task".
This is the class that associates an Obstacle with its path properties. An obstacle&#39;s path properties...
Definition: obstacle.h:60
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...
Frame holds all data for one planning cycle.
Definition: frame.h:61
ReferenceLineInfo holds all data for one reference line.
Definition: reference_line_info.h:54
Definition: navi_task.h:33
bool Init(const PlanningConfig &config) override
NaviSpeedTsGraph is used to generate a t-s graph with some limits and preferred.
Definition: navi_speed_ts_graph.h:78
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
NaviSpeedDecider is used to generate an appropriate speed curve of the vehicle in navigation mode...
Definition: navi_speed_decider.h:50
NaviObstacleDecider is used to make appropriate decisions for obstacles around the vehicle in navigat...
Definition: navi_obstacle_decider.h:51
Definition: speed_data.h:30