Apollo 10.0
自动驾驶开放平台
scenario.h
浏览该文件的文档.
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
21#pragma once
22
23#include <memory>
24#include <string>
25#include <unordered_map>
26
27#include "modules/planning/planning_interface_base/scenario_base/proto/scenario_pipeline.pb.h"
28
29#include "cyber/common/file.h"
32
33namespace apollo {
34namespace common {
35class TrajectoryPoint;
36} // namespace common
37} // namespace apollo
38
39namespace apollo {
40namespace planning {
41
42class Frame;
43
45 public:
47};
48
49class Stage;
50class DependencyInjector;
51
52class Scenario {
53 public:
54 Scenario();
55
56 virtual ~Scenario() = default;
57
58 virtual bool Init(std::shared_ptr<DependencyInjector> injector,
59 const std::string& name);
60
65
70 virtual bool IsTransferable(const Scenario* other_scenario,
71 const Frame& frame) {
72 return false;
73 }
74
75 virtual ScenarioResult Process(
76 const common::TrajectoryPoint& planning_init_point, Frame* frame);
77
78 virtual bool Exit(Frame* frame) { return true; }
79
80 virtual bool Enter(Frame* frame) { return true; }
81
88 std::shared_ptr<Stage> CreateStage(const StagePipeline& stage_pipeline);
89
93
94 const std::string GetStage() const;
95
96 const std::string& GetMsg() const { return msg_; }
97
98 const std::string& Name() const { return name_; }
99
103 void Reset();
104
105 protected:
106 template <typename T>
107 bool LoadConfig(T* config);
108
110 std::shared_ptr<Stage> current_stage_;
111 std::unordered_map<std::string, const StagePipeline*> stage_pipeline_map_;
112 std::string msg_; // debug msg
113 std::shared_ptr<DependencyInjector> injector_;
114
115 std::string config_path_;
116 std::string config_dir_;
117 std::string name_;
119};
120
121template <typename T>
122bool Scenario::LoadConfig(T* config) {
123 return apollo::cyber::common::LoadConfig<T>(config_path_, config);
124}
125
126} // namespace planning
127} // namespace apollo
Frame holds all data for one planning cycle.
Definition frame.h:62
const ScenarioStatusType & GetScenarioStatus() const
Get the scenario status.
const std::string & GetMsg() const
Definition scenario.h:96
std::shared_ptr< Stage > current_stage_
Definition scenario.h:110
virtual ScenarioResult Process(const common::TrajectoryPoint &planning_init_point, Frame *frame)
Definition scenario.cc:86
virtual bool Init(std::shared_ptr< DependencyInjector > injector, const std::string &name)
Definition scenario.cc:43
const std::string GetStage() const
Definition scenario.cc:170
virtual ScenarioContext * GetContext()=0
Get the scenario context.
void Reset()
Reset the scenario, used before entering the scenario.
Definition scenario.cc:174
virtual bool IsTransferable(const Scenario *other_scenario, const Frame &frame)
Each scenario should define its own transfer condition, i.e., when it should allow to transfer from o...
Definition scenario.h:70
virtual bool Enter(Frame *frame)
Definition scenario.h:80
const ScenarioStatusType & GetStatus() const
Definition scenario.h:90
virtual ~Scenario()=default
std::unordered_map< std::string, const StagePipeline * > stage_pipeline_map_
Definition scenario.h:111
std::shared_ptr< Stage > CreateStage(const StagePipeline &stage_pipeline)
Each scenario should define its own stages object's creation scenario will call stage's Stage::Proces...
Definition scenario.cc:155
virtual bool Exit(Frame *frame)
Definition scenario.h:78
bool LoadConfig(T *config)
Definition scenario.h:122
ScenarioResult scenario_result_
Definition scenario.h:109
std::shared_ptr< DependencyInjector > injector_
Definition scenario.h:113
ScenarioPipeline scenario_pipeline_config_
Definition scenario.h:118
const std::string & Name() const
Definition scenario.h:98
Planning module main class.
class register implement
Definition arena_queue.h:37