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 #pragma once 00028 #ifndef LimitedPointCloudPlugin_H_included 00029 #define LimitedPointCloudPlugin_H_included 00030 00031 #include "point_cloud_plugin.h" 00032 00033 #include <srs_env_model_msgs/RVIZCameraPosition.h> 00034 #include <srs_env_model/but_server/server_tools.h> 00035 00036 #include <boost/scoped_ptr.hpp> 00037 #include <boost/thread/thread.hpp> 00038 #include <boost/thread/recursive_mutex.hpp> 00039 00040 00041 namespace srs_env_model 00042 { 00043 class CLimitedPointCloudPlugin : public CPointCloudPlugin 00044 { 00045 public: 00047 CLimitedPointCloudPlugin( const std::string & name ); 00048 00050 virtual ~CLimitedPointCloudPlugin(); 00051 00053 virtual void init(ros::NodeHandle & node_handle); 00054 00056 virtual void pause( bool bPause, ros::NodeHandle & node_handle); 00057 00059 virtual bool wantsMap() { return m_cameraFrameId.size() != 0; } 00060 00061 public: 00062 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00063 00064 protected: 00066 virtual void newMapDataCB( SMapWithParameters & par ); 00067 00069 virtual void handleOccupiedNode(tButServerOcTree::iterator& it, const SMapWithParameters & mp); 00070 00072 virtual void publishInternal(const ros::Time & timestamp); 00073 00075 void onCameraPositionChangedCB(const srs_env_model_msgs::RVIZCameraPosition::ConstPtr& position); 00076 00077 // main loop when spinning our own thread 00078 // - process callbacks in our callback queue 00079 // - process pending goals 00080 void spinThread(); 00081 00082 protected: 00084 bool m_bTransformCamera; 00085 00087 std::string m_cameraFrameId; 00088 00089 // Camera position topic name 00090 std::string m_cameraPositionTopic; 00091 00093 Eigen::Vector3f m_normal, m_normalBuf; 00094 00096 float m_d, m_dBuf; 00097 00099 Eigen::Matrix3f m_camToOcRot; 00100 00102 Eigen::Vector3f m_camToOcTrans; 00103 00105 // message_filters::Subscriber<srs_env_model_msgs::RVIZCameraPosition> *m_camPosSubscriber; 00106 ros::Subscriber m_camPosSubscriber; 00107 00109 tf::MessageFilter<srs_env_model_msgs::RVIZCameraPosition> *m_tfCamPosSub; 00110 00112 long m_countVisible, m_countHidden; 00113 00114 float min, max; 00115 00117 bool m_bSpinThread; 00118 00119 // these are needed when spinning up a dedicated thread 00120 boost::scoped_ptr<boost::thread> spin_thread_; 00121 ros::NodeHandle node_handle_; 00122 ros::CallbackQueue callback_queue_; 00123 volatile bool need_to_terminate_; 00124 00125 // Mutex used to lock camera position parameters 00126 boost::recursive_mutex m_camPosMutex; 00127 }; 00128 00129 } // namespace srs_env_model 00130 00131 // LimitedPointCloudPlugin_H_included 00132 #endif