Apollo  6.0
Open source self driving car software
navi_planning.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 #include <string>
21 #include <utility>
22 #include <vector>
23 
28 #include "modules/planning/proto/pad_msg.pb.h"
29 
34 namespace apollo {
35 namespace planning {
36 
43 class NaviPlanning : public PlanningBase {
44  public:
45  explicit NaviPlanning(const std::shared_ptr<DependencyInjector>& injector)
46  : PlanningBase(injector) {
47  planner_dispatcher_ = std::make_unique<NaviPlannerDispatcher>();
48  }
49  virtual ~NaviPlanning();
50 
54  std::string Name() const override;
55 
60  apollo::common::Status Init(const PlanningConfig& config) override;
61 
66  void RunOnce(const LocalView& local_view,
67  ADCTrajectory* const trajectory_pb) override;
68 
70  const double current_time_stamp,
71  const std::vector<common::TrajectoryPoint>& stitching_trajectory,
72  ADCTrajectory* const trajectory) override;
73 
74  private:
75  common::Status InitFrame(const uint32_t sequence_num,
76  const common::TrajectoryPoint& planning_start_point,
77  const common::VehicleState& vehicle_state);
78 
79  bool CheckPlanningConfig(const PlanningConfig& config);
80 
84  void ProcessPadMsg(DrivingAction drvie_action);
85 
89  std::string GetCurrentLaneId();
90 
97  void GetLeftNeighborLanesInfo(
98  std::vector<std::pair<std::string, double>>* const lane_info_group);
99 
106  void GetRightNeighborLanesInfo(
107  std::vector<std::pair<std::string, double>>* const lane_info_group);
108 
109  void ExportReferenceLineDebug(planning_internal::Debug* debug);
110 
111  class VehicleConfig {
112  public:
113  double x_ = 0.0;
114  double y_ = 0.0;
115  double theta_ = 0.0;
116  bool is_valid_ = false;
117  };
118  VehicleConfig last_vehicle_config_;
119 
120  VehicleConfig ComputeVehicleConfigFromLocalization(
121  const localization::LocalizationEstimate& localization) const;
122 
123  std::string target_lane_id_;
124 
125  std::unique_ptr<ReferenceLineProvider> reference_line_provider_;
126 };
127 
128 } // namespace planning
129 } // namespace apollo
Definition: planning_base.h:54
Definition: navi_planning.h:43
apollo::common::Status Plan(const double current_time_stamp, const std::vector< common::TrajectoryPoint > &stitching_trajectory, ADCTrajectory *const trajectory) override
Plan the trajectory given current vehicle state.
std::unique_ptr< PlannerDispatcher > planner_dispatcher_
Definition: planning_base.h:92
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...
std::string Name() const override
Planning algorithm name.
LocalView contains all necessary data as planning input.
apollo::common::Status Init(const PlanningConfig &config) override
module initialization function
NaviPlanning(const std::shared_ptr< DependencyInjector > &injector)
Definition: navi_planning.h:45
void RunOnce(const LocalView &local_view, ADCTrajectory *const trajectory_pb) override
main logic of the planning module, runs periodically triggered by timer.
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
Definition: local_view.h:38