I'm trying to view a .pcd file with rviz.
I wrote a little script to read the file and than publish it. (Yes I included way to many headers)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
pcl::PointCloud::Ptr loadPCDfile() //Laden eines PCD Files
{
//Nach dem Dateipfad fragen
std::string pcdpath;
std::cout << "Bitte Pfad+Name.pcd eingeben: ";
//Einagbe lesen
std::getline(std::cin, pcdpath);
//Ausgabe der Eingabe
//std::cout<< pcdpath << std::endl;
// Erkennen ob es sich um eine gültige Eingabe handelt (http://pointclouds.org/documentation/tutorials/reading_pcd.php)
pcl::PointCloud::Ptr pcdcloud(
new pcl::PointCloud);
if (pcl::io::loadPCDFile(pcdpath, *pcdcloud) == -1) //* load the file
{
std::cout << "Keine pcd Datei gefunden unter: " << pcdpath << std::endl;
}
return pcdcloud;
}
int main(int argc, char **argv) {
pcl::PointCloud::Ptr pcdcloud = loadPCDfile(); //Laden unserer PCD Datei
/*for (size_t i = 0; i < pcdcloud->points.size (); ++i)
std::cout << " " << pcdcloud->points[i].x
<< " " << pcdcloud->points[i].y
<< " " << pcdcloud->points[i].z << std::endl;
*/
// Initialize ROS
ros::init(argc, argv, "pcdcloud");
ros::NodeHandle nh;
// Create a ROS publisher for the output pointcloud
ros::Publisher pubrviz = nh.advertise>("pcdcloud", 1);
pubrviz.publish(pcdcloud);
ros::Rate loop_rate(10);
loop_rate.sleep();
// Spin
ros::spin();
return (0);
}
The reading Part should be fine, since I get a lot of points returned when I don't comment the for loop out.
When I build it I get no error returned.
But I can't get the rviz gui to show the cloud.
I used `rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map my_frame 10` to set up the tf map. [link](http://answers.ros.org/question/195962/rviz-fixed-frame-world-does-not-exist/?answer=232726#post-id-232726)
Probably I'm doing something wrong withing with the topic.
![image description](/upfiles/1498778735986663.png)
↧