Apollo 10.0
自动驾驶开放平台
path_time_heuristic_optimizer.cc
浏览该文件的文档.
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
22
28
29namespace apollo {
30namespace planning {
31
34
36 const std::string& config_dir, const std::string& name,
37 const std::shared_ptr<DependencyInjector>& injector) {
38 if (!SpeedOptimizer::Init(config_dir, name, injector)) {
39 return false;
40 }
41 // Load the config_ this task.
42 return SpeedOptimizer::LoadConfig<SpeedHeuristicOptimizerConfig>(&config_);
43}
44
45bool PathTimeHeuristicOptimizer::SearchPathTimeGraph(
46 SpeedData* speed_data) const {
47 const auto& dp_st_speed_optimizer_config =
49 ? config_.lane_change_speed_config()
50 : config_.default_speed_config();
51
52 GriddedPathTimeGraph st_graph(
53 reference_line_info_->st_graph_data(), dp_st_speed_optimizer_config,
55
56 if (!st_graph.Search(speed_data).ok()) {
57 AERROR << "failed to search graph with dynamic programming.";
58 return false;
59 }
60 return true;
61}
62
63Status PathTimeHeuristicOptimizer::Process(
64 const PathData& path_data, const common::TrajectoryPoint& init_point,
65 SpeedData* const speed_data) {
66 init_point_ = init_point;
67
68 if (path_data.discretized_path().empty()) {
69 const std::string msg = "Empty path data";
70 AERROR << msg;
71 return Status(ErrorCode::PLANNING_ERROR, msg);
72 }
73
74 if (!SearchPathTimeGraph(speed_data)) {
75 const std::string msg = absl::StrCat(
76 Name(), ": Failed to search graph with dynamic programming.");
77 AERROR << msg;
80 return Status(ErrorCode::PLANNING_ERROR, msg);
81 }
83 *speed_data,
85 return Status::OK();
86}
87
88} // namespace planning
89} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
const std::vector< const T * > & Items() const
List all the items in the container.
const IndexedList< std::string, Obstacle > & obstacles() const
bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector) override
bool IsChangeLanePath() const
Check if the current reference line is a change lane reference line, i.e., ADC's current position is ...
void RecordDebugInfo(const SpeedData &speed_data)
planning_internal::STGraphDebug * mutable_st_graph_debug()
const std::string & Name() const
Definition task.cc:58
ReferenceLineInfo * reference_line_info_
Definition task.h:58
virtual bool Init(const std::string &config_dir, const std::string &name, const std::shared_ptr< DependencyInjector > &injector)
Definition task.cc:40
Planning module main class.
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37
: data with map info and obstacle info
optional DpStSpeedOptimizerConfig lane_change_speed_config
optional DpStSpeedOptimizerConfig default_speed_config