Apollo 11.0
自动驾驶开放平台
traffic_light_region_proposal_component.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#pragma once
17
18#include <map>
19#include <memory>
20#include <string>
21#include <vector>
22
23#include "modules/common_msgs/map_msgs/map_geometry.pb.h"
24#include "modules/common_msgs/map_msgs/map_signal.pb.h"
25#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
26#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
27#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
28#include "modules/common_msgs/transform_msgs/transform.pb.h"
29#include "modules/perception/traffic_light_region_proposal/proto/trafficlights_proposal_component.pb.h"
30
38
39namespace apollo {
40namespace perception {
41namespace trafficlight {
42
46
48 public:
59
61 delete;
63 const TrafficLightsPerceptionComponent&) = delete;
71 bool Init() override;
72
73 private:
74 int InitConfig();
75 int InitAlgorithmPlugin();
76 int InitCameraListeners();
77 int InitCameraFrame();
78
79 void OnReceiveImage(const std::shared_ptr<apollo::drivers::Image> image,
80 const std::string& camera_name);
81
82 bool QueryPoseAndSignals(const double ts, camera::CarPose* pose,
83 std::vector<apollo::hdmap::Signal>* signals);
84
85 bool VerifyLightsProjection(
86 const double& ts, const trafficlight::TLPreprocessorOption& option,
87 const std::string& camera_name,
88 std::shared_ptr<camera::TrafficLightFrame> image_lights,
89 std::shared_ptr<TrafficDetectMessage> msg);
90
91 bool UpdateCameraSelection(double timestamp,
93 std::shared_ptr<camera::TrafficLightFrame> frame);
94
95 bool CheckCameraImageStatus(double timestamp, double interval,
96 const std::string& camera_name);
97
98 bool GetCarPose(const double timestamp, camera::CarPose* pose);
99
100 bool GetPoseFromTF(const double timestamp, const std::string& frame_id,
101 const std::string& child_frame_id,
102 Eigen::Matrix4d* pose_matrix);
103
104 void GenerateTrafficLights(
105 const std::vector<apollo::hdmap::Signal>& signals,
106 std::vector<base::TrafficLightPtr>* traffic_lights);
107
108 private:
109 std::mutex mutex_;
110
111 std::shared_ptr<trafficlight::BaseTLPreprocessor> preprocessor_;
112 apollo::perception::map::HDMapInput* hd_map_ = nullptr;
113
114 trafficlight::TrafficLightPreprocessorInitOptions preprocessor_init_options_;
115 std::string tl_preprocessor_name_;
116
117 std::string tf2_frame_id_;
118 std::string tf2_child_frame_id_;
119 std::string proposal_output_channel_name_;
120 int gpu_id_;
121 double tf2_timeout_second_ = 0.01;
122
123 Buffer* tf2_buffer_ = Buffer::Instance();
124
125 std::vector<std::string> camera_names_;
126 std::vector<std::string> input_camera_channel_names_;
127 // camera_name -> TransformWrapper
128 std::map<std::string, std::shared_ptr<TransformWrapper>>
129 camera2world_trans_wrapper_map_;
130 // camera_name -> image_border_size
131 std::map<std::string, int> image_border_sizes_;
132 std::map<std::string, double> last_sub_camera_image_ts_;
133
134 // pre-allocated-mem data_provider; camera_id -> data_provider
135 std::map<std::string, std::shared_ptr<camera::DataProvider>>
136 data_providers_map_;
137
138 double query_tf_interval_seconds_ = 0.0;
139 double image_timestamp_offset_ = 0.0;
140 int max_process_image_fps_ = 10; // max frames to be processed per second
141 double proc_interval_seconds_ = 0.0;
142 double check_image_status_interval_thresh_ = 1.0;
143
144 double last_query_tf_ts_ = 0.0;
145 double last_proc_image_ts_ = 0.0;
146 double image_sys_ts_diff_threshold_ = 0.5;
147
148 // for querying hdmap signals
149 double last_signals_ts_ = -1.0;
150 double valid_hdmap_interval_ = 1.5;
151 double forward_distance_to_query_signals = 150.0;
152 std::vector<apollo::hdmap::Signal> last_signals_;
153
154 // image info.
155 int image_width_ = 1920;
156 int image_height_ = 1080;
157 int default_image_border_size_ = 100;
158
159 // options for DataProvider
160 bool enable_undistortion_ = false;
161 camera::DataProvider::InitOptions data_provider_init_options_;
162
163 // proc
164 ::google::protobuf::RepeatedPtrField<apollo::hdmap::Curve> stoplines_;
165
166 std::shared_ptr<apollo::cyber::Writer<TrafficDetectMessage>>
167 traffic_detect_writer_;
168};
169
171
172} // namespace trafficlight
173} // namespace perception
174} // namespace apollo
TrafficLightsPerceptionComponent & operator=(const TrafficLightsPerceptionComponent &)=delete
bool Init() override
Initialize configuration files, algorithm plug-ins, callback functions and create listening channels.
TrafficLightsPerceptionComponent(const TrafficLightsPerceptionComponent &)=delete
~TrafficLightsPerceptionComponent()=default
Destroy the traffic lights perception component object.
TrafficLightsPerceptionComponent()=default
Construct a new traffic lights perception component object.
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37