DepthImageProviderDynamicSimulation.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2013-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
19 * @author Raphael Grimm
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 <chrono>
28#include <memory>
29#include <mutex>
30#include <random>
31
32#include <VirtualRobot/Robot.h>
33
35
38#include <VisionX/interface/components/RGBDImageProvider.h>
39
41
42#include <Inventor/SoOffscreenRenderer.h>
43
44class SoOffscreenRenderer;
45
46namespace armarx
47{
54
57 virtual public visionx::ImageProvider,
58 virtual public visionx::RGBDPointCloudProviderInterface
59 {
60 public:
63
64 std::string getDefaultName() const override;
65
66 bool hasSharedMemorySupport(const Ice::Current& c = Ice::emptyCurrent) override;
67
68 visionx::StereoCalibration
69 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override;
70
71 bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override;
72
73 std::string getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override;
74
75 protected:
77
80
81 void onStartCapture(float frameRate) override;
82 void onStopCapture() override;
83 bool doCapture() override;
84
85 void onInitImageProvider() override;
86 void onDisconnectComponent() override;
87
88 void onExitImageProvider() override;
89
90 // mixed inherited stuff
91 void onInitComponent() override;
92 void onConnectComponent() override;
93 void onExitComponent() override;
94
95 bool render();
96 void syncVisu();
97
98 std::mutex captureMutex;
99
100 short width; //coin uses short here
101 short height; //coin uses short here
102
103 float baseline;
104
106
107 std::string robotName;
108 std::string camNodeName;
109 VirtualRobot::RobotNodePtr cameraNode;
110 SoSeparator* visualization{nullptr};
111
112 bool floatImageMode{false};
113
114 std::unique_ptr<CByteImage> rgbImage;
115 std::unique_ptr<CByteImage> dImage;
116 std::unique_ptr<CFloatImage> dFloatImage;
117 CByteImage* imgPtr[2];
118 CFloatImage* imgPtrFlt[1];
119 std::vector<unsigned char> rgbBuffer;
120 std::vector<float> depthBuffer;
121 std::vector<Eigen::Vector3f> pointCloudBuffer;
122
123 float zNear;
124 float zFar;
125 float vertFov;
127 float nanValue;
128
129 using PointT = pcl::PointXYZRGBA;
130 pcl::PointCloud<PointT>::Ptr pointcloud;
131
132 //draw to debug drawer
137 std::chrono::high_resolution_clock::time_point lastUpdate;
139
141
145
149
150 std::size_t pointSkip;
151
152 float noise = 0.0f;
153 std::vector<float> randValues;
154 std::normal_distribution<double> distribution;
155 std::default_random_engine generator;
156 std::shared_ptr<SoOffscreenRenderer> offscreenRenderer;
157
158 std::int64_t sumRenderTimes;
160 std::int32_t renderTimesCount;
161 };
162} // namespace armarx
constexpr T c
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
bool hasSharedMemorySupport(const Ice::Current &c=Ice::emptyCurrent) override
void onInitComponent() override
Pure virtual hook for the subclass.
void onExitCapturingPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
std::chrono::high_resolution_clock::time_point lastUpdate
void onStartCapture(float frameRate) override
This is called when the point cloud provider capturing has been started.
void onInitCapturingPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void onStopCapture() override
This is called when the point cloud provider capturing has been stopped.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
std::string getDefaultName() const override
Retrieve default name of component.
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...
ImageProvider abstract class defines a component which provide images via ice or shared memory.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ArmarXPhysicsWorldVisualization > ArmarXPhysicsWorldVisualizationPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx