Apollo 10.0
自动驾驶开放平台
apollo::perception::algorithm::SensorManager类 参考

#include <sensor_manager.h>

apollo::perception::algorithm::SensorManager 的协作图:

Public 成员函数

bool Init ()
 
bool IsSensorExist (const std::string &name) const
 
bool GetSensorInfo (const std::string &name, apollo::perception::base::SensorInfo *sensor_info) const
 
std::shared_ptr< BaseCameraDistortionModelGetDistortCameraModel (const std::string &name) const
 
std::shared_ptr< BaseCameraModelGetUndistortCameraModel (const std::string &name) const
 
bool IsHdLidar (const std::string &name) const
 
bool IsHdLidar (const apollo::perception::base::SensorType &type) const
 
bool IsLdLidar (const std::string &name) const
 
bool IsLdLidar (const apollo::perception::base::SensorType &type) const
 
bool IsLidar (const std::string &name) const
 
bool IsLidar (const apollo::perception::base::SensorType &type) const
 
bool IsRadar (const std::string &name) const
 
bool IsRadar (const apollo::perception::base::SensorType &type) const
 
bool IsCamera (const std::string &name) const
 
bool IsCamera (const apollo::perception::base::SensorType &type) const
 
bool IsUltrasonic (const std::string &name) const
 
bool IsUltrasonic (const apollo::perception::base::SensorType &type) const
 
bool IsMainSensor (const std::string &name) const
 
std::string GetFrameId (const std::string &name) const
 

详细描述

在文件 sensor_manager.h35 行定义.

成员函数说明

◆ GetDistortCameraModel()

std::shared_ptr< BaseCameraDistortionModel > apollo::perception::algorithm::SensorManager::GetDistortCameraModel ( const std::string &  name) const

在文件 sensor_manager.cc123 行定义.

124 {
125 const auto& itr = distort_model_map_.find(name);
126
127 return itr == distort_model_map_.end() ? nullptr : itr->second;
128}

◆ GetFrameId()

std::string apollo::perception::algorithm::SensorManager::GetFrameId ( const std::string &  name) const

在文件 sensor_manager.cc233 行定义.

233 {
234 const auto& itr = sensor_info_map_.find(name);
235 return itr == sensor_info_map_.end() ? std::string("") : itr->second.frame_id;
236}
std::string frame_id
Point cloud frame id

◆ GetSensorInfo()

bool apollo::perception::algorithm::SensorManager::GetSensorInfo ( const std::string &  name,
apollo::perception::base::SensorInfo sensor_info 
) const

在文件 sensor_manager.cc107 行定义.

108 {
109 if (sensor_info == nullptr) {
110 AERROR << "Nullptr error.";
111 return false;
112 }
113
114 const auto& itr = sensor_info_map_.find(name);
115 if (itr == sensor_info_map_.end()) {
116 return false;
117 }
118
119 *sensor_info = itr->second;
120 return true;
121}
#define AERROR
Definition log.h:44

◆ GetUndistortCameraModel()

std::shared_ptr< BaseCameraModel > apollo::perception::algorithm::SensorManager::GetUndistortCameraModel ( const std::string &  name) const

在文件 sensor_manager.cc130 行定义.

131 {
132 const auto& itr = undistort_model_map_.find(name);
133
134 return itr == undistort_model_map_.end() ? nullptr : itr->second;
135}

◆ Init()

bool apollo::perception::algorithm::SensorManager::Init ( )

在文件 sensor_manager.cc39 行定义.

39 {
40 std::lock_guard<std::mutex> lock(mutex_);
41 if (inited_) {
42 return true;
43 }
44
45 sensor_info_map_.clear();
46 distort_model_map_.clear();
47 undistort_model_map_.clear();
48
49 std::string config_file = GetCommonConfigFile(FLAGS_obs_sensor_meta_file);
50
51 MultiSensorMeta sensor_list_proto;
52 if (!GetProtoFromASCIIFile(config_file, &sensor_list_proto)) {
53 AERROR << "Invalid MultiSensorMeta file: " << config_file;
54 return false;
55 }
56
57 auto AddSensorInfo = [this](const SensorMeta& sensor_meta_proto) {
58 SensorInfo sensor_info;
59 sensor_info.name = sensor_meta_proto.name();
60 sensor_info.type = static_cast<SensorType>(sensor_meta_proto.type());
61 sensor_info.orientation =
62 static_cast<SensorOrientation>(sensor_meta_proto.orientation());
63 sensor_info.frame_id = sensor_meta_proto.name();
64 sensor_info.is_main_sensor = sensor_meta_proto.is_main_sensor();
65
66 auto pair = sensor_info_map_.insert(
67 make_pair(sensor_meta_proto.name(), sensor_info));
68 if (!pair.second) {
69 AERROR << "Duplicate sensor name error.";
70 return false;
71 }
72
73 if (this->IsCamera(sensor_info.type)) {
74 std::shared_ptr<BrownCameraDistortionModel> distort_model(
75 new BrownCameraDistortionModel());
76 // Todo(zero): Need change to GetCommonConfigFile
77 auto intrinsic_file = IntrinsicPath(sensor_info.frame_id);
78 if (!LoadBrownCameraIntrinsic(intrinsic_file, distort_model.get())) {
79 AERROR << "Failed to load camera intrinsic:" << intrinsic_file;
80 return false;
81 }
82 distort_model_map_.insert(make_pair(
83 sensor_meta_proto.name(),
84 std::dynamic_pointer_cast<BaseCameraDistortionModel>(distort_model)));
85 undistort_model_map_.insert(make_pair(sensor_meta_proto.name(),
86 distort_model->get_camera_model()));
87 }
88 return true;
89 };
90
91 for (const SensorMeta& sensor_meta_proto : sensor_list_proto.sensor_meta()) {
92 if (!AddSensorInfo(sensor_meta_proto)) {
93 AERROR << "Failed to add sensor_info: " << sensor_meta_proto.name();
94 return false;
95 }
96 }
97
98 inited_ = true;
99 AINFO << "Init sensor_manager success.";
100 return true;
101}
bool IsCamera(const std::string &name) const
#define AINFO
Definition log.h:42
bool GetProtoFromASCIIFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as ascii representation of protobufs,...
Definition file.cc:89
bool LoadBrownCameraIntrinsic(const std::string &yaml_file, base::BrownCameraDistortionModel *model)
Definition io_util.cc:59
SensorType
Sensor types are set in the order of lidar, radar, camera, ultrasonic Please make sure SensorType has...
Definition sensor_meta.h:29
std::string GetCommonConfigFile(const std::string &config_file)
Get the perception common config path
Definition util.cc:28

