48 #include <boost/filesystem.hpp> 51 #include <pcl/io/io.h> 52 #include <pcl/io/pcd_io.h> 64 main (
int argc,
char** argv)
69 std::cerr <<
"Syntax is: " << argv[0] <<
" <file_in.bag> <topic> <output_directory> [<target_frame>]" << std::endl;
70 std::cerr <<
"Example: " << argv[0] <<
" data.bag /laser_tilt_cloud ./pointclouds /base_link" << std::endl;
88 std::cerr <<
"Error opening file " << argv[1] << std::endl;
95 view_it = view.
begin ();
97 std::string output_dir = std::string (argv[3]);
98 boost::filesystem::path outpath (output_dir);
99 if (!boost::filesystem::exists (outpath))
101 if (!boost::filesystem::create_directories (outpath))
103 std::cerr <<
"Error creating directory " << output_dir << std::endl;
106 std::cerr <<
"Creating directory " << output_dir << std::endl;
110 std::cerr <<
"Saving recorded sensor_msgs::PointCloud2 messages on topic " << argv[2] <<
" to " << output_dir << std::endl;
115 while (view_it != view.
end ())
118 tf::tfMessage::ConstPtr
tf = view_it->instantiate<tf::tfMessage> ();
151 std::cerr <<
"Got " << cloud_t.width * cloud_t.height <<
" data points in frame " << cloud_t.header.frame_id <<
" with the following fields: " <<
pcl::getFieldsList (cloud_t) << std::endl;
153 std::stringstream ss;
154 ss << output_dir <<
"/" << cloud_t.header.stamp <<
".pcd";
155 std::cerr <<
"Data saved to " << ss.str () << std::endl;
157 Eigen::Quaternionf::Identity (),
true);
std::string getFieldsList(const sensor_msgs::PointCloud2 &cloud)
void open(std::string const &filename, uint32_t mode=bagmode::Read)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
sensor_msgs::PointCloud2 PointCloud
void addQuery(Bag const &bag, ros::Time const &start_time=ros::TIME_MIN, ros::Time const &end_time=ros::TIME_MAX)
PointCloud::Ptr PointCloudPtr
PointCloud::ConstPtr PointCloudConstPtr
int main(int argc, char **argv)
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const tf::Transform &transform)
Apply a rigid transform defined by a 3D offset and a quaternion.
ROSCPP_DECL void spinOnce()
int savePCDFile(const std::string &file_name, const sensor_msgs::PointCloud2 &cloud, const Eigen::Vector4f &origin=Eigen::Vector4f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity(), const bool binary_mode=false)