ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
There is probably a more direct method, but I've used PCL's .pcd
format to accomplish this. Use a ROS node to convert the PointCloud2 msg
into PCL's PointCloud<PointT>
type -- where PointT
is one of PointXYZ
, PointXYZRGB
, or PointXYZRGBA
-- and then save it in an ASCII-formatted .pcd
. (In a moment I'll post a link to a my node on GitHub)
In a ROS node, subscribe to a PointCloud2 topic, and within the subscriber, use the following:
pcl::PointCloud<pcl::PointXYZRGB> pclCloud; //create a pcl::PointCloud to be filled
pcl::fromROSMsg(*cloudMsg, pclCloud); //convert the msg->pcl::PointCloud
pcl::io::savePCDFileASCII( filename_ + ".pcd", pclCloud);
Then parse the .pcd
. For PointXYZRGB
, after the header the points are listed one per line: x y z rgb
. Note that PCL packs the RBG (and sometimes aplha) channels into a single float.
Related docs and tutorials: (coming soon)
2 | No.2 Revision |
There is probably a more direct method, but I've used PCL's .pcd
format to accomplish this. Use a ROS node to convert the PointCloud2 msg
into PCL's PointCloud<PointT>
type -- where PointT
is one of PointXYZ
, PointXYZRGB
, or PointXYZRGBA
-- and then save it in an ASCII-formatted .pcd
. (In a moment I'll post a link to a my node on GitHub)
In a ROS node, subscribe to a PointCloud2 topic, and within the subscriber, use the following:
pcl::PointCloud<pcl::PointXYZRGB> pclCloud; //create a pcl::PointCloud to be filled
pcl::fromROSMsg(*cloudMsg, pclCloud); //convert the msg->pcl::PointCloud
pcl::io::savePCDFileASCII( filename_ + ".pcd", pclCloud);
pclCloud); // save it
Then parse the .pcd
. For PointXYZRGB
, after the header the points are listed one per line: x y z rgb
. Note that PCL packs the RBG (and sometimes aplha) alpha) channels into a single float.
Related docs and tutorials: (coming soon)
.pcd
file | .pcd
file format 3 | No.3 Revision |
There is probably a more direct method, but I've used PCL's .pcd
format to accomplish this. Use a ROS node to convert the PointCloud2 msg
into PCL's PointCloud<PointT>
type -- where PointT
is one of PointXYZ
, PointXYZRGB
, or PointXYZRGBA
-- and then save it in an ASCII-formatted .pcd
. (In a moment I'll post a link to a my node (I have cpp code on GitHub)GitHub that does this.)
In a ROS node, subscribe to a PointCloud2 topic, and within the subscriber, use the following:
pcl::PointCloud<pcl::PointXYZRGB> pclCloud; //create a pcl::PointCloud to be filled
pcl::fromROSMsg(*cloudMsg, pclCloud); //convert the msg->pcl::PointCloud
pcl::io::savePCDFileASCII( filename_ + ".pcd", pclCloud); // save it
Then parse the .pcd
. For PointXYZRGB
, after the header the points are listed one per line: x y z rgb
. Note that PCL packs the RBG (and sometimes alpha) alpha, if you're using it) channels into a single float.
Related docs and tutorials: pcl::fromROSmsg | writing to a .pcd
file | .pcd
file format
4 | No.4 Revision |
There is probably a more direct method, but I've used PCL's .pcd
format to accomplish this. Use a ROS node to convert the PointCloud2 msg
into PCL's PointCloud<PointT>
type -- where PointT
is one of PointXYZ
, PointXYZRGB
, or PointXYZRGBA
-- and then save it in an ASCII-formatted .pcd
. (I have cpp code on GitHub that does this.)
In EDIT: Dan Lazewatsky pointed out pointcloud_to_pcd, which converts a ROS node, subscribe PointCloud2
msg to a PointCloud2 topic, and within .pcd
file. See his comment for the subscriber, use the following:docs.
pcl::PointCloud<pcl::PointXYZRGB> pclCloud; //create
Once you have it as
aThen parse the
.pcd
PointXYZRGB
x y z rgb
. Note that PCL packs the RBG (and alpha, if you're using it) channels into a single float. Related docs and tutorials: pcl::fromROSmsg | writing to a .pcd
file | .pcd
file format