18 #include <pcl/io/pcd_io.h> 19 #include <pcl/point_types.h> 20 #include "std_msgs/String.h" 21 #include "leica_scanstation_utils/LeicaUtils.h" 34 pub_ =
nh_.
advertise<sensor_msgs::PointCloud2>(
"simulator/cloud", 100,
false);
40 file_name_ = LeicaUtils::getFilePath(
"scan",
".pcd");
51 ROS_INFO(
"Saving the point cloud...");
67 sensor_msgs::PointCloud2 cloud,total_cloud_msg;
70 PointCloudXYZ::Ptr cloud_pcl;
75 scan->header.frame_id,
84 pcl::fromROSMsg(cloud, *cloud_pcl);
102 int main(
int argc,
char** argv)
105 ros::init(argc, argv,
"ScanToPointCloud");
108 ROS_INFO(
"tf from laserscan to pointcloud");
PointCloudXYZ::Ptr total_cloud_
Point cloud generated by the Leica.
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
tf::TransformListener tf_listener_
Reference system of the listener.
ScanToPointCloud(ros::NodeHandle nh)
Construct a new Scan To Point Cloud object.
laser_geometry::LaserProjection projector_
Instance of object LaserProjection to transform the laser scan into a point cloud.
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Subscriber sub_
Subscriber for the laser scan.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool init_cloud_
Attaches header info and more to total_cloud_ in the first iteration.
ROSCPP_DECL void spin(Spinner &spinner)
Duration & fromSec(double t)
ros::Subscriber filename_sub_
Subscriber to receive file name.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::NodeHandle nh_
Pointer to the ROS node.
bool saveCloudCb(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
Saves the cloud as .pcd format. The destination folder will be on package leica_scanstation_utils/poi...
void scanCb(const sensor_msgs::LaserScan::ConstPtr &scan)
Callback for adding the new scan to the point cloud.
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ
ros::Publisher pub_
Publisher for the point cloud.
std::string file_name_
File name to store point cloud scanned.
void filenameCb(const std_msgs::String::ConstPtr &msg)
Callback for read file name in which store point cloud scanned.
void transformLaserScanToPointCloud(const std::string &target_frame, const sensor_msgs::LaserScan &scan_in, sensor_msgs::PointCloud &cloud_out, tf::Transformer &tf, double range_cutoff, int channel_options=channel_option::Default)
ros::ServiceServer store_sub_
Service for saving the point cloud.
int counter_
Count number of scans finished to append on file name.
int main(int argc, char **argv)