PointCloudFilter.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::PointCloudFilter
19 * @author Markus Grotz ( markus dot grotz at kit dot edu )
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <mutex>
28
29#include <Eigen/Core>
30
31#include <pcl/common/transforms.h>
32#include <pcl/filters/approximate_voxel_grid.h>
33#include <pcl/filters/crop_hull.h>
34#include <pcl/filters/filter.h>
35#include <pcl/filters/passthrough.h>
36#include <pcl/point_types.h>
37
40
41#include <ArmarXGui/interface/RemoteGuiInterface.h>
43
44#include <RobotAPI/interface/core/PoseBase.h>
45#include <RobotAPI/interface/core/RobotState.h>
48
50#include <VisionX/interface/components/PointCloudFilter.h>
51
52namespace visionx
53{
54 class CoordinateFrame;
55 template <class PointT>
56 class FramedPointCloud;
57
58 /// @class PointCloudFilterPropertyDefinitions
65
66 /**
67 * @defgroup Component-PointCloudFilter PointCloudFilter
68 * @ingroup VisionX-Components
69 * A description of the component PointCloudFilter.
70 *
71 * @class PointCloudFilter
72 * @ingroup Component-PointCloudFilter
73 * @brief Brief description of class PointCloudFilter.
74 *
75 * Detailed description of class PointCloudFilter.
76 */
78 virtual public armarx::PointCloudFilterInterface,
79 virtual public visionx::PointCloudProcessor
80 {
81 public:
82 /// @see armarx::ManagedIceObject::getDefaultName()
83 virtual std::string getDefaultName() const override;
84
85 virtual std::string getReferenceFrame(const Ice::Current& = Ice::emptyCurrent) override;
86
87 virtual void setCroppingParameters(const armarx::Vector3BasePtr& min,
88 const armarx::Vector3BasePtr& max,
89 const std::string& frame,
90 const Ice::Current& = Ice::emptyCurrent) override;
91
92 protected:
93 /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
94 virtual void onInitPointCloudProcessor() override;
95
96 /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
97 virtual void onConnectPointCloudProcessor() override;
98
99 /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
100 virtual void onDisconnectPointCloudProcessor() override;
101
102 /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
103 virtual void onExitPointCloudProcessor() override;
104
105 /// @see visionx::PointCloudProcessor::process()
106 virtual void process() override;
107
108 template <typename PointType>
109 void processPointCloud();
110
111 /// @see PropertyUser::createPropertyDefinitions()
113
114
115 private:
116 /// Draw the given frame with given role.
117 void drawFrame(const armarx::FramedPose& frame, const std::string& role);
118
119 /// Change the point cloud to given frame.
120 /// Also logs transformation and draws target frame.
121 template <typename PointT>
122 void changePointCloudFrame(FramedPointCloud<PointT>& pointCloud,
123 const std::string& role,
124 const std::string& frame);
125
126 /// Create the remote gui. May only be called if `remoteGui` is not nullptr.
127 void remoteGuiCreate();
128 /// Create the remote gui. May only be called if `remoteGui` is not nullptr.
129 void remoteGuiRun();
130
131 void remoteGuiUpdate(armarx::RemoteGui::TabProxy& tab);
132
133
134 private:
135 // Robot
136 armarx::RobotStateComponentInterfacePrx robotStateComponent;
137 VirtualRobot::RobotPtr localRobot;
138
139 std::string pointCloudFormat;
140 std::string providerSourceFrameName; ///< Point cloud frame specified by provider.
141
142 struct Parameters
143 {
144 // Frames
145 std::string sourceFrameName;
146 std::string targetFrameName;
147
148 // Cropping
149 bool croppingEnabled;
150 Eigen::Vector3f croppingMinPoint;
151 Eigen::Vector3f croppingMaxPoint;
152 Eigen::Vector3f croppingRPY;
153 std::string croppingFrameName;
154
155 //SOR
157 {
158 bool enabled = false;
160 int meanK = 50;
161 };
162
163 StatisticalOutlierRemoval statisticalOutlierRemoval;
164
165 // Downsampling
166 bool downsamplingEnabled;
167 float gridLeafSize;
168
169 // Collision model filter
170 bool applyCollisionModelFilter;
171
172 bool reportCloudOutsideOfCroppingArea = false;
173
174 Eigen::Matrix4f providerFrameTransformation = Eigen::Matrix4f::Identity();
175 };
176
177 std::mutex parametersMutex;
178 Parameters parameters;
179
180
181 // Remote GUI
182 /// The remote GUI proxy. Only fetched when property `RemoteGuiEnabled` is true.
183 armarx::RemoteGuiInterfacePrx remoteGui;
184 /// The remote GUI tab.
185 armarx::RemoteGui::TabProxy remoteGuiTab;
186 /// The remote GUI main thread.
188
189
190 // Debug Drawer
192 };
193} // namespace visionx
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
The FramedPose class.
Definition FramedPose.h:281
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
A point cloud which keeps track of its reference coordinate frame and allows changing frames using ar...
Brief description of class PointCloudFilter.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
virtual void process() override
virtual void onExitPointCloudProcessor() override
virtual std::string getReferenceFrame(const Ice::Current &=Ice::emptyCurrent) override
virtual void onConnectPointCloudProcessor() override
virtual void onDisconnectPointCloudProcessor() override
virtual void setCroppingParameters(const armarx::Vector3BasePtr &min, const armarx::Vector3BasePtr &max, const std::string &frame, const Ice::Current &=Ice::emptyCurrent) override
virtual void onInitPointCloudProcessor() override
virtual std::string getDefaultName() const override
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
T min(T t1, T t2)
Definition gdiam.h:44
T max(T t1, T t2)
Definition gdiam.h:51
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
ArmarX headers.