MultiSensePointCloudProvider.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::MultiSensePointCloudProvider
19 * @author Markus Grotz ( markus dot grotz at kit dot edu )
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <Eigen/Core>
28
29#include <pcl/common/transforms.h>
30#include <pcl/filters/crop_box.h>
31#include <pcl/filters/filter.h>
32#include <pcl/io/pcd_io.h>
33#include <pcl/point_types.h>
34
35#include <opencv2/opencv.hpp>
36
38
41#include <VisionX/interface/components/PointCloudAndImageAndCalibrationProviderInterface.h>
42
43#include <Image/IplImageAdaptor.h>
44#include <MultiSense/MultiSenseChannel.hh>
45#include <MultiSense/MultiSenseTypes.hh>
46
47namespace armarx
48{
49
50 static Eigen::Vector4f
51 stringToVector4f(std::string propertyValue)
52 {
53 Eigen::Vector4f vec;
54 sscanf(propertyValue.c_str(),
55 "%f, %f, %f, %f",
56 &vec.data()[0],
57 &vec.data()[1],
58 &vec.data()[2],
59 &vec.data()[3]);
60 return vec;
61 }
62
63 /**
64 * @class MultiSensePointCloudProviderPropertyDefinitions
65 * @brief
66 */
69 {
70 public:
73 {
75
77 "minPoint", Eigen::Vector4f(-5000, -1e+06, -0, 1), "")
78 .setFactory(f);
80 "maxPoint", Eigen::Vector4f(1000, 1e+08, 1e+08, 1), "")
81 .setFactory(f);
82 defineOptionalProperty<std::string>("ipAddress", "10.66.171.21", "Description");
84 "enableLight", false, "Switch on the MultiSense LEDs on startup");
85 defineOptionalProperty<bool>("useLidar", false, "Use the laser for depth information");
86 defineOptionalProperty<std::string>("CalibrationFileName",
87 "VisionX/examples/camera_multisense.txt",
88 "Camera calibration file");
89 }
90 };
91
92 /**
93 * @defgroup Component-MultiSensePointCloudProvider MultiSensePointCloudProvider
94 * @ingroup VisionX-Components
95 * A description of the component MultiSensePointCloudProvider.
96 *
97 * @class MultiSensePointCloudProvider
98 * @ingroup Component-MultiSensePointCloudProvider
99 * @brief Brief description of class MultiSensePointCloudProvider.
100 *
101 * Detailed description of class MultiSensePointCloudProvider.
102 */
104 virtual public visionx::CapturingPointCloudAndImageAndStereoCalibrationProviderInterface,
106 virtual public visionx::ImageProvider
107 {
108 public:
109 /**
110 * @see armarx::ManagedIceObject::getDefaultName()
111 */
112 std::string
113 getDefaultName() const override
114 {
115 return "MultiSensePointCloudProvider";
116 }
117
118 void disparityImageCallback(const crl::multisense::image::Header& header);
119
120 void lumaImageCallback(const crl::multisense::image::Header& header);
121
122 void chromaImageCallback(const crl::multisense::image::Header& header);
123
124 void lidarScanCallback(const crl::multisense::lidar::Header& header);
125
126 protected:
127 /**
128 * @see visionx::PointCloudProviderBase::onInitPointCloudProvider()
129 */
130 void onInitCapturingPointCloudProvider() override;
131
132 /**
133 * @see visionx::PointCloudProviderBase::onExitPointCloudProvider()
134 */
135 void onExitCapturingPointCloudProvider() override;
136
137 /**
138 * @see visionx::PointCloudProviderBase::onStartCapture()
139 */
140 void onStartCapture(float frameRate) override;
141
142 /**
143 * @see visionx::PointCloudProviderBase::onStopCapture()
144 */
145 void onStopCapture() override;
146
147 /**
148 * @see visionx::PointCloudProviderBase::doCapture()
149 */
150 bool doCapture() override;
151
152 visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat() override;
153
154
155 /**
156 * @see visionx::CapturingImageProvider::onInitImageProvider()
157 */
158 void onInitImageProvider() override;
159
160 /**
161 * @see visionx::CapturingImageProvider::onExitImageProvider()
162 */
163 void
165 {
166 }
167
168 /**
169 * @see PropertyUser::createPropertyDefinitions()
170 */
172
173 void
179
180 void
186
187 void
193
194 void
200
201 visionx::MonocularCalibration
202 getMonocularCalibration(const ::Ice::Current& c = Ice::emptyCurrent) override;
203
204 visionx::StereoCalibration
205 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override;
206
207 bool
208 getImagesAreUndistorted(const ::Ice::Current& c = Ice::emptyCurrent) override
209 {
210 return false;
211 }
212
213 bool
214 hasSharedMemorySupport(const Ice::Current& c = Ice::emptyCurrent) override
215 {
216 return true;
217 }
218
219
220 private:
221 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointCloudData;
222
223 crl::multisense::Channel* driver;
224
225 boost::mutex dataMutex;
226
227 crl::multisense::DataSource mask;
228
229 bool hasNewDisparityData;
230 bool hasNewColorData;
231
232 std::vector<uint8_t> lumaData;
233 bool hasNewLumaData;
234
235 cv::Mat_<double> q_matrix;
236
237 cv::Mat rgbImage;
238 cv::Mat disparityImage;
239
240 Eigen::Matrix4f cameraToSpindle;
241 Eigen::Matrix4f laserToSpindle;
242
243 pcl::CropBox<pcl::PointXYZRGBA> cropBoxFilter;
244
245
246 visionx::StereoCalibration calibration;
247 CByteImage** rgbImages;
248 };
249} // namespace armarx
constexpr T c
virtual void onExitComponent()
Hook for subclass.
virtual void onDisconnectComponent()
Hook for subclass.
virtual void onConnectComponent()=0
Pure virtual hook for the subclass.
virtual void onInitComponent()=0
Pure virtual hook for the subclass.
Brief description of class MultiSensePointCloudProvider.
bool hasSharedMemorySupport(const Ice::Current &c=Ice::emptyCurrent) override
void disparityImageCallback(const crl::multisense::image::Header &header)
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
void lumaImageCallback(const crl::multisense::image::Header &header)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void lidarScanCallback(const crl::multisense::lidar::Header &header)
void onConnectComponent() override
Pure virtual hook for the subclass.
void chromaImageCallback(const crl::multisense::image::Header &header)
void onExitComponent() override
Hook for subclass.
bool getImagesAreUndistorted(const ::Ice::Current &c=Ice::emptyCurrent) override
visionx::MonocularCalibration getMonocularCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
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)
std::function< PropertyType(std::string)> PropertyFactoryFunction
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.
void onInitComponent() override
void onDisconnectComponent() override
Hook for subclass.
void onConnectComponent() override
void onExitComponent() override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.