运行 feature-based-icp-on-rgb-data实验记录

运行feature-based-icp-on-rgb-data

ROS中用rosbag记录的数据仿真时发布TF在RVIZ中遇到“Message removed because it is too old”的问题解决

即在launch文件顶部加入:<param name="use_sim_time" value="true"/>

然后在rosbag 节点加入:--clock

这样做的含义是所有node都使用仿真时间而不是ros time

rivz配置并保存

<launch>
    <node pkg="rviz" type="rviz" name="rviz" args="-d ~/catkin_ws/src/test.rviz" required="true" />
</launch>

请添加图片描述

//图像点云配准算法
Eigen::Matrix4f MapRecon::get_transformation(pcl::PointCloud<pcl::PointXYZRGB>::Ptr& old_pcl, pcl::PointCloud<pcl::PointXYZRGB>::Ptr& new_pcl){
    Eigen::Matrix4f Trans;  //T
    Trans = Matrix4f::Identity();
		//计算点云质心
        Centroid_A = compute_center_of_mass_xyz(old_pcl, this->idx_xyz[0]);
        //cout << "pointcloud A size: " << old_pcl->points.size()  << "\n "<< "Cemtroid_A: \n" << Cemtroid_A << endl;
        Centroid_B = compute_center_of_mass_xyz(new_pcl, this->idx_xyz[1]);
        //cout << "pointcloud B size: " << new_pcl->points.size() << "\n "<< "Cemtroid_B: \n" << Cemtroid_B << endl;
                                        // (1) Compute Cross Covariance Matrix from xyz points
    	//计算协方差矩阵
        Eigen::Matrix3f cov_A_B = MapRecon::cross_covariance_matrix( old_pcl, new_pcl);

                                        // (2) compute singular value decomposition (SVD) --> openCV2
                                        // A = USV*
                                        // Singular values --> D (Diagonal Matrix)
                                        // svd.singularValues();
                                        // svd.matrixU();  
                                        // svd.matrixV();
    //计算SVD分解,得到旋转矩阵
        Eigen::JacobiSVD<Eigen::MatrixXf> svd(cov_A_B, Eigen::ComputeThinU | Eigen::ComputeThinV);
        Eigen::Matrix3f Rotation = svd.matrixU() * (svd.matrixV().transpose());
	//计算平移向量
        Eigen::Vector3f translation = Centroid_A - Rotation * Centroid_B;
        Trans << Rotation(0,0), Rotation(0,1), Rotation(0,2), translation(0),
                 Rotation(1,0), Rotation(1,1), Rotation(1,2), translation(1),
                 Rotation(2,0), Rotation(2,1), Rotation(2,2), translation(2),
                 0,             0,             0,             1; 
    } 
    return Trans;             
}

GT

请添加图片描述

output

请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值