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 std::string getDefaultName() const override;
135
136 protected:
137 /**
138 * @see PropertyUser::createPropertyDefinitions()
139 */
141
142
143 // PointCloudProcessor interface
144 protected:
145 void onInitPointCloudProcessor() override;
146 void onConnectPointCloudProcessor() override;
147 void onExitPointCloudProcessor() override;
148 void process() override;
149
150
151 std::pair<armarx::Vector3fSeq, std::vector<VirtualRobot::VisualizationFactory::Color>>
152 removeRobotVoxels(const armarx::Vector3fSeq& gridPoints,
153 std::vector<VirtualRobot::VisualizationFactory::Color> const& gridColors,
154 const VirtualRobot::RobotPtr& robot,
155 float distanceThreshold);
157 const VirtualRobot::RobotPtr& robot,
158 float distanceThreshold);
159
160 std::string providerName;
161
162 std::string pointCloudFormat;
163
165
167
168 std::string sourceFrameName;
169
171
173 pcl::octree::OctreePointCloud<PointType>::Ptr octtree;
174 float gridLeafSize = 0.0f;
175 VirtualRobot::TriMeshModelPtr gridMesh;
176 armarx::Vector3fSeq gridPositions;
177 mutable std::mutex dataMutex;
179
180 Eigen::Vector3f croppingMin, croppingMax;
181 std::unique_ptr<armarx::IceReportSkipper> skipper;
182 std::unique_ptr<armarx::CycleUtil> cycleKeeper;
183
184
185 // VoxelGridMappingProviderInterface interface
186 void updateBoundaries();
187
188 public:
189 armarx::Vector3fSeq getFilledGridPositions(const Ice::Current&) const override;
190 ::Ice::Float getGridSize(const ::Ice::Current& = Ice::emptyCurrent) const override;
191 void startCollectingPointClouds(const Ice::Current&) override;
192 void stopCollectingPointClouds(const Ice::Current&) override;
193 void reset(const Ice::Current&) override;
194
195 // Component interface
196 public:
197 void componentPropertiesUpdated(const std::set<std::string>& changedProperties) override;
198 };
199} // 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
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.