◆ IsCamera() [1/2]

bool apollo::perception::algorithm::SensorManager::IsCamera ( const apollo::perception::base::SensorType type) const

◆ IsCamera() [2/2]

bool apollo::perception::algorithm::SensorManager::IsCamera ( const std::string &  name) const

在文件 sensor_manager.cc195 行定义.

195 {
196 const auto& itr = sensor_info_map_.find(name);
197 if (itr == sensor_info_map_.end()) {
198 return false;
199 }
200
201 SensorType type = itr->second.type;
202 return this->IsCamera(type);
203}

◆ IsHdLidar() [1/2]

bool apollo::perception::algorithm::SensorManager::IsHdLidar ( const apollo::perception::base::SensorType type) const

◆ IsHdLidar() [2/2]

bool apollo::perception::algorithm::SensorManager::IsHdLidar ( const std::string &  name) const

在文件 sensor_manager.cc137 行定义.

137 {
138 const auto& itr = sensor_info_map_.find(name);
139 if (itr == sensor_info_map_.end()) {
140 return false;
141 }
142
143 SensorType type = itr->second.type;
144 return this->IsHdLidar(type);
145}
bool IsHdLidar(const std::string &name) const

◆ IsLdLidar() [1/2]

bool apollo::perception::algorithm::SensorManager::IsLdLidar ( const apollo::perception::base::SensorType type) const

◆ IsLdLidar() [2/2]

bool apollo::perception::algorithm::SensorManager::IsLdLidar ( const std::string &  name) const

在文件 sensor_manager.cc152 行定义.

152 {
153 const auto& itr = sensor_info_map_.find(name);
154 if (itr == sensor_info_map_.end()) {
155 return false;
156 }
157
158 SensorType type = itr->second.type;
159 return this->IsLdLidar(type);
160}
bool IsLdLidar(const std::string &name) const

◆ IsLidar() [1/2]

bool apollo::perception::algorithm::SensorManager::IsLidar ( const apollo::perception::base::SensorType type) const

◆ IsLidar() [2/2]

bool apollo::perception::algorithm::SensorManager::IsLidar ( const std::string &  name) const

在文件 sensor_manager.cc166 行定义.

166 {
167 const auto& itr = sensor_info_map_.find(name);
168 if (itr == sensor_info_map_.end()) {
169 return false;
170 }
171
172 SensorType type = itr->second.type;
173 return this->IsLidar(type);
174}
bool IsLidar(const std::string &name) const

◆ IsMainSensor()

bool apollo::perception::algorithm::SensorManager::IsMainSensor ( const std::string &  name) const

在文件 sensor_manager.cc224 行定义.

224 {
225 const auto& itr = sensor_info_map_.find(name);
226 if (itr == sensor_info_map_.end()) {
227 return false;
228 }
229
230 return itr->second.is_main_sensor;
231}

◆ IsRadar() [1/2]

bool apollo::perception::algorithm::SensorManager::IsRadar ( const apollo::perception::base::SensorType type) const

◆ IsRadar() [2/2]

bool apollo::perception::algorithm::SensorManager::IsRadar ( const std::string &  name) const

在文件 sensor_manager.cc180 行定义.

180 {
181 const auto& itr = sensor_info_map_.find(name);
182 if (itr == sensor_info_map_.end()) {
183 return false;
184 }
185
186 SensorType type = itr->second.type;
187 return this->IsRadar(type);
188}
bool IsRadar(const std::string &name) const

◆ IsSensorExist()

bool apollo::perception::algorithm::SensorManager::IsSensorExist ( const std::string &  name) const

在文件 sensor_manager.cc103 行定义.

103 {
104 return sensor_info_map_.find(name) != sensor_info_map_.end();
105}

◆ IsUltrasonic() [1/2]

bool apollo::perception::algorithm::SensorManager::IsUltrasonic ( const apollo::perception::base::SensorType type) const

◆ IsUltrasonic() [2/2]

bool apollo::perception::algorithm::SensorManager::IsUltrasonic ( const std::string &  name) const

在文件 sensor_manager.cc210 行定义.

210 {
211 const auto& itr = sensor_info_map_.find(name);
212 if (itr == sensor_info_map_.end()) {
213 return false;
214 }
215
216 SensorType type = itr->second.type;
217 return this->IsUltrasonic(type);
218}
bool IsUltrasonic(const std::string &name) const

该类的文档由以下文件生成: