VoxelGridMappingProvider.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotComponents::ArmarXObjects::VoxelGridMappingProvider
17 * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25
26#include <mutex>
27
28#include <pcl/octree/octree.h>
29
30#include <VirtualRobot/VirtualRobot.h>
31#include <VirtualRobot/Visualization/VisualizationFactory.h>
32
35
36#include <RobotAPI/interface/core/RobotState.h>
38
40#include <VisionX/interface/components/VoxelGridProviderInterface.h>
41
42namespace armarx
43{
44 class IceReportSkipper;
45}
46
47namespace visionx
48{
49 /**
50 * @class VoxelGridMappingProviderPropertyDefinitions
51 * @brief
52 */
54 {
55 public:
58 {
60 "PointCloudLoadFilepath",
61 "",
62 "If set, the accumulated point cloud is loaded from the file");
64 "PointCloudStoreFilepath",
65 "",
66 "If set, the accumulated point cloud is stored to this file periodically");
68 "PointCloudStorageFrequency",
69 0.1f,
70 "Frequency at which the collected point cloud is stored.");
72 "RobotStateComponentName",
73 "RobotStateComponent",
74 "Name of the robot state component that should be used");
76 "providerName", "OpenNIPointCloudProvider", "name of the point cloud provider");
78 "",
79 "The source frame name. If unspecified the value "
80 "will be retrieved from the provider.");
82 "BoundingBox",
83 "0,6000;0,6000;100,2500",
84 "Point cloud points outside of this bouning box will be cropped",
87 50,
88 "Size in x,y,z dimension of each entry of the voxel grid",
91 "MinimumPointNumberPerVoxel",
92 10,
93 "Minimum number of points in a voxel of the grid to be considered a filled voxel.",
96 "UpdateRate", 2.0f, "Frequency how often the voxel grid is updated");
98 "ActivateOnStartUp",
99 true,
100 "If true, the component will start collection point cloud directly after start up. "
101 "Otherwise use interface functions.");
102
103 //defineRequiredProperty<std::string>("PropertyName", "Description");
104 //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
105 }
106 };
107
108 /**
109 * @defgroup Component-VoxelGridMappingProvider VoxelGridMappingProvider
110 * @ingroup RobotComponents-Components
111 * A description of the component VoxelGridMappingProvider.
112 *
113 * @class VoxelGridMappingProvider
114 * @ingroup Component-VoxelGridMappingProvider
115 * @brief Brief description of class VoxelGridMappingProvider.
116 *
117 * Detailed description of class VoxelGridMappingProvider.
118 */
120 virtual public visionx::PointCloudProcessor,
121 virtual public VoxelGridProviderInterface
122 {
123 public:
124 using PointType = pcl::PointXYZRGBA;
125 using Cloud = pcl::PointCloud<PointType>;
126 using CloudPtr = Cloud::Ptr;
127
129
130
131 /**
132 * @see armarx::ManagedIceObject::getDefaultName()
133 */
134 static std::string GetDefaultName();
135 std::string getDefaultName() const override;
136
137 protected:
138 /**
139 * @see PropertyUser::createPropertyDefinitions()
140 */
142
143
144 // PointCloudProcessor interface
145 protected:
146 void onInitPointCloudProcessor() override;
147 void onConnectPointCloudProcessor() override;
148 void onExitPointCloudProcessor() override;
149 void process() override;
150
151
152 std::pair<armarx::Vector3fSeq, std::vector<VirtualRobot::VisualizationFactory::Color>>
153 removeRobotVoxels(const armarx::Vector3fSeq& gridPoints,
154 std::vector<VirtualRobot::VisualizationFactory::Color> const& gridColors,
155 const VirtualRobot::RobotPtr& robot,
156 float distanceThreshold);
158 const VirtualRobot::RobotPtr& robot,
159 float distanceThreshold);
160
161 std::string providerName;
162
163 std::string pointCloudFormat;
164
166
168
169 std::string sourceFrameName;
170
172
174 pcl::octree::OctreePointCloud<PointType>::Ptr octtree;
175 float gridLeafSize = 0.0f;
176 VirtualRobot::TriMeshModelPtr gridMesh;
177 armarx::Vector3fSeq gridPositions;
178 mutable std::mutex dataMutex;
180
181 Eigen::Vector3f croppingMin, croppingMax;
182 std::unique_ptr<armarx::IceReportSkipper> skipper;
183 std::unique_ptr<armarx::CycleUtil> cycleKeeper;
184
185
186 // VoxelGridMappingProviderInterface interface
187 void updateBoundaries();
188
189 public:
190 armarx::Vector3fSeq getFilledGridPositions(const Ice::Current&) const override;
191 ::Ice::Float getGridSize(const ::Ice::Current& = Ice::emptyCurrent) const override;
192 void startCollectingPointClouds(const Ice::Current&) override;
193 void stopCollectingPointClouds(const Ice::Current&) override;
194 void reset(const Ice::Current&) override;
195
196 // Component interface
197 public:
198 void componentPropertiesUpdated(const std::set<std::string>& changedProperties) override;
199 };
200} // namespace visionx
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
std::unique_ptr< armarx::IceReportSkipper > skipper
pcl::octree::OctreePointCloud< PointType >::Ptr octtree
void componentPropertiesUpdated(const std::set< std::string > &changedProperties) override
Implement this function if you would like to react to changes in the properties.
std::pair< armarx::Vector3fSeq, std::vector< VirtualRobot::VisualizationFactory::Color > > removeRobotVoxels(const armarx::Vector3fSeq &gridPoints, std::vector< VirtualRobot::VisualizationFactory::Color > const &gridColors, const VirtualRobot::RobotPtr &robot, float distanceThreshold)
void startCollectingPointClouds(const Ice::Current &) override
void reset(const Ice::Current &) override
armarx::Vector3fSeq getFilledGridPositions(const Ice::Current &) const override
::Ice::Float getGridSize(const ::Ice::Current &=Ice::emptyCurrent) const override
void stopCollectingPointClouds(const Ice::Current &) override
void process() override
Process the vision component.
armarx::DebugDrawerInterfacePrx dd
void onExitPointCloudProcessor() override
Exit the ImapeProcessor component.
void onConnectPointCloudProcessor() override
Implement this method in the PointCloudProcessor in order execute parts when the component is fully i...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
VirtualRobot::TriMeshModelPtr gridMesh
std::unique_ptr< armarx::CycleUtil > cycleKeeper
armarx::RobotStateComponentInterfacePrx robotStateComponent
void onInitPointCloudProcessor() override
Setup the vision component.
std::string getDefaultName() const override
Retrieve default name of component.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
std::shared_ptr< class RobotPool > RobotPoolPtr
ArmarX headers.