23 #include "pcl_adapter.h" 25 #include <pcl/point_cloud.h> 26 #include <pcl/point_types.h> 27 #if PCL_VERSION_COMPARE(>=, 1, 7, 0) 28 # include <pcl/PCLPointField.h> 30 #include <logging/logger.h> 31 #include <pcl_utils/pointcloud_manager.h> 37 class PointCloudAdapter::StorageAdapter
76 : pcl_manager_(pcl_manager)
83 std::map<std::string, StorageAdapter *>::iterator i;
84 for (i = sas_.begin(); i != sas_.end(); ++i) {
98 template <
typename Po
intT>
101 unsigned int & width,
102 unsigned int & height,
103 std::string & frame_id,
109 frame_id = p->header.frame_id;
110 is_dense = p->is_dense;
112 #if PCL_VERSION_COMPARE(>=, 1, 7, 0) 113 std::vector<pcl::PCLPointField> pfields;
115 std::vector<sensor_msgs::PointField> pfields;
117 pcl::for_each_type<typename pcl::traits::fieldList<PointT>::type>(
118 pcl::detail::FieldAdder<PointT>(pfields));
121 pfi.resize(pfields.size());
122 for (
unsigned int i = 0; i < pfields.size(); ++i) {
123 #if PCL_VERSION_COMPARE(>=, 1, 7, 0) 124 pcl::PCLPointField &pf = pfields[i];
126 sensor_msgs::PointField &pf = pfields[i];
142 unsigned int & width,
143 unsigned int & height,
144 std::string & frame_id,
148 if (sas_.find(
id) == sas_.end()) {
155 fill_info(p, width, height, frame_id, is_dense, pfi);
160 fill_info(p, width, height, frame_id, is_dense, pfi);
165 fill_info(p, width, height, frame_id, is_dense, pfi);
168 throw Exception(
"PointCloud '%s' does not exist or unknown type",
id.c_str());
184 std::string & frame_id,
185 unsigned int & width,
186 unsigned int & height,
192 if (sas_.find(
id) == sas_.end()) {
220 std::string & frame_id,
222 unsigned int & width,
223 unsigned int & height,
230 get_info(
id, width, height, frame_id, is_dense, pfi);
231 get_data(
id, frame_id, width, height, time, data_ptr, point_size, num_points);
240 if (sas_.find(
id) != sas_.end()) {
std::vector< PointFieldInfo > V_PointFieldInfo
Vector of PointFieldInfo.
void close(const std::string &id)
Close an adapter.
Fawkes library namespace.
virtual unsigned int width() const =0
Get width of point cloud.
Information about the data fields.
~PointCloudAdapter()
Destructor.
A class for handling time.
virtual size_t point_size() const =0
Get size of a point.
virtual unsigned int height() const =0
Get height of point cloud.
void get_data_and_info(const std::string &id, std::string &frame_id, bool &is_dense, unsigned int &width, unsigned int &height, fawkes::Time &time, V_PointFieldInfo &pfi, void **data_ptr, size_t &point_size, size_t &num_points)
Get data and info of point cloud.
virtual std::string frame_id() const =0
Get frame ID of point cloud.
virtual void * data_ptr() const =0
Get pointer on data.
const RefPtr< const pcl::PointCloud< PointT > > get_pointcloud(const char *id)
Get point cloud.
Base class for exceptions in Fawkes.
PointCloudAdapter(fawkes::PointCloudManager *pcl_manager, fawkes::Logger *logger)
Constructor.
void get_info(const std::string &id, unsigned int &width, unsigned int &height, std::string &frame_id, bool &is_dense, V_PointFieldInfo &pfi)
Get info about point cloud.
virtual void get_time(fawkes::Time &time) const =0
Get last capture time.
RefPtr<> is a reference-counting shared smartpointer.
virtual size_t num_points() const =0
Get numer of points in point cloud.
void get_data(const std::string &id, std::string &frame_id, unsigned int &width, unsigned int &height, fawkes::Time &time, void **data_ptr, size_t &point_size, size_t &num_points)
Get current data of point cloud.
const pcl_utils::StorageAdapter * get_storage_adapter(const char *id)
Get a storage adapter.
bool exists_pointcloud(const char *id)
Check if point cloud exists.