ros虚拟机,点云矩阵平移旋转运算
第一部分代码给出来了,并且运行成功了
第二部分和第三部,不会
#include "PointCloudOpt.h"
pcl::PointCloud PointCloudOpt::pointCloudTranslation(const pcl::PointCloud& pointcloudinput)
{
pcl::PointCloud pointcloudoutput;
/*
* please finish this program to implement 3D points translation.
* input: pointcloudinput
* output: pointcloudoutput
* description: calculate pointcloudoutput by adding translation vector to pointcloudoutput
*/pointcloudoutput.resize(pointcloudinput.size());
for(int i=0;i0.17;
pointcloudoutput.at(i).y=pointcloudinput.at(i).y+0.17;
pointcloudoutput.at(i).z=pointcloudinput.at(i).z+0.17;
}
return pointcloudoutput;
}
pcl::PointCloud PointCloudOpt::pointCloudRot(const pcl::PointCloud& pointcloudinput)
{
pcl::PointCloud pointcloudoutput;
/*
* please finish this program to implement 3D points rotation.
* input: pointcloudinput
* output: pointcloudoutput
* description: calculate pointcloudoutput by multipling rotation matrix to pointcloudoutput
*/
return pointcloudoutput;
}
pcl::PointCloud PointCloudOpt::pointCloudTransformation(const pcl::PointCloud& pointcloudinput)
{
pcl::PointCloud pointcloudoutput;
/*
* please finish this program to implement 3D points Transformation.
* input: pointcloudinput
* output: pointcloudoutput
* description: calculate pointcloudoutput by multipling Transformation matrix to pointcloudoutput
*/
return pointcloudoutput;
}
ros虚拟机
第一部分代码运行结果如图:
include
#include
#include
#include
#include
using namespace std;
class PointCloudOpt
{
public:
cv::Mat RaboutX(const double& theta);//rotation about X axis
cv::Mat RaboutY(const double& theta);//rotation about Y axis
cv::Mat RaboutZ(const double& theta);//rotation about Z axis
pcl::PointCloud pointCloudTranslation(const pcl::PointCloud& pointcloudinput) ;
pcl::PointCloud pointCloudRot(const pcl::PointCloud& pointcloudinput) ;
pcl::PointCloud pointCloudTransformation(const pcl::PointCloud& pointcloudinput) ;
pcl::PointCloud linkageTransformation(const pcl::PointCloud& pointcloudinput) ;
};
inline
cv::Mat PointCloudOpt::RaboutX(const double& theta)
{
cv::Mat raboutx = (cv::Mat_<double>(3,3) << 1, 0, 0,
0,cos(theta),-sin(theta),
0,sin(theta),cos(theta));
return raboutx;
}
inline
cv::Mat PointCloudOpt::RaboutY(const double& theta)
{
cv::Mat rabouty = (cv::Mat_<double>(3,3) << cos(theta), 0, sin(theta),
0, 1, 0,
-sin(theta),0, cos(theta));
return rabouty;
}
inline
cv::Mat PointCloudOpt::RaboutZ(const double& theta)
{
cv::Mat raboutz = (cv::Mat_<double>(3,3) << cos(theta),-sin(theta),0,
sin(theta), cos(theta),0,
0, 0, 1);
return raboutz;
}
代码能运行,且符合要求即可
具体你的代码调试下,输出下错误信息看看。