Apollo 10.0
自动驾驶开放平台
apollo::localization::msf::velodyne 命名空间参考

struct  PointXYZIRT
 
struct  PointXYZIRTd
 
struct  PointXYZIT
 
struct  PointXYZITd
 
struct  VelodyneFrame
 

函数

void LoadPcds (const std::string &file_path, const unsigned int frame_index, const Eigen::Affine3d &pose, VelodyneFrame *velodyne_frame, bool is_global)
 
void LoadPcds (const std::string &file_path, const unsigned int frame_index, const Eigen::Affine3d &pose, ::apollo::common::EigenVector3dVec *pt3ds, std::vector< unsigned char > *intensities, bool is_global)
 
void LoadPcdPoses (const std::string &file_path, ::apollo::common::EigenAffine3dVec *poses, std::vector< double > *timestamps)
 Load the PCD poses with their timestamps.
 
void LoadPcdPoses (const std::string &file_path, ::apollo::common::EigenAffine3dVec *poses, std::vector< double > *timestamps, std::vector< unsigned int > *pcd_indices)
 Load the PCD poses with their timestamps and indices.
 
void LoadPosesAndStds (const std::string &file_path, ::apollo::common::EigenAffine3dVec *poses, ::apollo::common::EigenVector3dVec *stds, std::vector< double > *timestamps)
 Load poses and stds their timestamps.
 
bool LoadExtrinsic (const std::string &file_path, Eigen::Affine3d *extrinsic)
 Load the velodyne extrinsic from a YAML file.
 

变量

struct apollo::localization::msf::velodyne::PointXYZIRT EIGEN_ALIGN16
 

函数说明

◆ LoadExtrinsic()

bool apollo::localization::msf::velodyne::LoadExtrinsic ( const std::string &  file_path,
Eigen::Affine3d *  extrinsic 
)

Load the velodyne extrinsic from a YAML file.

在文件 velodyne_utility.cc164 行定义.

164 {
165 YAML::Node config = YAML::LoadFile(file_path);
166 if (config["transform"]) {
167 if (config["transform"]["translation"]) {
168 extrinsic->translation()(0) =
169 config["transform"]["translation"]["x"].as<double>();
170 extrinsic->translation()(1) =
171 config["transform"]["translation"]["y"].as<double>();
172 extrinsic->translation()(2) =
173 config["transform"]["translation"]["z"].as<double>();
174 if (config["transform"]["rotation"]) {
175 double qx = config["transform"]["rotation"]["x"].as<double>();
176 double qy = config["transform"]["rotation"]["y"].as<double>();
177 double qz = config["transform"]["rotation"]["z"].as<double>();
178 double qw = config["transform"]["rotation"]["w"].as<double>();
179 extrinsic->linear() =
180 Eigen::Quaterniond(qw, qx, qy, qz).toRotationMatrix();
181 return true;
182 }
183 }
184 }
185 return false;
186}

◆ LoadPcdPoses() [1/2]

void apollo::localization::msf::velodyne::LoadPcdPoses ( const std::string &  file_path,
::apollo::common::EigenAffine3dVec poses,
std::vector< double > *  timestamps 
)

Load the PCD poses with their timestamps.

在文件 velodyne_utility.cc94 行定义.

96 {
97 std::vector<unsigned int> pcd_indices;
98 LoadPcdPoses(file_path, poses, timestamps, &pcd_indices);
99}
void LoadPcdPoses(const std::string &file_path, ::apollo::common::EigenAffine3dVec *poses, std::vector< double > *timestamps)
Load the PCD poses with their timestamps.

◆ LoadPcdPoses() [2/2]

void apollo::localization::msf::velodyne::LoadPcdPoses ( const std::string &  file_path,
::apollo::common::EigenAffine3dVec poses,
std::vector< double > *  timestamps,
std::vector< unsigned int > *  pcd_indices 
)

Load the PCD poses with their timestamps and indices.

在文件 velodyne_utility.cc101 行定义.

104 {
105 poses->clear();
106 timestamps->clear();
107 pcd_indices->clear();
108
109 FILE* file = fopen(file_path.c_str(), "r");
110 if (file) {
111 unsigned int index;
112 double timestamp;
113 double x, y, z;
114 double qx, qy, qz, qr;
115 static constexpr int kSize = 9;
116 while (fscanf(file, "%u %lf %lf %lf %lf %lf %lf %lf %lf\n", &index,
117 &timestamp, &x, &y, &z, &qx, &qy, &qz, &qr) == kSize) {
118 Eigen::Translation3d trans(Eigen::Vector3d(x, y, z));
119 Eigen::Quaterniond quat(qr, qx, qy, qz);
120 poses->push_back(trans * quat);
121 timestamps->push_back(timestamp);
122 pcd_indices->push_back(index);
123 }
124 fclose(file);
125 } else {
126 AERROR << "Can't open file to read: " << file_path;
127 }
128}
#define AERROR
Definition log.h:44

◆ LoadPcds() [1/2]

