Apollo 11.0
自动驾驶开放平台
planner.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
17#pragma once
18
19#include <memory>
20#include <string>
21
22#include <cxxabi.h>
23
24#include "modules/common_msgs/basic_msgs/pnc_point.pb.h"
25
26#include "cyber/common/file.h"
31
36namespace apollo {
37namespace planning {
38
45class Planner {
46 public:
50 virtual ~Planner() = default;
51
52 virtual std::string Name() = 0;
53
55 const std::shared_ptr<DependencyInjector>& injector,
56 const std::string& config_path = "") {
57 injector_ = injector;
58 return common::Status::OK();
59 }
60
68 const common::TrajectoryPoint& planning_init_point, Frame* frame,
69 ADCTrajectory* ptr_computed_trajectory) = 0;
70
71 virtual void Stop() = 0;
72
73 virtual void Reset(Frame* frame) {}
74
75 template <typename T>
76 bool LoadConfig(const std::string& custom_config_path, T* config);
77
78 protected:
79 std::shared_ptr<DependencyInjector> injector_ = nullptr;
80};
81
82template <typename T>
83bool Planner::LoadConfig(const std::string& custom_config_path, T* config) {
84 std::string config_path = custom_config_path;
85 // Get the default config file if "custom_config_path" is empty.
86 if ("" == config_path) {
87 int status;
88 // Get the name of this class.
89 std::string class_name =
90 abi::__cxa_demangle(typeid(*this).name(), 0, 0, &status);
93 class_name, "conf/planner_config.pb.txt");
94 }
95 return apollo::cyber::common::LoadConfig<T>(config_path, config);
96}
97
99 public:
103 virtual ~PlannerWithReferenceLine() = default;
104
113 const common::TrajectoryPoint& planning_init_point, Frame* frame,
114 ReferenceLineInfo* reference_line_info) {
115 CHECK_NOTNULL(frame);
117 }
118};
119
120} // namespace planning
121} // 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
std::string GetPluginConfPath(const std::string &class_name, const std::string &conf_name)
get plugin configuration file location
static PluginManager * Instance()
get singleton instance of PluginManager
Frame holds all data for one planning cycle.
Definition frame.h:62
virtual apollo::common::Status PlanOnReferenceLine(const common::TrajectoryPoint &planning_init_point, Frame *frame, ReferenceLineInfo *reference_line_info)
Compute a trajectory for execution.
Definition planner.h:112
virtual ~PlannerWithReferenceLine()=default
Destructor
Planner is a base class for specific planners.
Definition planner.h:45
bool LoadConfig(const std::string &custom_config_path, T *config)
Definition planner.h:83
virtual apollo::common::Status Plan(const common::TrajectoryPoint &planning_init_point, Frame *frame, ADCTrajectory *ptr_computed_trajectory)=0
Compute trajectories for execution.
virtual apollo::common::Status Init(const std::shared_ptr< DependencyInjector > &injector, const std::string &config_path="")
Definition planner.h:54
virtual ~Planner()=default
Destructor
std::shared_ptr< DependencyInjector > injector_
Definition planner.h:79
virtual std::string Name()=0
virtual void Reset(Frame *frame)
Definition planner.h:73
virtual void Stop()=0
ReferenceLineInfo holds all data for one reference line.
Planning module main class.
class register implement
Definition arena_queue.h:37