Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * pcl_adapter.h - Thread to exchange point clouds 00004 * 00005 * Created: Tue Nov 08 00:36:10 2011 00006 * Copyright 2011 Tim Niemueller [www.niemueller.de] 00007 ****************************************************************************/ 00008 00009 /* This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Library General Public License for more details. 00018 * 00019 * Read the full text in the LICENSE.GPL file in the doc directory. 00020 */ 00021 00022 #ifndef __PLUGINS_ROS_PCL_ADAPTER_H_ 00023 #define __PLUGINS_ROS_PCL_ADAPTER_H_ 00024 00025 #include <utils/time/time.h> 00026 00027 #include <map> 00028 #include <vector> 00029 #include <string> 00030 #include <stdint.h> 00031 00032 namespace fawkes { 00033 class PointCloudManager; 00034 class Logger; 00035 } 00036 00037 class RosPointCloudAdapter 00038 { 00039 public: 00040 /** Information about the data fields. */ 00041 class PointFieldInfo { 00042 public: 00043 std::string name; ///< Name of field 00044 uint32_t offset; ///< Offset from start of point struct 00045 uint8_t datatype; ///< Datatype enumeration see above 00046 uint32_t count; ///< How many elements in field 00047 00048 /** Constructor for pre-allocation. */ 00049 PointFieldInfo() {} 00050 /** Constructor. 00051 * @param name field name 00052 * @param offset data offset 00053 * @param datatype data type ID, see sensor_msgs::PointField 00054 * @param count number of data entries 00055 */ 00056 PointFieldInfo(std::string name, uint32_t offset, 00057 uint8_t datatype, uint32_t count) 00058 : name(name), offset(offset), datatype(datatype), count(count) {} 00059 }; 00060 /** Vector of PointFieldInfo. */ 00061 typedef std::vector<PointFieldInfo> V_PointFieldInfo; 00062 00063 RosPointCloudAdapter(fawkes::PointCloudManager *pcl_manager, 00064 fawkes::Logger *logger); 00065 ~RosPointCloudAdapter(); 00066 00067 void get_info(std::string &id, 00068 unsigned int &width, unsigned int &height, 00069 std::string &frame_id, bool &is_dense, 00070 V_PointFieldInfo &pfi); 00071 00072 void get_data(const std::string &id, 00073 unsigned int &width, unsigned int &height, fawkes::Time &time, 00074 void **data_ptr, size_t &point_size, size_t &num_points); 00075 00076 void close(const std::string &id); 00077 00078 private: 00079 fawkes::PointCloudManager *__pcl_manager; 00080 00081 class StorageAdapter; 00082 std::map<std::string, StorageAdapter *> __sas; 00083 }; 00084 00085 00086 #endif