ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Here is a sample that can solve your problem. This is a snippet and it should work properly with normal rate of 30Hz. If this is not solving then let me know about the exact problem.
//// c++ headers #include <iostream> // ROS headers #include <ros ros.h=""> #include <sensor_msgs pointcloud2.h=""> // point cloud definition typedef pcl::PointCloud<pcl::pointxyz> PointCloud; // namspace using namespace std; using namespace sensor_msgs;
void callback(const sensor_msgs::PointCloud2ConstPtr& pCloud) { // new cloud formation pcl::PointCloud<pcl::pointxyz>::Ptr cloud (new pcl::PointCloud<pcl::pointxyz>); pcl::fromROSMsg (*pCloud, *cloud);
// cloud is the one you are interested about. }
int main(int argc, char** argv) { ros::init(argc, argv, "test_node");
ros::NodeHandle nh;
ros::Rate rate(30); // frequency of operation
// subscribe
ros::Subscriber sub = nh.subscribe ("/camera/depth/points", 1, callback);
ros::spin();
return 0;
}
Regards, Prasanna
2 | No.2 Revision |
Here is a sample that can solve your problem. This is a snippet and it should work properly with normal rate of 30Hz. If this is not solving then let me know about the exact problem.
//// c++ headers
}
Regards, Prasanna