PointCloudUtility.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::ArmarXObjects::PointCloudUtility
19  * @author Tim Niklas Freudenstein ( uidnv at student dot kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 
28 #include <pcl/common/transforms.h>
29 #include <pcl/filters/approximate_voxel_grid.h>
30 #include <pcl/io/pcd_io.h>
31 #include <pcl/registration/icp.h>
32 #include <pcl/visualization/cloud_viewer.h>
33 
34 #include <VirtualRobot/MathTools.h>
35 
39 
40 namespace armarx
41 {
42  /**
43  * @class PointCloudUtilityPropertyDefinitions
44  * @brief
45  */
47  {
48  public:
51  {
52  defineRequiredProperty<std::string>("PointCloud1", "FileName1");
53  defineOptionalProperty<std::string>("PointCloud2", "", "FileName2");
54  defineOptionalProperty<bool>(
55  "Merge", true, "If set the program merges PointCloud1 and PointCloud2");
56  defineOptionalProperty<bool>(
57  "Transform",
58  true,
59  "If set the program transforms the merged Pointcloud or Pointcloud1");
60  defineOptionalProperty<bool>(
61  "Show",
62  true,
63  "If set the program shows the merged/transformed Pointcloud or Pointcloud1");
64  defineOptionalProperty<std::string>(
65  "ResultFileName", "result.pcd", "The filename of the output file");
66  defineOptionalProperty<float>("X", 0.0, "");
67  defineOptionalProperty<float>("Y", 0.0, "");
68  defineOptionalProperty<float>("Z", 0.0, "");
69  defineOptionalProperty<float>("Roll", 0.0, "");
70  defineOptionalProperty<float>("Pitch", 0.0, "");
71  defineOptionalProperty<float>("Yaw", 0.0, "");
72  }
73  };
74 
75  /**
76  * @defgroup Component-PointCloudUtility PointCloudUtility
77  * @ingroup VisionX-Components
78  * A description of the component PointCloudUtility.
79  *
80  * @class PointCloudUtility
81  * @ingroup Component-PointCloudUtility
82  * @brief Brief description of class PointCloudUtility.
83  *
84  * Detailed description of class PointCloudUtility.
85  */
86  class PointCloudUtility : virtual public armarx::Component
87  {
88  public:
89  /**
90  * @see armarx::ManagedIceObject::getDefaultName()
91  */
92  std::string
93  getDefaultName() const override
94  {
95  return "PointCloudUtility";
96  }
97 
98  private:
99  void fusePointclouds(std::string file1, std::string file2, std::string out);
100  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr loadPointCloud(std::string filename);
101  void moveOrigin(std::string file, std::string out, Eigen::Vector3f translation);
102  void rotatePointCloud(std::string file, std::string out, Eigen::Matrix3f rotation);
103  void transformPointcloud(std::string file, std::string out, Eigen::Matrix4f pose);
104  void showResult(std::string file);
106  void process();
107 
108  protected:
109  /**
110  * @see armarx::ManagedIceObject::onInitComponent()
111  */
112  void onInitComponent() override;
113 
114  /**
115  * @see armarx::ManagedIceObject::onConnectComponent()
116  */
117  void onConnectComponent() override;
118 
119  /**
120  * @see armarx::ManagedIceObject::onDisconnectComponent()
121  */
122  void onDisconnectComponent() override;
123 
124  /**
125  * @see armarx::ManagedIceObject::onExitComponent()
126  */
127  void onExitComponent() override;
128 
129  /**
130  * @see PropertyUser::createPropertyDefinitions()
131  */
133  };
134 } // namespace armarx
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::PointCloudUtility::onConnectComponent
void onConnectComponent() override
Definition: PointCloudUtility.cpp:187
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::PointCloudUtility::onExitComponent
void onExitComponent() override
Definition: PointCloudUtility.cpp:197
RunningTask.h
armarx::PointCloudUtility
Brief description of class PointCloudUtility.
Definition: PointCloudUtility.h:86
armarx::PointCloudUtility::onInitComponent
void onInitComponent() override
Definition: PointCloudUtility.cpp:154
armarx::PointCloudUtility::getDefaultName
std::string getDefaultName() const override
Definition: PointCloudUtility.h:93
filename
std::string filename
Definition: VisualizationRobot.cpp:86
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::PointCloudUtilityPropertyDefinitions::PointCloudUtilityPropertyDefinitions
PointCloudUtilityPropertyDefinitions(std::string prefix)
Definition: PointCloudUtility.h:49
armarx::PointCloudUtilityPropertyDefinitions
Definition: PointCloudUtility.h:46
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
armarx::PointCloudUtility::onDisconnectComponent
void onDisconnectComponent() override
Definition: PointCloudUtility.cpp:192
IceUtil::Handle
Definition: forward_declarations.h:30
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
ArmarXDataPath.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::PointCloudUtility::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PointCloudUtility.cpp:202