qq_25286153 2023-03-14 19:44 采纳率: 0%
浏览 5

点云矩阵平移旋转,ros虚拟机

问题遇到的现象和发生背景

ros虚拟机,点云矩阵平移旋转运算
第一部分代码给出来了,并且运行成功了
第二部分和第三部,不会

#include "PointCloudOpt.h"


pcl::PointCloud<pcl::PointXYZ> PointCloudOpt::pointCloudTranslation(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput)
{
  pcl::PointCloud<pcl::PointXYZ> 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;i<pointcloudinput.size();++i)
        {
            pointcloudoutput.at(i).x=pointcloudinput.at(i).x+0.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<pcl::PointXYZ> PointCloudOpt::pointCloudRot(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput)
{
  pcl::PointCloud<pcl::PointXYZ> 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<pcl::PointXYZ> PointCloudOpt::pointCloudTransformation(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput)
{
  pcl::PointCloud<pcl::PointXYZ> 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虚拟机

尝试过的解决方法

第一部分代码运行结果如图:

img


"PointCloudOpt.h"如下

include <iostream>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/io/ply_io.h>
#include <cv.h>
#include <highgui.h>
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<pcl::PointXYZ> pointCloudTranslation(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput);
  pcl::PointCloud<pcl::PointXYZ> pointCloudRot(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput);
  pcl::PointCloud<pcl::PointXYZ> pointCloudTransformation(const pcl::PointCloud<pcl::PointXYZ>& pointcloudinput);
  pcl::PointCloud<pcl::PointXYZ> linkageTransformation(const pcl::PointCloud<pcl::PointXYZ>& 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;
}

我想要达到的结果

代码能运行,且符合要求即可

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-03-14 21:25
    关注

    具体你的代码调试下,输出下错误信息看看。

    评论

报告相同问题?

问题事件

  • 创建了问题 3月14日

悬赏问题

  • ¥20 搭建三相栅极电路后高侧浮动地VS存在电容特性
  • ¥20 云卓h12pro 数传问题
  • ¥20 请问有人知道怎么用工艺库里面的sdb文件通过virtuoso导出来library里面每个cell的symbol吗?
  • ¥20 海思 nnie 编译 报错
  • ¥50 决策面并仿真,要求有仿真结果图
  • ¥15 springboot接入微信支付SDK
  • ¥50 大区域的遥感影像匹配 怎么做啊
  • ¥15 求解答:pytorch跑yolov8神经网络受挫
  • ¥20 Js代码报错问题不知道怎么解决
  • ¥15 gojs 点击按钮node的position位置进行改变,再次点击回到原来的位置