我嘗試用高斯分佈構建自己的點雲。 rviz的可視化不起作用。RVIZ:顯示自己的點雲
這裏是我創建點雲
int sizeOfCloud = 1000;
keypoints.points.resize(sizeOfCloud);
getRandomPointCloud(keypoints, 100, 100, sizeOfCloud);
keypoints.header.frame_id = "base_link";
keypoints.header.stamp = ros::Time::now();
keypoints_publisher.publish(keypoints);
,這裏是功能getRandomPointCloud:
void getRandomPointCloud(sensor_msgs::PointCloud& pc, int centerX, int centerY, int& sizeOfCloud) {
std::random_device rd;
std::mt19937 gen(rd());
std::normal_distribution<> distX(centerX, 10);
std::normal_distribution<> distY(centerY, 10);
for (int i = 0; i < pc.points.size(); i++) {
double xValue = distX(gen);
double yValue = distY(gen);
std::cout << std::round(xValue) << std::endl;
pc.points[i].x = std::round(xValue);
pc.points[i].y = std::round(yValue);
}
std::cout << "done" << std::endl;
}
正如我所說的,它不能在rviz顯示。我按主題選擇,選擇適當的主題,然後屏幕上沒有任何內容。主題是正確的,如果我將網格設置爲base_link,那麼包含該主題的所有內容都可以。也許我必須在rviz中設置一個特殊的屬性,否則我不會正確構建我的pointcloud。
編輯:
截圖現在,我認爲這個問題是更多關於「base_link」 TF話題不能得到解決。如果我試圖映射我的TF樹,那麼沒有條目。我如何在我的tf樹中設置base_link。或者我的目的還有另一種可能性嗎?
貴的問題得到解答,對我的作品的代碼? – cassinaj