forked from GKD-RM-Lab/AutoSentry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotatePCD.cpp
More file actions
28 lines (22 loc) · 840 Bytes
/
rotatePCD.cpp
File metadata and controls
28 lines (22 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <pcl/io/pcd_io.h>
#include <pcl/common/transforms.h>
int main()
{
// 创建点云对象
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud(new pcl::PointCloud<pcl::PointXYZ>);
// 读取PCD文件
if (pcl::io::loadPCDFile<pcl::PointXYZ>("../RMUL.pcd", *cloud) == -1)
{
PCL_ERROR("无法读取输入文件!\n");
return -1;
}
// 创建绕X轴旋转90度的变换矩阵
Eigen::Affine3f transform = Eigen::Affine3f::Identity();
transform.rotate(Eigen::AngleAxisf(M_PI/2, Eigen::Vector3f::UnitX()));
// 应用变换
pcl::transformPointCloud(*cloud, *transformed_cloud, transform);
// 保存结果
pcl::io::savePCDFileASCII("../RMUL-r.pcd", *transformed_cloud);
return 0;
}