34#include <VisionX/interface/core/DataTypes.h>
35#include <VisionX/interface/core/PointCloudProcessorInterface.h>
38#include <condition_variable>
40#include <shared_mutex>
42#include <IceUtil/IceUtil.h>
86 PointCloudProviderInterfacePrx
proxy;
126 template <
typename Po
intCloudPtrT>
152 std::string resultPointCloudProviderName;
156 PointContentType pointContentType;
179 virtual public PointCloudProcessorInterface
231 template <
typename Po
intT>
244 ARMARX_ERROR <<
"unable to determine shared memory capacity for result provider. "
245 "(result provider is not enabled!)";
249 template <
typename Po
intT>
252 const std::string& resultProviderName =
"")
258 MetaPointCloudFormatPtr info =
270 ARMARX_ERROR <<
"unable to determine shared memory capacity for result provider. "
271 "(result provider is not enabled!)"
272 <<
"\nThe according input provider is " << inputProviderName;
278 PointContentType pointContentType);
286 template <
typename Po
intCloudPtrT>
304 ARMARX_WARNING <<
"unable to find provider name: " << providerName
305 <<
"\nknown names :\n"
310 template <
typename Po
intCloudPtrT>
378 template <
typename Po
intCloudPtrT>
384 ARMARX_ERROR <<
"Calling getPointClouds without PointCloudProvider name but using "
385 "multiple PointCloudProviders or without usingPointCloudProvider";
421 template <
typename Po
intCloudPtrT>
425 using PointCloudT =
typename PointCloudPtrT::element_type;
426 using PointT =
typename PointCloudT::PointType;
428 if (pointClouds == NULL)
437 std::map<std::string, PointCloudProviderInfo>::iterator iter =
442 ARMARX_ERROR <<
"Trying to retrieve PointClouds from unknown PointCloud provider. "
443 "Call usingPointCloudProvider before";
448 if (!iter->second.pointCloudAvailable)
450 ARMARX_WARNING <<
"no point cloud available. use waitForPointCloud()";
463 <<
" differs from provided format ("
465 <<
"\nbut automatic type conversion is disabled."
466 <<
"\nTo enable automatic type conversion, set the property "
467 "'AutomaticTypeConversion' to true"
468 <<
"\n (make sure your point cloud processor's properties derive "
469 "from 'PointCloudProcessorPropertyDefinitions')."
470 <<
"\nThe received point cloud will appear empty.";
479 std::vector<Ice::Byte> blob =
481 blob.swap(providerInfo.
buffer);
490 void* bufferPtr = providerInfo.
buffer.data();
491 void** bufferPtrPtr = &bufferPtr;
504 iter->second.pointCloudAvailable =
false;
506 IceUtil::Time timeReceived = IceUtil::Time::now();
507 IceUtil::Time timeProvided =
514 long transferTime = (timeReceived - timeProvided).toMilliSeconds();
516 ARMARX_DEBUG <<
"received point cloud size: " << pointClouds->width <<
"x"
517 << pointClouds->height <<
". took " << transferTime <<
" ms.";
538 bool resetStats =
false);
547 const std::string& defaultFrame =
"");
628 const Ice::Current&
c = Ice::emptyCurrent)
override;
641 std::map<std::string, IceInternal::Handle<ResultPointCloudProvider>>
Default component property definition container.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Property< PropertyType > getProperty(const std::string &name)
IceUtil::Handle< IceSharedMemoryConsumer< MemoryObject, MemoryObjectMetaInfo > > pointer_type
pointer type for convenience.
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
void waitForProxy(std::string const &name, bool addToDependencies)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
PointCloudProcessorPropertyDefinitions(std::string prefix)
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
virtual void onInitComponent() override
void releasePointCloudProvider(std::string providerName)
Removes topic subscription and provider proxy dependency to release a point cloud provider.
std::string getPointCloudFrame(const std::string &providerName, const std::string &defaultFrame="")
Get the reference frame of the point cloud by given provider.
virtual void process()=0
Process the vision component.
virtual void onInitPointCloudProcessor()=0
Setup the vision component.
void enableResultPointCloudForInputProvider(const std::string &inputProviderName, const std::string &resultProviderName="")
std::map< std::string, IceInternal::Handle< ResultPointCloudProvider > > resultPointCloudProviders
std::map< std::string, PointCloudTransferStats > statistics
bool isPointCloudProviderKnown(const std::string &providerName) const
Indicate whether the given name identifies a known point cloud provider.
void enableResultPointClouds(std::string resultProviderName="")
Enables visualization.
virtual void onDisconnectComponent() override
void usingPointCloudProviderFromProperty(const std::string &prop)
int getPointClouds(const PointCloudPtrT &pointCloudPtr)
Poll PointClouds from provider.
void provideResultPointClouds(const std::string &providerName, const PointCloudPtrT &pointClouds)
virtual void runProcessor()
virtual void onConnectPointCloudProcessor()=0
Implement this method in the PointCloudProcessor in order execute parts when the component is fully i...
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
std::shared_mutex pointCloudProviderInfoMutex
std::shared_mutex resultProviderMutex
PointCloudProviderMap usedPointCloudProviders
void usingPointCloudProvider(std::string providerName)
Registers a delayed topic subscription and a delayed provider proxy retrieval which will be available...
virtual void onDisconnectPointCloudProcessor()
Implement this method in the PointCloudProcessor in order execute parts when the component looses net...
virtual void onConnectComponent() override
PointCloudProviderInfo getPointCloudProvider(std::string name, bool waitForProxy=false)
Select an PointCloudProvider.
bool pointCloudHasNewData(std::string providerName)
Returns current status for the given point cloud.
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
armarx::RunningTask< PointCloudProcessor >::pointer_type processorTask
PointCloudTransferStats getPointCloudTransferStats(std::string providerName, bool resetStats=false)
Retrieve statistics for a connection to an PointCloudProvider.
void provideResultPointClouds(const PointCloudPtrT &pointClouds, std::string providerName="")
sends result PointClouds for visualization
virtual void onExitComponent() override
std::vector< std::string > getPointCloudProviderNames() const
Get the names of providers for which usingPointCloudProvider() has been called.
virtual void onExitPointCloudProcessor()=0
Exit the ImapeProcessor component.
bool getPointClouds(std::string providerName, const PointCloudPtrT &pointClouds)
Poll PointClouds from provider.
void reportPointCloudAvailable(const std::string &providerName, const Ice::Current &c=Ice::emptyCurrent) override
Listener callback function.
std::map< std::string, PointCloudProviderInfo > pointCloudProviderInfoMap
std::map< std::string, armarx::IceSharedMemoryConsumer< unsigned char, MetaPointCloudFormat >::pointer_type > PointCloudProviderMap
std::mutex statisticsMutex
ImageTransferMode pointCloudTransferMode
Transfer mode of images.
PointCloudProviderInterfacePrx proxy
Proxy to PointCloud provider.
MetaPointCloudFormatPtr pointCloudFormat
PointCloud format struct that contains all necessary PointCloud information.
std::vector< unsigned char > buffer
Memory block.
std::shared_ptr< std::condition_variable > pointCloudAvailableEvent
Conditional variable used internally for synchronization purposes.
bool pointCloudAvailable
Indicates whether an PointCloud is available.
PointCloudProviderPropertyDefinitions(std::string prefix)
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
void providePointCloud(PointCloudPtrT pointCloudPtr)
offer the new point cloud.
The PointCloudTransferStats class provides information on the connection between PointCloudProvider a...
FPSCounter pollingFPS
Statistics for the PointClouds polled by the PointCloudProcessor.
PointCloudTransferStats()
FPSCounter pointCloudProviderFPS
Statistics for the PointClouds announced by the PointCloudProvider.
ResultPointCloudProviderPropertyDefinitions(std::string prefix)
PointContentType getPointContentType() const
void setShmCapacity(size_t shmCapacity)
void provideResultPointClouds(PointCloudPtrT pointCloudPtr)
void setPointContentType(PointContentType type)
virtual void onInitPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
friend class PointCloudProcessor
virtual MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
ResultPointCloudProvider()
virtual void onExitPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
virtual std::string getDefaultName() const override
Retrieve default name of component.
void setResultPointCloudProviderName(const std::string &name)
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
std::string GetHandledExceptionString()
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void getMapKeys(const MapType &map, OutputIteratorType it)
IceInternal::Handle< PointCloudProcessor > PointCloudProcessorPtr
Shared pointer for convenience.