我尝试在qtvtk小部件上可视化实时sensor_msgs/PointCloud 2,而不是从阅读。pcd文件。我将分享一个代码的例子,从。pcd文件。
void MainWindow::imageShowLIDAR( const sensor_msgs::PointCloud2& msg)
{
//std::cout << "carico file" << std::endl;
std::cout << "imageshow lidar initiated" << std::endl;
cloud_pcl.reset (new PointCloudT);
cloud_pcl->resize (200);
red = 128;
green = 128;
blue = 128;
pcl::io::loadPCDFile("/home/rack_dl/RCEDS_V5/Data/pcl1.pcd", *cloud_pcl);
//pcl::io::loadPCDFile("/home/rack_dl/RCEDS_V5/Data/Reg.pcd", *cloud_pcl);
for (auto& point: *cloud_pcl)
{
//point.x = 1024 * rand () / (RAND_MAX + 1.0f);
//point.y = 1024 * rand () / (RAND_MAX + 1.0f);
//point.z = 1024 * rand () / (RAND_MAX + 1.0f);
point.r = red;
point.g = green;
point.b = blue;
}
viewer_pcl.reset(new pcl::visualization::PCLVisualizer("viewer_pcl", false));
//Set viewer settings
viewer_pcl->addCoordinateSystem(3.0, "coordinate");
viewer_pcl->setShowFPS(false);
viewer_pcl->setBackgroundColor(0.0, 0.0, 0.0, 0);
//viewer_pcl->setCameraPosition(0.0, 0.0, 30.0, 0.0, 1.0, 0.0, 0);
ui.LIDAR_Widget->SetRenderWindow(viewer_pcl->getRenderWindow());
viewer_pcl->setupInteractor(ui.LIDAR_Widget->GetInteractor(), ui.LIDAR_Widget->GetRenderWindow());
viewer_pcl->addPointCloud (cloud_pcl, "cloud");
viewer_pcl->resetCamera ();
ui.LIDAR_Widget->update();
}
我正在接收sensor_msgs/PointCloud 2上的数据
而不是从阅读。pcd文件我想实时可视化.我该怎么做?
1条答案
按热度按时间yhuiod9q1#
正如@伊格纳西奥所说。你应该看看pcl_conversions包!
下面是ROS 2中的回调示例:
对于ROS 1,您应该稍微更改
#include
和名称空间。但代码几乎是一样的。您可以看一下github repo示例,了解它应该是什么样子。对于实时可视化更新,您应该查看official pcl tutorial。