Go to the documentation of this file.
30 #include <pcl/console/print.h>
38 #include <VisionX/interface/components/Calibration.h>
47 ResultPointCloudProviderPropertyDefinitions::ResultPointCloudProviderPropertyDefinitions(std::string prefix) :
53 resultPointCloudProviderName(
"ResultPointCloudProvider"),
54 pointContentType(PointContentType::eColoredPoints)
60 resultPointCloudProviderName = name;
65 return resultPointCloudProviderName;
70 this->shmCapacity = shmCapacity;
80 pointContentType = type;
85 return pointContentType;
98 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
99 info->capacity =
static_cast<Ice::Int>(shmCapacity);
100 info->size =
static_cast<Ice::Int>(shmCapacity);
101 info->type = pointContentType;
114 defineOptionalProperty<float>(
"FrameRate", 0.0,
115 "Number of frames per second. If zero then this property is ignored.");
116 defineOptionalProperty<bool>(
"AutomaticTypeConversion",
false,
117 "Automatically convert different point cloud types.");
118 defineOptionalProperty<std::string>(
"ProviderName",
"",
119 "Name(s) of the point cloud provider(s).");
126 switch (getProperty<armarx::MessageTypeT>(
"MinimumLoggingLevel"))
129 pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);
132 pcl::console::setVerbosityLevel(pcl::console::L_DEBUG);
136 pcl::console::setVerbosityLevel(pcl::console::L_INFO);
139 pcl::console::setVerbosityLevel(pcl::console::L_WARN);
143 pcl::console::setVerbosityLevel(pcl::console::L_ERROR);
146 pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS);
170 if (
hasProperty(
"ProviderName") && !getProperty<std::string>(
"ProviderName").getValue().
empty())
172 std::vector<std::string> providerNames =
173 armarx::Split(getProperty<std::string>(
"ProviderName"),
",",
true);
175 for (
const std::string& providerName : providerNames)
177 if(providerName.empty())
190 <<
"\nnot derive from PointCloudProcessorPropertyDefinitions. Consider"
191 <<
"\nderiving " <<
getDefaultName() <<
"'s properties from this class to get"
192 <<
"\ndefault point cloud processor properties, such as 'ProviderName', and"
193 <<
"\nthe respective features.";
252 std::this_thread::sleep_for(std::chrono::milliseconds(1));
266 usingTopic(providerName +
".PointCloudListener");
300 std::string
memoryName = providerName +
"Memory" +
"PointCloudProvider";
311 ARMARX_INFO <<
"Point cloud provider already started: " << providerName;
319 providerInfo.
proxy = getProxy<PointCloudProviderInterfacePrx>(providerName,
waitForProxy);
320 ARMARX_DEBUG <<
"getProxy '" << providerName <<
"'...done!";
326 size_t pointCloudBufferSize =
static_cast<size_t>(providerInfo.
pointCloudFormat->size);
327 providerInfo.
buffer.resize(pointCloudBufferSize);
338 statistics[providerName].pointCloudProviderFPS.reset();
340 if (!providerInfo.
proxy->hasSharedMemorySupport())
342 ARMARX_WARNING <<
"shared memory not available for provider " << providerName;
364 std::string providerName;
371 ARMARX_ERROR <<
"Calling getPointCloudProvider without "
372 <<
"PointCloudProvider name but using multiple "
373 <<
"PointCloudProviders";
383 std::vector<std::string>
names;
387 names.push_back(name);
400 if (resultProviderName ==
"")
402 resultProviderName =
getName() +
"Result";
409 ARMARX_WARNING <<
"result point cloud provider already exists: " << resultProviderName;
414 resultProvider->setName(resultProviderName);
415 resultProvider->setShmCapacity(shmCapacity);
416 resultProvider->setPointContentType(pointContentType);
426 resultProvider->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
440 ARMARX_ERROR <<
"Calling waitForPointClouds without PointCloudProvider name but using multiple PointCloudProviders";
461 <<
"Trying to wait for PointClouds from unknown PointCloud provider '"
462 << providerName <<
"'. Call usingPointCloudProvider before."
467 if (iter->second.pointCloudAvailable)
473 auto cond = iter->second.pointCloudAvailableEvent;
479 std::unique_lock lock2(mut);
480 auto td = std::chrono::milliseconds(milliseconds);
483 return cond->wait_for(lock2, td) != std::cv_status::timeout;
495 <<
"Asked for new point cloud data for unknown PointCloud provider '"
496 << providerName <<
"'. Call usingPointCloudProvider() beforehand."
502 return iter->second.pointCloudAvailable;
510 MetaPointCloudFormatPtr format;
517 <<
"Trying to wait for PointClouds from unknown PointCloud provider '"
518 << providerName <<
"'. Call usingPointCloudProvider before."
523 format = iter->second.proxy->getPointCloudFormat();
537 ARMARX_ERROR <<
"Requesting statistics for unknown PointCloud provider '" << providerName <<
"'"
547 iter->second.pollingFPS.reset();
551 iter->second.pointCloudProviderFPS.recalculate();
552 iter->second.pollingFPS.recalculate();
565 <<
"Requesting information about unknown point cloud provider ''" << providerName <<
"'."
569 auto frameProv = ReferenceFrameInterfacePrx::checkedCast(providerInfo.
proxy);
571 return frameProv ? frameProv->getReferenceFrame() : defaultFrame;
584 ARMARX_ERROR <<
"Received notification from unknown point cloud provider '" << providerName <<
"'."
589 iter->second.pointCloudAvailable =
true;
590 iter->second.pointCloudAvailableEvent->notify_all();
594 statistics[providerName].pointCloudProviderFPS.update();
void waitForProxy(std::string const &name, bool addToDependencies)
bool pointCloudHasNewData(std::string providerName)
Returns current status for the given point cloud.
#define ARMARX_CHECK_NOT_EQUAL(lhs, rhs)
This macro evaluates whether lhs is inequal (!=) rhs and if it turns out to be false it will throw an...
PointCloudTransferStats getPointCloudTransferStats(std::string providerName, bool resetStats=false)
Retrieve statistics for a connection to an PointCloudProvider.
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
PointContentType getPointContentType() const
virtual std::string getDefaultName() const override
Retrieve default name of component.
std::vector< unsigned char > buffer
Memory block.
PointCloudProviderInterfacePrx proxy
Proxy to PointCloud provider.
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
virtual void onConnectPointCloudProcessor()=0
Implement this method in the PointCloudProcessor in order execute parts when the component is fully i...
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
virtual void onInitPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
bool removeProxyDependency(const std::string &name)
This function removes the dependency of this object on the in parameter name specified object.
virtual void onDisconnectComponent() override
bool isPointCloudProviderKnown(const std::string &providerName) const
Indicate whether the given name identifies a known point cloud provider.
std::mutex statisticsMutex
PointCloudProcessorPropertyDefinitions(std::string prefix)
std::shared_mutex pointCloudProviderInfoMutex
virtual void onInitPointCloudProcessor()=0
Setup the vision component.
bool hasProperty(const std::string &name)
armarx::RunningTask< PointCloudProcessor >::pointer_type processorTask
std::string getPointCloudFrame(const std::string &providerName, const std::string &defaultFrame="")
Get the reference frame of the point cloud by given provider.
virtual void onExitComponent() override
bool empty(const std::string &s)
virtual void onExitPointCloudProcessor()=0
Exit the ImapeProcessor component.
void reset()
Resets the FPS counter to its initial state.
std::map< std::string, PointCloudProviderInfo > pointCloudProviderInfoMap
bool pointCloudAvailable
Indicates whether an PointCloud is available.
virtual void process()=0
Process the vision component.
ResultPointCloudProvider()
void setPointContentType(PointContentType type)
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
MetaPointCloudFormatPtr pointCloudFormat
PointCloud format struct that contains all necessary PointCloud information.
void setResultPointCloudProviderName(const std::string &name)
virtual void onExitPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
bool unsubscribeFromTopic(const std::string &name)
Unsubscribe from a topic.
std::shared_ptr< std::condition_variable > pointCloudAvailableEvent
Conditional variable used internally for synchronization purposes.
virtual std::string getDefaultName() const =0
Retrieve default name of component.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
void releasePointCloudProvider(std::string providerName)
Removes topic subscription and provider proxy dependency to release a point cloud provider.
virtual void onConnectComponent() override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Default component property definition container.
const simox::meta::IntEnumNames names
virtual void onDisconnectPointCloudProcessor()
Implement this method in the PointCloudProcessor in order execute parts when the component looses net...
void assureFPS(float fFrameRate)
Synchronize to FPS.
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
const std::string memoryName
void usingPointCloudProvider(std::string providerName)
Registers a delayed topic subscription and a delayed provider proxy retrieval which will be available...
virtual void onInitComponent() override
void setShmCapacity(size_t shmCapacity)
std::map< std::string, PointCloudTransferStats > statistics
The PointCloudTransferStats class provides information on the connection between PointCloudProvider a...
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.
PointCloudProviderInfo getPointCloudProvider(std::string name, bool waitForProxy=false)
Select an PointCloudProvider.
std::string getName() const
Retrieve name of object.
virtual MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
FPSCounter pointCloudProviderFPS
Statistics for the PointClouds announced by the PointCloudProvider.
void enableResultPointClouds(std::string resultProviderName="")
Enables visualization.
std::vector< std::string > getPointCloudProviderNames() const
Get the names of providers for which usingPointCloudProvider() has been called.
void getMapKeys(const MapType &map, OutputIteratorType it)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_mutex resultProviderMutex
virtual void runProcessor()
std::map< std::string, IceInternal::Handle< ResultPointCloudProvider > > resultPointCloudProviders
PointCloudProviderMap usedPointCloudProviders
void reportPointCloudAvailable(const std::string &providerName, const Ice::Current &c=Ice::emptyCurrent) override
Listener callback function.