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 
44 class SoOffscreenRenderer;
45 
46 namespace armarx
47 {
50  {
51  public:
53  };
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 
78  void onInitCapturingPointCloudProvider() override;
79  void onExitCapturingPointCloudProvider() override;
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;
126  float focalLength;
127  float nanValue;
128 
129  using PointT = pcl::PointXYZRGBA;
130  pcl::PointCloud<PointT>::Ptr pointcloud;
131 
132  //draw to debug drawer
134  std::string debugDrawerTopicName;
136  unsigned int pointCloudDrawDelay;
137  std::chrono::high_resolution_clock::time_point lastUpdate;
138  std::size_t pointCloudPointSize;
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;
159  std::int64_t sumRenderTimesSquared;
160  std::int32_t renderTimesCount;
161  };
162 } // namespace armarx
CapturingPointCloudProvider.h
armarx::DepthImageProviderDynamicSimulation::drawPointCloud
bool drawPointCloud
Definition: DepthImageProviderDynamicSimulation.h:133
armarx::DepthImageProviderDynamicSimulation::imgPtr
CByteImage * imgPtr[2]
Definition: DepthImageProviderDynamicSimulation.h:117
armarx::DepthImageProviderDynamicSimulation::nanValue
float nanValue
Definition: DepthImageProviderDynamicSimulation.h:127
armarx::DepthImageProviderDynamicSimulationPropertyDefinitions
Definition: DepthImageProviderDynamicSimulation.h:48
armarx::DepthImageProviderDynamicSimulation::rgbImage
std::unique_ptr< CByteImage > rgbImage
Definition: DepthImageProviderDynamicSimulation.h:114
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudZHi
float clipDrawnCloudZHi
Definition: DepthImageProviderDynamicSimulation.h:148
armarx::DepthImageProviderDynamicSimulation::imgPtrFlt
CFloatImage * imgPtrFlt[1]
Definition: DepthImageProviderDynamicSimulation.h:118
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::DepthImageProviderDynamicSimulation::dFloatImage
std::unique_ptr< CFloatImage > dFloatImage
Definition: DepthImageProviderDynamicSimulation.h:116
armarx::DepthImageProviderDynamicSimulation::height
short height
Definition: DepthImageProviderDynamicSimulation.h:101
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::DepthImageProviderDynamicSimulation::baseline
float baseline
Definition: DepthImageProviderDynamicSimulation.h:103
armarx::DepthImageProviderDynamicSimulation::onExitCapturingPointCloudProvider
void onExitCapturingPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: DepthImageProviderDynamicSimulation.cpp:331
armarx::DepthImageProviderDynamicSimulation::onStopCapture
void onStopCapture() override
This is called when the point cloud provider capturing has been stopped.
Definition: DepthImageProviderDynamicSimulation.cpp:247
armarx::DepthImageProviderDynamicSimulation::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: DepthImageProviderDynamicSimulation.cpp:256
armarx::DepthImageProviderDynamicSimulation::camNodeName
std::string camNodeName
Definition: DepthImageProviderDynamicSimulation.h:108
armarx::DepthImageProviderDynamicSimulation::focalLength
float focalLength
Definition: DepthImageProviderDynamicSimulation.h:126
armarx::DepthImageProviderDynamicSimulation::zNear
float zNear
Definition: DepthImageProviderDynamicSimulation.h:123
armarx::DepthImageProviderDynamicSimulation::dImage
std::unique_ptr< CByteImage > dImage
Definition: DepthImageProviderDynamicSimulation.h:115
armarx::DepthImageProviderDynamicSimulation::~DepthImageProviderDynamicSimulation
~DepthImageProviderDynamicSimulation() override
Definition: DepthImageProviderDynamicSimulation.cpp:251
armarx::DepthImageProviderDynamicSimulation::distribution
std::normal_distribution< double > distribution
Definition: DepthImageProviderDynamicSimulation.h:154
armarx::DepthImageProviderDynamicSimulation
Definition: DepthImageProviderDynamicSimulation.h:55
IceInternal::Handle< ArmarXPhysicsWorldVisualization >
armarx::DepthImageProviderDynamicSimulation::onConnectComponent
void onConnectComponent() override
Definition: DepthImageProviderDynamicSimulation.cpp:192
armarx::DepthImageProviderDynamicSimulation::pointcloud
pcl::PointCloud< PointT >::Ptr pointcloud
Definition: DepthImageProviderDynamicSimulation.h:130
armarx::DepthImageProviderDynamicSimulation::clipPointCloud
bool clipPointCloud
Definition: DepthImageProviderDynamicSimulation.h:140
ArmarXPhysicsWorldVisualization.h
armarx::DepthImageProviderDynamicSimulation::onExitComponent
void onExitComponent() override
Definition: DepthImageProviderDynamicSimulation.cpp:208
visionx::CapturingPointCloudProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingPointCloudProvider.h:214
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudYHi
float clipDrawnCloudYHi
Definition: DepthImageProviderDynamicSimulation.h:147
armarx::DepthImageProviderDynamicSimulation::generator
std::default_random_engine generator
Definition: DepthImageProviderDynamicSimulation.h:155
armarx::DepthImageProviderDynamicSimulation::getReferenceFrame
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
Definition: DepthImageProviderDynamicSimulation.cpp:320
armarx::DepthImageProviderDynamicSimulation::vertFov
float vertFov
Definition: DepthImageProviderDynamicSimulation.h:125
visionx::CapturingPointCloudProviderPropertyDefinitions
Definition: CapturingPointCloudProvider.h:38
armarx::DepthImageProviderDynamicSimulation::simVisu
ArmarXPhysicsWorldVisualizationPtr simVisu
Definition: DepthImageProviderDynamicSimulation.h:105
armarx::DepthImageProviderDynamicSimulation::DepthImageProviderDynamicSimulation
DepthImageProviderDynamicSimulation()=default
armarx::DepthImageProviderDynamicSimulation::zFar
float zFar
Definition: DepthImageProviderDynamicSimulation.h:124
armarx::DepthImageProviderDynamicSimulation::onExitImageProvider
void onExitImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: DepthImageProviderDynamicSimulation.cpp:424
armarx::DepthImageProviderDynamicSimulation::noise
float noise
Definition: DepthImageProviderDynamicSimulation.h:152
armarx::DepthImageProviderDynamicSimulation::width
short width
Definition: DepthImageProviderDynamicSimulation.h:100
armarx::DepthImageProviderDynamicSimulation::rgbBuffer
std::vector< unsigned char > rgbBuffer
Definition: DepthImageProviderDynamicSimulation.h:119
armarx::DepthImageProviderDynamicSimulation::lastUpdate
std::chrono::high_resolution_clock::time_point lastUpdate
Definition: DepthImageProviderDynamicSimulation.h:137
Component.h
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudXHi
float clipDrawnCloudXHi
Definition: DepthImageProviderDynamicSimulation.h:146
visionx::CapturingPointCloudProvider
The CapturingPointCloudProvider provides a callback function to trigger the capturing of point clouds...
Definition: CapturingPointCloudProvider.h:56
armarx::DepthImageProviderDynamicSimulation::pointCloudDrawDelay
unsigned int pointCloudDrawDelay
Definition: DepthImageProviderDynamicSimulation.h:136
visionx::ImageProvider
ImageProvider abstract class defines a component which provide images via ice or shared memory.
Definition: ImageProvider.h:66
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudYLo
float clipDrawnCloudYLo
Definition: DepthImageProviderDynamicSimulation.h:143
armarx::DepthImageProviderDynamicSimulation::onInitCapturingPointCloudProvider
void onInitCapturingPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
Definition: DepthImageProviderDynamicSimulation.cpp:326
armarx::DepthImageProviderDynamicSimulation::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: DepthImageProviderDynamicSimulation.cpp:416
armarx::DepthImageProviderDynamicSimulation::onInitImageProvider
void onInitImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: DepthImageProviderDynamicSimulation.cpp:356
armarx::DepthImageProviderDynamicSimulation::robotName
std::string robotName
Definition: DepthImageProviderDynamicSimulation.h:107
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudXLo
float clipDrawnCloudXLo
Definition: DepthImageProviderDynamicSimulation.h:142
armarx::DepthImageProviderDynamicSimulation::onInitComponent
void onInitComponent() override
Definition: DepthImageProviderDynamicSimulation.cpp:137
armarx::DepthImageProviderDynamicSimulation::sumRenderTimes
std::int64_t sumRenderTimes
Definition: DepthImageProviderDynamicSimulation.h:158
armarx::DepthImageProviderDynamicSimulation::pointCloudPointSize
std::size_t pointCloudPointSize
Definition: DepthImageProviderDynamicSimulation.h:138
armarx::DepthImageProviderDynamicSimulation::clipDrawnCloudZLo
float clipDrawnCloudZLo
Definition: DepthImageProviderDynamicSimulation.h:144
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::DepthImageProviderDynamicSimulation::doCapture
bool doCapture() override
Main capturing function.
Definition: DepthImageProviderDynamicSimulation.cpp:435
armarx::DepthImageProviderDynamicSimulation::render
bool render()
Definition: DepthImageProviderDynamicSimulation.cpp:552
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::DepthImageProviderDynamicSimulation::getStereoCalibration
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Definition: DepthImageProviderDynamicSimulation.cpp:268
armarx::DepthImageProviderDynamicSimulation::visualization
SoSeparator * visualization
Definition: DepthImageProviderDynamicSimulation.h:110
armarx::DepthImageProviderDynamicSimulation::depthBuffer
std::vector< float > depthBuffer
Definition: DepthImageProviderDynamicSimulation.h:120
armarx::DepthImageProviderDynamicSimulationPropertyDefinitions::DepthImageProviderDynamicSimulationPropertyDefinitions
DepthImageProviderDynamicSimulationPropertyDefinitions(std::string prefix)
Definition: DepthImageProviderDynamicSimulation.cpp:47
armarx::DepthImageProviderDynamicSimulation::PointT
pcl::PointXYZRGBA PointT
Definition: DepthImageProviderDynamicSimulation.h:129
armarx::DepthImageProviderDynamicSimulation::pointCloudBuffer
std::vector< Eigen::Vector3f > pointCloudBuffer
Definition: DepthImageProviderDynamicSimulation.h:121
armarx::DepthImageProviderDynamicSimulation::debugDrawerTopicName
std::string debugDrawerTopicName
Definition: DepthImageProviderDynamicSimulation.h:134
armarx::DepthImageProviderDynamicSimulation::offscreenRenderer
std::shared_ptr< SoOffscreenRenderer > offscreenRenderer
Definition: DepthImageProviderDynamicSimulation.h:156
armarx::DepthImageProviderDynamicSimulation::syncVisu
void syncVisu()
Definition: DepthImageProviderDynamicSimulation.cpp:707
armarx::DepthImageProviderDynamicSimulation::getImagesAreUndistorted
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Definition: DepthImageProviderDynamicSimulation.cpp:314
armarx::DepthImageProviderDynamicSimulation::debugDrawer
DebugDrawerInterfacePrx debugDrawer
Definition: DepthImageProviderDynamicSimulation.h:135
armarx::DepthImageProviderDynamicSimulation::randValues
std::vector< float > randValues
Definition: DepthImageProviderDynamicSimulation.h:153
armarx::DepthImageProviderDynamicSimulation::onStartCapture
void onStartCapture(float frameRate) override
This is called when the point cloud provider capturing has been started.
Definition: DepthImageProviderDynamicSimulation.cpp:217
armarx::DepthImageProviderDynamicSimulation::hasSharedMemorySupport
bool hasSharedMemorySupport(const Ice::Current &c=Ice::emptyCurrent) override
Definition: DepthImageProviderDynamicSimulation.cpp:262
armarx::DepthImageProviderDynamicSimulation::pointSkip
std::size_t pointSkip
Definition: DepthImageProviderDynamicSimulation.h:150
ImageProvider.h
armarx::DepthImageProviderDynamicSimulation::captureMutex
std::mutex captureMutex
Definition: DepthImageProviderDynamicSimulation.h:98
armarx::DepthImageProviderDynamicSimulation::floatImageMode
bool floatImageMode
Definition: DepthImageProviderDynamicSimulation.h:112
armarx::DepthImageProviderDynamicSimulation::cameraNode
VirtualRobot::RobotNodePtr cameraNode
Definition: DepthImageProviderDynamicSimulation.h:109
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::DepthImageProviderDynamicSimulation::renderTimesCount
std::int32_t renderTimesCount
Definition: DepthImageProviderDynamicSimulation.h:160
armarx::DepthImageProviderDynamicSimulation::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DepthImageProviderDynamicSimulation.cpp:429
armarx::DepthImageProviderDynamicSimulation::sumRenderTimesSquared
std::int64_t sumRenderTimesSquared
Definition: DepthImageProviderDynamicSimulation.h:159