Apollo 11.0
自动驾驶开放平台
message_process.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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 <chrono>
24#include <fstream>
25#include <list>
26#include <memory>
27#include <string>
28#include <unordered_map>
29#include <utility>
30#include <vector>
31
32#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
33#include "modules/common_msgs/dreamview_msgs/hmi_status.pb.h"
34#include "modules/common_msgs/localization_msgs/localization.pb.h"
35#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
36#include "modules/common_msgs/prediction_msgs/prediction_obstacle.pb.h"
37#include "modules/common_msgs/routing_msgs/routing.pb.h"
38#include "modules/common_msgs/storytelling_msgs/story.pb.h"
39#include "modules/planning/planning_base/proto/learning_data.pb.h"
40#include "modules/planning/planning_base/proto/planning_config.pb.h"
41
44
45namespace apollo {
46namespace planning {
47
49 public:
50 bool Init(const PlanningConfig& planning_config);
51 bool Init(const PlanningConfig& planning_config,
52 const std::shared_ptr<DependencyInjector>& injector);
53
54 void Close();
55
56 void OnChassis(const apollo::canbus::Chassis& chassis);
57
58 void OnHMIStatus(apollo::dreamview::HMIStatus hmi_status);
59
61
62 void OnPrediction(
63 const apollo::prediction::PredictionObstacles& prediction_obstacles);
64
66 const apollo::routing::RoutingResponse& routing_response);
67
69
71 const apollo::perception::TrafficLightDetection& traffic_light_detection);
72
73 void ProcessOfflineData(const std::string& record_file);
74
75 private:
76 struct ADCCurrentInfo {
77 std::pair<double, double> adc_cur_position_;
78 std::pair<double, double> adc_cur_velocity_;
79 std::pair<double, double> adc_cur_acc_;
80 double adc_cur_heading_;
81 };
82
84 const apollo::common::PointENU& position);
85 bool GetADCCurrentRoutingIndex(int* adc_road_index, int* adc_passage_index,
86 double* adc_passage_s);
87
88 int GetADCCurrentInfo(ADCCurrentInfo* adc_curr_info);
89
90 void GenerateObstacleTrajectory(const int frame_num, const int obstacle_id,
91 const ADCCurrentInfo& adc_curr_info,
92 ObstacleFeature* obstacle_feature);
93
94 void GenerateObstaclePrediction(
95 const int frame_num,
96 const apollo::prediction::PredictionObstacle& prediction_obstacle,
97 const ADCCurrentInfo& adc_curr_info, ObstacleFeature* obstacle_feature);
98
99 void GenerateObstacleFeature(LearningDataFrame* learning_data_frame);
100
101 bool GenerateLocalRouting(const int frame_num,
102 RoutingResponseFeature* local_routing,
103 std::vector<std::string>* local_routing_lane_ids);
104
105 void GenerateRoutingFeature(
106 const RoutingResponseFeature& local_routing,
107 const std::vector<std::string>& local_routing_lane_ids,
108 LearningDataFrame* learning_data_frame);
109
110 void GenerateTrafficLightDetectionFeature(
111 LearningDataFrame* learning_data_frame);
112 void GenerateADCTrajectoryPoints(
113 const std::list<apollo::localization::LocalizationEstimate>&
114 localizations,
115 LearningDataFrame* learning_data_frame);
116
117 void GeneratePlanningTag(LearningDataFrame* learning_data_frame);
118
119 bool GenerateLearningDataFrame(LearningDataFrame* learning_data_frame);
120
121 private:
122 std::shared_ptr<DependencyInjector> injector_;
123 PlanningConfig planning_config_;
124 std::chrono::time_point<std::chrono::system_clock> start_time_;
125 std::ofstream log_file_;
126 std::string record_file_;
127 std::unordered_map<std::string, std::string> map_m_;
128 LearningData learning_data_;
129 int learning_data_file_index_ = 0;
130 std::list<apollo::localization::LocalizationEstimate> localizations_;
131 std::unordered_map<int, apollo::prediction::PredictionObstacle>
132 prediction_obstacles_map_;
133 std::unordered_map<int, std::list<PerceptionObstacleFeature>>
134 obstacle_history_map_;
135 ChassisFeature chassis_feature_;
136 std::string map_name_;
137 PlanningTag planning_tag_;
138 apollo::routing::RoutingResponse routing_response_;
139 double traffic_light_detection_message_timestamp_;
140 std::vector<TrafficLightFeature> traffic_lights_;
141 int total_learning_data_frame_num_ = 0;
142 double last_localization_message_timestamp_sec_ = 0.0;
143};
144
145} // namespace planning
146} // namespace apollo
bool Init(const PlanningConfig &planning_config)
void OnPrediction(const apollo::prediction::PredictionObstacles &prediction_obstacles)
void OnStoryTelling(const apollo::storytelling::Stories &stories)
void OnRoutingResponse(const apollo::routing::RoutingResponse &routing_response)
void OnLocalization(const apollo::localization::LocalizationEstimate &le)
void OnTrafficLightDetection(const apollo::perception::TrafficLightDetection &traffic_light_detection)
void ProcessOfflineData(const std::string &record_file)
void OnHMIStatus(apollo::dreamview::HMIStatus hmi_status)
void OnChassis(const apollo::canbus::Chassis &chassis)
Planning module main class.
std::shared_ptr< const LaneInfo > LaneInfoConstPtr
class register implement
Definition arena_queue.h:37