ImageProviderDynamicSimulation.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 Nikolaus Vahrenkamp
20 * @date 2014
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <mutex>
28#include <string>
29
31
33#include <VisionX/interface/components/Calibration.h>
34#include <VisionX/interface/core/DataTypes.h>
35
36// IVT
37#include <VirtualRobot/Robot.h>
38#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
39
41
43#include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
44
45#include <Calibration/StereoCalibration.h>
46#include <Image/ByteImage.h>
47
48namespace armarx
49{
52 {
53 public:
56 {
57 defineOptionalProperty<float>("FrameRate", 30.0f, "Frames per second")
58 .setMatchRegex("\\d+(.\\d*)?")
59 .setMin(0.0f)
60 .setMax(60.0f);
62 "ImageSize",
63 visionx::ImageDimension(640, 480),
64 "Target resolution of the images. Captured images will be converted to this size.")
65 .setCaseInsensitive(true)
66 .map("320x240", visionx::ImageDimension(320, 240))
67 .map("640x480", visionx::ImageDimension(640, 480))
68 .map("800x600", visionx::ImageDimension(800, 600))
69 .map("768x576", visionx::ImageDimension(768, 576))
70 .map("1024x768", visionx::ImageDimension(1024, 768))
71 .map("1280x960", visionx::ImageDimension(1280, 960))
72 .map("1600x1200", visionx::ImageDimension(1600, 1200))
73 .map("none", visionx::ImageDimension(0, 0));
74 //defineOptionalProperty<std::string>("SimulatorControlName", "ArmarXSimulatorControl", "Name of the simulator control component that should be used");
75 defineOptionalProperty<std::string>("RobotName", "Armar3", "The robot");
76 defineOptionalProperty<std::string>("RobotNodeLeftCamera",
77 "EyeLeftCameraSim",
78 "The coordinate system of the left camera");
79 defineOptionalProperty<std::string>("RobotNodeRightCamera",
80 "EyeRightCameraSim",
81 "The coordinate system of the right camera");
83 "CalibrationFile",
84 "",
85 "Camera calibration file, will be made available in the SLICE interface");
87 "ReferenceFrame",
88 "EyeLeftCameraSim",
89 "Reference frame in the robot model of this stereo camera system.");
90 }
91 };
92
93 /**
94 * Image provider captures images from the simulator and broadcasts
95 * notifications at a specified frame rate.
96 *
97 * It supports the following image transmission formats:
98 *
99 * - RGB
100 * - Gray Scale
101 *
102 */
104 virtual public visionx::CapturingImageProvider,
105 virtual public visionx::StereoCalibrationCaptureProviderInterface
106 {
107 public:
108 std::string
109 getDefaultName() const override
110 {
111 return "DynamicSimulationImageProvider";
112 }
113
114
115 protected:
116 /**
117 * @see visionx::CapturingImageProvider::onInitCapturingImageProvider()
118 */
119 void onInitCapturingImageProvider() override;
120
121 /**
122 * @see visionx::CapturingImageProvider::onExitCapturingImageProvider()
123 */
124 void onExitCapturingImageProvider() override;
125
126 /**
127 * @see visionx::CapturingImageProvider::onStartCapture(float frameRate)
128 */
129 void onStartCapture(float frameRate) override;
130
131 /**
132 * @see visionx::CapturingImageProvider::onStopCapture()
133 */
134 void onStopCapture() override;
135
136 bool capture(void** ppImageBuffers) override;
137
138
139 /**
140 * Returns the StereoCalibration as provided in configuration
141 *
142 * @return visionx::StereoCalibration
143 */
144 visionx::StereoCalibration
145 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override;
146
147 /**
148 * Returns whether images are undistorted
149 *
150 * @return bool
151 */
152 bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override;
153 std::string getReferenceFrame(const ::Ice::Current& = Ice::emptyCurrent) override;
154
155 /**
156 * @see PropertyUser::createPropertyDefinitions()
157 */
160 {
164
165 props->defineOptionalProperty<float>("focalLength", 600, "The focal length.");
166
167 return props;
168 }
169
170 CByteImage** images;
171 CByteImage** resizedImages;
172
173 std::mutex captureMutex;
174
175 //VirtualRobot::RobotNodePtr leftCameraNode;
176 //VirtualRobot::RobotNodePtr rightCameraNode;
177
181
182 //RemoteRobotPtr remoteRobot;
183
185
186 //SimulatorControlInterfacePrx simulatorProxy;
187 /*std::string memoryNameLeft;
188 std::string memoryNameRight;
189 SharedMemoryConsumer<unsigned char>::pointer_type sharedMemoryConsumerLeft;
190 SharedMemoryConsumer<unsigned char>::pointer_type sharedMemoryConsumerRight;*/
191
192 std::shared_ptr<SoOffscreenRenderer> rendererLeft;
193 std::shared_ptr<SoOffscreenRenderer> rendererRight;
194
195 std::string robotName;
196 std::string leftNodeName;
197 std::string rightNodeName;
198 VirtualRobot::RobotNodePtr cameraNodeL;
199 VirtualRobot::RobotNodePtr cameraNodeR;
200
202
203 std::optional<visionx::StereoCalibration> stereoCalibration;
204
205 bool setupCameraRendering(const std::string& robotName,
206 const std::string& cameraSensorNameLeft,
207 const std::string& cameraSensorNameRight);
209
210 void initStereoCalib();
211
212 private:
213 };
214
215} // namespace armarx
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Image provider captures images from the simulator and broadcasts notifications at a specified frame r...
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Returns the StereoCalibration as provided in configuration.
bool setupCameraRendering(const std::string &robotName, const std::string &cameraSensorNameLeft, const std::string &cameraSensorNameRight)
std::optional< visionx::StereoCalibration > stereoCalibration
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::shared_ptr< SoOffscreenRenderer > rendererRight
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Returns whether images are undistorted.
std::string getReferenceFrame(const ::Ice::Current &=Ice::emptyCurrent) override
std::shared_ptr< SoOffscreenRenderer > rendererLeft
std::string getDefaultName() const override
Retrieve default name of component.
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 CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
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.