NerianVisionPointCloudProvider.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package VisionX::ArmarXObjects::NerianVisionPointCloudProvider
17 * @author Julian Tusch <julian.tusch@student.kit.edu>
18 * @date 2025
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23
24#pragma once
25
26#include <string>
27#include <utility>
28
29#include <Eigen/Core>
30
31#include <pcl/impl/point_types.hpp>
32#include <pcl/point_cloud.h>
33
34#include <opencv2/opencv.hpp> // IWYU pragma: keep
35
36#include <Ice/Config.h>
37#include <Ice/Current.h>
38
43
46#include <VisionX/interface/components/Calibration.h>
47#include <VisionX/interface/components/NerianVisionPointCloudProviderInterface.h>
48#include <VisionX/interface/core/DataTypes.h>
49
50#include <visiontransfer/deviceinfo.h>
51
52namespace visionx
53{
54 /// @class NerianVisionPointCloudProviderPropertyDefinitions
57 {
58 public:
61 {
62 // these are the available resolutions (presets) for the Karmin and Ruby cameras
64 "dimensions",
65 visionx::ImageDimension(720, 512),
66 "Needs to be set according to the selected camera preset. This property will "
67 "be "
68 "used as a fallback if auto-detection fails.")
69 .map("720x512", visionx::ImageDimension(720, 512))
70 .map("1024x768", visionx::ImageDimension(1024, 768))
71 .map("1440x1054", visionx::ImageDimension(1440, 1056));
72 defineOptionalProperty<float>("MaxDepth", 6000.0f, "Max depth in mm.");
73 };
74 };
75
76 /**
77 * @defgroup Component-NerianVisionPointCloudProvider NerianVisionPointCloudProvider
78 * @ingroup VisionX-Components
79 * Provides support for Nerian Vision cameras for ArmarX.
80 *
81 * @class NerianVisionPointCloudProvider
82 * @ingroup Component-NerianVisionPointCloudProvider
83 * @brief Brief description of class NerianVisionPointCloudProvider.
84 */
86 virtual public armarx::NerianVisionPointCloudProviderInterface,
87 virtual public visionx::PointCloudProvider,
88 virtual public visionx::ImageProvider
89 {
90 public:
91 using CloudPointType = pcl::PointXYZRGBA;
92
93 /**
94 * @see armarx::ManagedIceObject::getDefaultName()
95 */
96 std::string
97 getDefaultName() const override
98 {
99 return "NerianVisionPointCloudProvider";
100 }
101
102 // StereoCalibrationInterface
103 visionx::StereoCalibration getStereoCalibration(const Ice::Current& c) override;
104 bool getImagesAreUndistorted(const ::Ice::Current& c) override;
105 std::string getReferenceFrame(const Ice::Current& c) override;
106
107 void startCapture(const Ice::Current& c) override;
108 void stopCapture(const Ice::Current& c) override;
109 void changeFrameRate(Ice::Float framesPerSecond, const Ice::Current& c) override;
110 void startCaptureForNumFrames(int numFrames, const Ice::Current& c) override;
111 bool isCaptureEnabled(const Ice::Current& c) override;
112
113 protected:
114 void onInitComponent() override;
115 void onInitImageProvider() override;
116 void onInitPointCloudProvider() override;
117
118 void onConnectComponent() override;
119 void onConnectImageProvider() override;
120 void onConnectPointCloudProvider() override;
121
123
124 void onDisconnectComponent() override;
125 void onDisconnectImageProvider() override;
126 // onDisconnectPointCloudProvider()
127
128 void onExitComponent() override;
129 void onExitImageProvider() override;
130 void onExitPointCloudProvider() override;
131
132 bool
133 hasSharedMemorySupport(const Ice::Current& /*c*/) override
134 {
135 return true;
136 }
137
138 MetaPointCloudFormatPtr
140 {
141 MetaPointCloudFormatPtr info = new MetaPointCloudFormat();
142 info->type = PointContentType::eColoredPoints;
143
144 ARMARX_INFO << "default pointcloud format: " << dimensions.width << ", "
145 << dimensions.height;
146
147 info->capacity = static_cast<::Ice::Int>(dimensions.width * dimensions.height *
148 sizeof(ColoredPoint3D));
149 info->size = info->capacity;
150 return info;
151 }
152
153 /**
154 * @see PropertyUser::createPropertyDefinitions()
155 */
157
158 static std::string
159 getNameForDeviceModel(const visiontransfer::DeviceInfo::DeviceModel& model)
160 {
161 using visiontransfer::DeviceInfo;
162 switch (model)
163 {
164 case DeviceInfo::DeviceModel::SCENESCAN:
165 return "SceneScan";
166 case DeviceInfo::DeviceModel::SCENESCAN_PRO:
167 return "SceneScan Pro";
168 case DeviceInfo::DeviceModel::SCARLET:
169 return "Scarlet";
170 case DeviceInfo::DeviceModel::RUBY:
171 return "Ruby";
172 default:
173 return "(INVALID_ENUM_VALUE)";
174 }
175 }
176
177 private:
178 visiontransfer::DeviceInfo device;
180 pcl::PointCloud<CloudPointType>::Ptr pointcloud;
181 MetaPointCloudFormatPtr cloudFormat;
182 visionx::ImageDimension dimensions;
183 };
184} // namespace visionx
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 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)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
ImageProvider abstract class defines a component which provide images via ice or shared memory.
Brief description of class NerianVisionPointCloudProvider.
void onInitComponent() override
Pure virtual hook for the subclass.
bool isCaptureEnabled(const Ice::Current &c) override
void changeFrameRate(Ice::Float framesPerSecond, const Ice::Current &c) override
void onConnectPointCloudProvider() override
This is called when the Component::onConnectComponent() setup is called.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectImageProvider() override
This is called when the Component::onConnectComponent() setup is called.
void onInitPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
bool hasSharedMemorySupport(const Ice::Current &) override
std::string getReferenceFrame(const Ice::Current &c) override
void startCaptureForNumFrames(int numFrames, const Ice::Current &c) override
MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
void onConnectComponent() override
Pure virtual hook for the subclass.
static std::string getNameForDeviceModel(const visiontransfer::DeviceInfo::DeviceModel &model)
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c) override
bool getImagesAreUndistorted(const ::Ice::Current &c) 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.
void onExitPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.