void apollo::localization::msf::velodyne::LoadPcds ( const std::string &  file_path,
const unsigned int  frame_index,
const Eigen::Affine3d &  pose,
::apollo::common::EigenVector3dVec pt3ds,
std::vector< unsigned char > *  intensities,
bool  is_global 
)

在文件 velodyne_utility.cc39 行定义.

42 {
43 Eigen::Affine3d pose_inv = pose.inverse();
44 pcl::PointCloud<PointXYZIT>::Ptr cloud(new pcl::PointCloud<PointXYZIT>);
45 if (pcl::io::loadPCDFile(file_path, *cloud) >= 0) {
46 if (cloud->height == 1 || cloud->width == 1) {
47 AINFO << "Un-organized-point-cloud";
48 for (unsigned int i = 0; i < cloud->size(); ++i) {
49 Eigen::Vector3d pt3d;
50 pt3d[0] = (*cloud)[i].x;
51 pt3d[1] = (*cloud)[i].y;
52 pt3d[2] = (*cloud)[i].z;
53
54 if (pt3d[0] == pt3d[0] && pt3d[1] == pt3d[1] && pt3d[2] == pt3d[2]) {
55 Eigen::Vector3d pt3d_local;
56 if (is_global) {
57 pt3d_local = pose_inv * pt3d;
58 } else {
59 pt3d_local = pt3d;
60 }
61 unsigned char intensity =
62 static_cast<unsigned char>((*cloud)[i].intensity);
63 pt3ds->push_back(pt3d_local);
64 intensities->push_back(intensity);
65 }
66 }
67 } else {
68 for (unsigned int h = 0; h < cloud->height; ++h) {
69 for (unsigned int w = 0; w < cloud->width; ++w) {
70 double x = cloud->at(w, h).x;
71 double y = cloud->at(w, h).y;
72 double z = cloud->at(w, h).z;
73 Eigen::Vector3d pt3d(x, y, z);
74 if (pt3d[0] == pt3d[0] && pt3d[1] == pt3d[1] && pt3d[2] == pt3d[2]) {
75 Eigen::Vector3d pt3d_local;
76 if (is_global) {
77 pt3d_local = pose_inv * pt3d;
78 } else {
79 pt3d_local = pt3d;
80 }
81 unsigned char intensity =
82 static_cast<unsigned char>(cloud->at(w, h).intensity);
83 pt3ds->push_back(pt3d_local);
84 intensities->push_back(intensity);
85 }
86 }
87 }
88 }
89 } else {
90 AERROR << "Failed to load PCD file: " << file_path;
91 }
92}
#define AINFO
Definition log.h:42

◆ LoadPcds() [2/2]

void apollo::localization::msf::velodyne::LoadPcds ( const std::string &  file_path,
const unsigned int  frame_index,
const Eigen::Affine3d &  pose,
VelodyneFrame velodyne_frame,
bool  is_global 
)

在文件 velodyne_utility.cc30 行定义.

32 {
33 velodyne_frame->frame_index = frame_index;
34 velodyne_frame->pose = pose;
35 LoadPcds(file_path, frame_index, pose, &velodyne_frame->pt3ds,
36 &velodyne_frame->intensities, is_global);
37}
void LoadPcds(const std::string &file_path, const unsigned int frame_index, const Eigen::Affine3d &pose, VelodyneFrame *velodyne_frame, bool is_global)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW unsigned int frame_index
The frame index.
::apollo::common::EigenVector3dVec pt3ds
The 3D point cloud in this frame.
std::vector< unsigned char > intensities
The laser reflection values in this frames.
Eigen::Affine3d pose
The pose of the frame.

◆ LoadPosesAndStds()

void apollo::localization::msf::velodyne::LoadPosesAndStds ( const std::string &  file_path,
::apollo::common::EigenAffine3dVec poses,
::apollo::common::EigenVector3dVec stds,
std::vector< double > *  timestamps 
)

Load poses and stds their timestamps.

在文件 velodyne_utility.cc130 行定义.

133 {
134 poses->clear();
135 stds->clear();
136 timestamps->clear();
137
138 FILE* file = fopen(file_path.c_str(), "r");
139 if (file) {
140 unsigned int index;
141 double timestamp;
142 double x, y, z;
143 double qx, qy, qz, qr;
144 double std_x, std_y, std_z;
145 static constexpr int kSize = 12;
146 while (fscanf(file, "%u %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
147 &index, &timestamp, &x, &y, &z, &qx, &qy, &qz, &qr, &std_x,
148 &std_y, &std_z) == kSize) {
149 Eigen::Translation3d trans(Eigen::Vector3d(x, y, z));
150 Eigen::Quaterniond quat(qr, qx, qy, qz);
151 poses->push_back(trans * quat);
152 timestamps->push_back(timestamp);
153
154 Eigen::Vector3d std;
155 std << std_x, std_y, std_z;
156 stds->push_back(std);
157 }
158 fclose(file);
159 } else {
160 AERROR << "Can't open file to read: " << file_path;
161 }
162}
Definition future.h:29

变量说明

◆ EIGEN_ALIGN16

struct apollo::localization::msf::velodyne::PointXYZITd apollo::localization::msf::velodyne::EIGEN_ALIGN16