pointcloud_to_octomap_alg.cpp
Go to the documentation of this file.
00001 #include "pointcloud_to_octomap_alg.h"
00002 #include <limits>
00003 PointcloudToOctomapAlgorithm::PointcloudToOctomapAlgorithm(void)
00004 {
00005 }
00006 
00007 PointcloudToOctomapAlgorithm::~PointcloudToOctomapAlgorithm(void)
00008 {
00009 }
00010 
00011 void PointcloudToOctomapAlgorithm::config_update(Config& new_cfg, uint32_t level)
00012 {
00013   this->lock();
00014 
00015   // save the current configuration
00016   this->config_=new_cfg;
00017   
00018   this->unlock();
00019 }
00020 
00021 // PointcloudToOctomapAlgorithm Public API
00022 
00023 bool PointcloudToOctomapAlgorithm::isRunning(const std::string& file_name, const sensor_msgs::PointCloud2::ConstPtr& msg, const octomap::point3d& sensor_origin, const octomap::pose6d& frame_origin)
00024 {
00025     octomap::Pointcloud scan;
00026     for(unsigned int rr=0; rr<msg->height; ++rr){
00027         for(unsigned int cc=0; cc<msg->width; ++cc){
00028             unsigned int idx = rr*msg->width + cc;
00029             float *step = (float*)&msg->data[idx*msg->point_step];
00030             if (!isnan(step[0]) && !isnan(step[1]) && !isnan(step[2])){
00031                 scan.push_back(step[0], step[1], step[2]);
00032             }
00033         }
00034     }
00035 
00036     octomap::ColorOcTree occupancy_tree(0.004f);
00037     occupancy_tree.insertScan(scan, sensor_origin, frame_origin);
00038     occupancy_tree.write(file_name);
00039     //pcl::io::savePCDFile ( file_name, *cloud, origin, orientation, binary_mode );
00040     return true;
00041 }
00042 


iri_pointcloud_to_octomap
Author(s): Sergi Foix
autogenerated on Fri Dec 6 2013 21:26:04