00001 /****************************************************************************** 00002 * \file 00003 * 00004 * $Id:$ 00005 * 00006 * Copyright (C) Brno University of Technology 00007 * 00008 * This file is part of software developed by dcgm-robotics@FIT group. 00009 * 00010 * Author: Vit Stancl (stancl@fit.vutbr.cz) 00011 * Supervised by: Michal Spanel (spanel@fit.vutbr.cz) 00012 * Date: dd/mm/2012 00013 * 00014 * This file is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation, either version 3 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This file is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this file. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #pragma once 00029 #ifndef COMPRESSED_PC_PUBLISHER_H_INCLUDED 00030 #define COMPRESSED_PC_PUBLISHER_H_INCLUDED 00031 00032 #include "ros/ros.h" 00033 #include <sensor_msgs/PointCloud2.h> 00034 #include <srs_env_model/OctomapUpdates.h> 00035 #include <pcl/point_types.h> 00036 #include <pcl/point_cloud.h> 00037 #include <image_geometry/pinhole_camera_model.h> 00038 #include <tf/transform_listener.h> 00039 #include <tf/message_filter.h> 00040 #include <message_filters/subscriber.h> 00041 00042 00043 namespace srs_env_model 00044 { 00045 00049 class CCompressedPCPublisher 00050 { 00051 public: 00053 typedef pcl::PointXYZRGB tPclPoint; 00054 00056 typedef pcl::PointCloud<tPclPoint> tPointCloudInternal; 00057 00059 typedef srs_env_model::OctomapUpdates tInputData; 00060 00062 typedef tInputData::_pointcloud2_type tInputCloudMsg; 00063 00065 typedef sensor_msgs::PointCloud2 tOutputCloudMsg; 00066 00068 typedef tInputData::_camera_info_type tCameraInfo; 00069 00070 public: 00072 CCompressedPCPublisher(ros::NodeHandle & nh); 00073 00074 protected: 00076 void incommingDataCB( const tInputData::ConstPtr & data ); 00077 00079 long copyCloud( const tInputCloudMsg & input, tPointCloudInternal & output, bool bAdd = false ); 00080 00082 long removeFrustumFromCloud( const tInputData::ConstPtr & data, tPointCloudInternal & cloud ); 00083 00085 bool isRGBCloud( const tInputCloudMsg & cloud ); 00086 00088 bool inSensorCone(const cv::Point2d& uv) const; 00089 00090 protected: 00092 std::string m_publishedTopicName; 00093 00095 ros::Publisher m_pub; 00096 00098 std::string m_subscribedTopicName; 00099 00101 // ros::Subscriber m_sub; 00102 message_filters::Subscriber<tInputData> m_sub; 00103 tf::MessageFilter<tInputData> * m_tf_filter; 00104 00106 tPointCloudInternal m_cloud; 00107 00109 int m_camera_stereo_offset_left, m_camera_stereo_offset_right; 00110 00112 cv::Size m_camera_size; 00113 00115 std::string m_cameraFrameId; 00116 00118 image_geometry::PinholeCameraModel m_camera_model; 00119 00121 tf::Transform m_to_sensor; 00122 00124 tf::Transform m_to_pfid; 00125 00127 std::string m_publishFID, m_cameraFID; 00128 00130 tf::TransformListener m_tfListener, m_tfListener2; 00131 00132 public: 00133 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00134 }; 00135 00136 00137 } // namespace srs_env_model 00138 00139 // COMPRESSED_PC_PUBLISHER_H_INCLUDED 00140 #endif 00141