FakePointCloudProvider.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::FakePointCloudProvider
19 * @author Markus Grotz ( markus-grotz at web dot de )
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#include <cmath>
28#include <filesystem>
29#include <mutex>
30#include <vector>
31
32#include <pcl/common/transforms.h>
33#include <pcl/filters/filter.h>
34#include <pcl/io/pcd_io.h>
35#include <pcl/point_types.h>
36
37#include <VirtualRobot/Robot.h>
38
41
43
44#include <RobotAPI/interface/core/RobotState.h>
45
48#include <VisionX/interface/components/FakePointCloudProviderInterface.h>
49
50
51class CByteImage;
52
53namespace visionx
54{
55 /// @class FakePointCloudProviderPropertyDefinitions
62
63 /**
64 * @class FakePointCloudProvider
65 * @ingroup VisionX-Components
66 * @brief A brief description
67 *
68 * Detailed Description
69 */
71 virtual public FakePointCloudProviderInterface,
72 virtual public CapturingPointCloudProvider,
73 virtual public ImageProvider,
75 {
76 public:
77 /// @see armarx::ManagedIceObject::getDefaultName()
78 std::string getDefaultName() const override;
79
80 protected:
81 /// @see visionx::PointCloudProviderBase::onInitPointCloudProvider()
83
84 /// @see visionx::PointCloudProviderBase::onExitPointCloudProvider()
86
87 /// @see visionx::PointCloudProviderBase::onStartCapture()
88 void onStartCapture(float frameRate) override;
89
90 /// @see visionx::PointCloudProviderBase::onStopCapture()
91 void onStopCapture() override;
92
93 /// @see visionx::PointCloudProviderBase::doCapture()
94 bool doCapture() override;
95
96 MetaPointCloudFormatPtr getDefaultPointCloudFormat() override;
97
98 /// @see visionx::CapturingImageProvider::onInitImageProvider()
99 void onInitImageProvider() override;
100
101 /// @see visionx::CapturingImageProvider::onExitImageProvider()
102 void onExitImageProvider() override;
103
104 StereoCalibration getStereoCalibration(const Ice::Current& = Ice::emptyCurrent) override;
105
106 bool getImagesAreUndistorted(const Ice::Current& = Ice::emptyCurrent) override;
107
108 std::string getReferenceFrame(const Ice::Current& = Ice::emptyCurrent) override;
109
110
111 // mixed inherited stuff
112 void onInitComponent() override;
113 void onConnectComponent() override;
114 void onDisconnectComponent() override;
115 void onExitComponent() override;
116
117 /// @see PropertyUser::createPropertyDefinitions()
119
120 void setPointCloudFilename(const std::string& filename,
121 const ::Ice::Current& = Ice::emptyCurrent) override;
122
123 bool hasSharedMemorySupport(const Ice::Current& = Ice::emptyCurrent) override;
124
125
126 private:
127 bool loadPointCloud(const std::string& fileName);
128 bool loadPointCloudDirectory(const std::string& directoryName);
129 bool loadCalibrationFile(std::string fileName, visionx::CameraParameters& calibration);
130
131 template <typename PointT>
132 bool processAndProvide(const pcl::PCLPointCloud2Ptr& pointCloud);
133 bool processRGBImage(const pcl::PCLPointCloud2Ptr& pointCloud);
134
135
136 armarx::RemoteGui::WidgetPtr buildGui();
137 void processGui(armarx::RemoteGui::TabProxy& prx);
138
139 private:
140 std::string pointCloudFileName;
141 /// Assume point cloud was stored in this frame.
142 std::string sourceFrameName;
143 /// Frame in which point cloud is provided. (armarx::GlobalFrame by default.)
144 std::string targetFrameName;
145 std::string providedPointCloudFormat;
146 std::string robotStateComponentName;
147
148 std::mutex pointCloudMutex;
149 std::vector<pcl::PCLPointCloud2Ptr> pointClouds;
150
151 std::atomic_int counter = 0;
152
153 std::atomic_bool rewind = false;
154 std::atomic_bool removeNAN = false;
155 std::atomic<float> scaleFactor = 0;
156 std::atomic_bool freezeImage = false;
157 std::atomic_int freezeImageIdx = 0;
158
159 StereoCalibration calibration;
160 CByteImage** rgbImages = nullptr;
161
162 armarx::RobotStateComponentInterfacePrx robotStateComponent;
163 VirtualRobot::RobotPtr localRobot;
164 };
165} // namespace visionx
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
The CapturingPointCloudProvider provides a callback function to trigger the capturing of point clouds...
void onInitComponent() override
Pure virtual hook for the subclass.
bool hasSharedMemorySupport(const Ice::Current &=Ice::emptyCurrent) override
void onDisconnectComponent() override
Hook for subclass.
bool getImagesAreUndistorted(const Ice::Current &=Ice::emptyCurrent) override
void onStartCapture(float frameRate) override
std::string getReferenceFrame(const Ice::Current &=Ice::emptyCurrent) override
MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
void onConnectComponent() override
Pure virtual hook for the subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void setPointCloudFilename(const std::string &filename, const ::Ice::Current &=Ice::emptyCurrent) override
void onExitComponent() override
Hook for subclass.
StereoCalibration getStereoCalibration(const Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
ImageProvider abstract class defines a component which provide images via ice or shared memory.
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.