Apollo  6.0
Open source self driving car software
planning_component.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 
17 #pragma once
18 
19 #include <memory>
20 
24 #include "modules/canbus/proto/chassis.pb.h"
25 #include "modules/localization/proto/localization.pb.h"
26 #include "modules/perception/proto/traffic_light_detection.pb.h"
30 #include "modules/planning/proto/learning_data.pb.h"
31 #include "modules/planning/proto/pad_msg.pb.h"
32 #include "modules/planning/proto/planning.pb.h"
33 #include "modules/planning/proto/planning_config.pb.h"
34 #include "modules/prediction/proto/prediction_obstacle.pb.h"
35 #include "modules/routing/proto/routing.pb.h"
36 #include "modules/storytelling/proto/story.pb.h"
37 
38 namespace apollo {
39 namespace planning {
40 
41 class PlanningComponent final
42  : public cyber::Component<prediction::PredictionObstacles, canbus::Chassis,
43  localization::LocalizationEstimate> {
44  public:
45  PlanningComponent() = default;
46 
47  ~PlanningComponent() = default;
48 
49  public:
50  bool Init() override;
51 
52  bool Proc(const std::shared_ptr<prediction::PredictionObstacles>&
53  prediction_obstacles,
54  const std::shared_ptr<canbus::Chassis>& chassis,
55  const std::shared_ptr<localization::LocalizationEstimate>&
56  localization_estimate) override;
57 
58  private:
59  void CheckRerouting();
60  bool CheckInput();
61 
62  private:
63  std::shared_ptr<cyber::Reader<perception::TrafficLightDetection>>
64  traffic_light_reader_;
65  std::shared_ptr<cyber::Reader<routing::RoutingResponse>> routing_reader_;
66  std::shared_ptr<cyber::Reader<planning::PadMessage>> pad_msg_reader_;
67  std::shared_ptr<cyber::Reader<relative_map::MapMsg>> relative_map_reader_;
68  std::shared_ptr<cyber::Reader<storytelling::Stories>> story_telling_reader_;
69 
70  std::shared_ptr<cyber::Writer<ADCTrajectory>> planning_writer_;
71  std::shared_ptr<cyber::Writer<routing::RoutingRequest>> rerouting_writer_;
72  std::shared_ptr<cyber::Writer<PlanningLearningData>>
73  planning_learning_data_writer_;
74 
75  std::mutex mutex_;
76  perception::TrafficLightDetection traffic_light_;
77  routing::RoutingResponse routing_;
78  planning::PadMessage pad_msg_;
79  relative_map::MapMsg relative_map_;
80  storytelling::Stories stories_;
81 
82  LocalView local_view_;
83 
84  std::unique_ptr<PlanningBase> planning_base_;
85  std::shared_ptr<DependencyInjector> injector_;
86 
87  PlanningConfig config_;
88  MessageProcess message_process_;
89 };
90 
92 
93 } // namespace planning
94 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: planning_component.h:41
Planning module main class. It processes GPS and IMU as input, to generate planning info...
Definition: message_process.h:47
bool Proc(const std::shared_ptr< prediction::PredictionObstacles > &prediction_obstacles, const std::shared_ptr< canbus::Chassis > &chassis, const std::shared_ptr< localization::LocalizationEstimate > &localization_estimate) override
#define CYBER_REGISTER_COMPONENT(name)
Definition: component.h:551
Definition: local_view.h:38
The Component can process up to four channels of messages. The message type is specified when the com...
Definition: component.h:58