Apollo 11.0
自动驾驶开放平台
lane_detection_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 <mutex>
21#include <string>
22#include <vector>
23
24#include "Eigen/Core"
25#include "Eigen/Dense"
26#include "Eigen/StdVector"
27
28#include "modules/common_msgs/perception_msgs/perception_lane.pb.h"
29#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
30#include "modules/perception/common/proto/motion_service.pb.h"
31#include "modules/perception/lane_detection/proto/lane_perception_component.pb.h"
32#include "modules/perception/lane_detection/proto/perception.pb.h"
33
46
47namespace apollo {
48namespace perception {
49namespace onboard {
50
51
52class LaneDetectionComponent;
55 public:
56 template <class EigenType>
58
59 template <typename T, class EigenType>
61
63 std::shared_ptr<apollo::perception::MotionService>;
64
65 public:
66 LaneDetectionComponent() : seq_num_(0) {}
68
71
72 bool Init() override;
73
74 template <typename T>
75 friend class FunctionInfo;
76
77 private:
78 void OnReceiveImage(const std::shared_ptr<apollo::drivers::Image>& in_message,
79 const std::string& camera_name);
80 void OnMotionService(const MotionServiceMsgType& in_message);
81 int InitConfig();
82 int InitSensorInfo();
83 int InitAlgorithmPlugin();
84 int InitCameraFrames();
85 int InitProjectMatrix();
86 int InitMotionService();
87 int InitCameraListeners();
88 void SetCameraHeightAndPitch();
89
90 int InternalProc(
91 const std::shared_ptr<apollo::drivers::Image const>& in_message,
92 const std::string& camera_name, apollo::common::ErrorCode* error_code,
93 SensorFrameMessage* prefused_message,
95
96 int ConvertLaneToCameraLaneline(
97 const base::LaneLine& lane_line,
98 apollo::perception::camera::CameraLaneLine* camera_laneline);
99
100 int MakeProtobufMsg(double msg_timestamp, const std::string& camera_name,
101 const camera::CameraFrame& camera_frame,
103
104 private:
105 std::mutex mutex_;
106 uint32_t seq_num_;
107
108 std::vector<std::shared_ptr<cyber::Node>> camera_listener_nodes_;
109
110 std::vector<std::string> camera_names_; // camera sensor names
111 std::vector<std::string> input_camera_channel_names_;
112
113 // camera name -> SensorInfo
114 std::map<std::string, base::SensorInfo> sensor_info_map_;
115
116 // camera_height
117 std::map<std::string, float> camera_height_map_;
118
119 // camera_pitch_angle_diff
120 std::map<std::string, float> name_camera_pitch_angle_diff_map_;
121
122 // TF stuff
123 std::map<std::string, std::string> tf_camera_frame_id_map_;
124 std::map<std::string, std::shared_ptr<TransformWrapper>>
125 camera2world_trans_wrapper_map_;
126
127 // pre-allocaated-mem data_provider;
128 std::map<std::string, std::shared_ptr<camera::DataProvider>>
129 data_providers_map_;
130
131 // map for store params
134 Eigen::Matrix3d homography_image2ground_;
135
136 // camera lane pipeline
137 camera::CameraPerceptionInitOptions camera_perception_init_options_;
138 std::unique_ptr<camera::LaneCameraPerception> camera_lane_pipeline_;
139
140 // fixed size camera frames
141 int frame_capacity_ = 20;
142 int frame_id_ = 0;
144
145 // image info.
146 int image_width_ = 1920;
147 int image_height_ = 1080;
148 int image_channel_num_ = 3;
149 int image_data_size_ = -1;
150
151 // default camera pitch angle & height
152 float default_camera_pitch_ = 0.f;
153 float default_camera_height_ = 1.6f;
154
155 // options for DataProvider
156 bool enable_undistortion_ = false;
157
158 double timestamp_offset_ = 0.0;
159
160 bool enable_visualization_ = false;
161 std::string visual_debug_folder_;
162 std::string visual_camera_;
163
164 std::string output_lanes_channel_name_;
165
166 Eigen::Matrix3d project_matrix_;
167 double pitch_diff_ = 0.0;
168
169 double last_timestamp_ = 0.0;
170 double ts_diff_ = 1.0;
171
172 std::shared_ptr<apollo::cyber::Writer<apollo::perception::PerceptionLanes>>
173 writer_;
174
175 base::MotionBufferPtr mot_buffer_;
176 const int motion_buffer_size_ = 100;
177
178 camera::Visualizer visualize_;
179 bool write_visual_img_;
180 static FunInfoType init_func_arry_[];
181};
182
184
185} // namespace onboard
186} // namespace perception
187} // namespace apollo
std::shared_ptr< apollo::perception::MotionService > MotionServiceMsgType
apollo::common::EigenVector< EigenType > EigenVector
apollo::common::EigenMap< T, EigenType > EigenMap
LaneDetectionComponent & operator=(const LaneDetectionComponent &)=delete
LaneDetectionComponent(const LaneDetectionComponent &)=delete
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
Some util functions.
std::map< T, EigenType, std::less< T >, Eigen::aligned_allocator< std::pair< const T, EigenType > > > EigenMap
Definition eigen_defs.h:40
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
Definition eigen_defs.h:33
std::shared_ptr< MotionBuffer > MotionBufferPtr
FunctionInfo< LaneDetectionComponent > FunInfoType
class register implement
Definition arena_queue.h:37