00001
00002
00003
00004 #include <velodyne_pointcloud/pointcloudXYZIR.h>
00005
00006 namespace velodyne_pointcloud
00007 {
00008
00009 PointcloudXYZIR::PointcloudXYZIR(
00010 const double max_range, const double min_range,
00011 const std::string& target_frame, const std::string& fixed_frame,
00012 const unsigned int scans_per_block, boost::shared_ptr<tf::TransformListener> tf_ptr)
00013 : DataContainerBase(
00014 max_range, min_range, target_frame, fixed_frame,
00015 0, 1, true, scans_per_block, tf_ptr, 5,
00016 "x", 1, sensor_msgs::PointField::FLOAT32,
00017 "y", 1, sensor_msgs::PointField::FLOAT32,
00018 "z", 1, sensor_msgs::PointField::FLOAT32,
00019 "intensity", 1, sensor_msgs::PointField::FLOAT32,
00020 "ring", 1, sensor_msgs::PointField::UINT16),
00021 iter_x(cloud, "x"), iter_y(cloud, "y"), iter_z(cloud, "z"),
00022 iter_ring(cloud, "ring"), iter_intensity(cloud, "intensity")
00023 {};
00024
00025 void PointcloudXYZIR::setup(const velodyne_msgs::VelodyneScan::ConstPtr& scan_msg){
00026 DataContainerBase::setup(scan_msg);
00027 iter_x = sensor_msgs::PointCloud2Iterator<float>(cloud, "x");
00028 iter_y = sensor_msgs::PointCloud2Iterator<float>(cloud, "y");
00029 iter_z = sensor_msgs::PointCloud2Iterator<float>(cloud, "z");
00030 iter_intensity = sensor_msgs::PointCloud2Iterator<float>(cloud, "intensity");
00031 iter_ring = sensor_msgs::PointCloud2Iterator<uint16_t >(cloud, "ring");
00032 }
00033
00034 void PointcloudXYZIR::newLine()
00035 {}
00036
00037 void PointcloudXYZIR::addPoint(float x, float y, float z, uint16_t ring, uint16_t , float distance, float intensity)
00038 {
00039 if(!pointInRange(distance)) return;
00040
00041
00042
00043 if(config_.transform)
00044 transformPoint(x, y, z);
00045
00046 *iter_x = x;
00047 *iter_y = y;
00048 *iter_z = z;
00049 *iter_ring = ring;
00050 *iter_intensity = intensity;
00051
00052 ++cloud.width;
00053 ++iter_x;
00054 ++iter_y;
00055 ++iter_z;
00056 ++iter_ring;
00057 ++iter_intensity;
00058 }
00059 }
00060