Go to the documentation of this file.
30 #include <pcl/console/print.h>
38 #include <VisionX/interface/components/Calibration.h>
46 ResultPointCloudProviderPropertyDefinitions::ResultPointCloudProviderPropertyDefinitions(
53 resultPointCloudProviderName(
"ResultPointCloudProvider"),
54 pointContentType(PointContentType::eColoredPoints)
61 resultPointCloudProviderName = name;
67 return resultPointCloudProviderName;
73 this->shmCapacity = shmCapacity;
85 pointContentType = type;
91 return pointContentType;
104 MetaPointCloudFormatPtr
107 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
108 info->capacity =
static_cast<Ice::Int>(shmCapacity);
109 info->size =
static_cast<Ice::Int>(shmCapacity);
110 info->type = pointContentType;
122 std::string prefix) :
125 defineOptionalProperty<float>(
128 "Number of frames per second. If zero then this property is ignored.");
129 defineOptionalProperty<bool>(
130 "AutomaticTypeConversion",
false,
"Automatically convert different point cloud types.");
131 defineOptionalProperty<std::string>(
132 "ProviderName",
"",
"Name(s) of the point cloud provider(s).");
139 switch (getProperty<armarx::MessageTypeT>(
"MinimumLoggingLevel"))
142 pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE);
145 pcl::console::setVerbosityLevel(pcl::console::L_DEBUG);
149 pcl::console::setVerbosityLevel(pcl::console::L_INFO);
152 pcl::console::setVerbosityLevel(pcl::console::L_WARN);
156 pcl::console::setVerbosityLevel(pcl::console::L_ERROR);
159 pcl::console::setVerbosityLevel(pcl::console::L_ALWAYS);
183 !getProperty<std::string>(
"ProviderName").getValue().
empty())
185 std::vector<std::string> providerNames =
186 armarx::Split(getProperty<std::string>(
"ProviderName"),
",",
true);
188 for (
const std::string& providerName : providerNames)
190 if (providerName.empty())
193 <<
" contains an invalid value";
204 <<
"\nnot derive from PointCloudProcessorPropertyDefinitions. Consider"
206 <<
"'s properties from this class to get"
207 <<
"\ndefault point cloud processor properties, such as 'ProviderName', and"
208 <<
"\nthe respective features.";
271 std::this_thread::sleep_for(std::chrono::milliseconds(1));
284 usingTopic(providerName +
".PointCloudListener");
289 this, providerName,
"PointCloudProvider");
320 std::string
memoryName = providerName +
"Memory" +
"PointCloudProvider";
332 ARMARX_INFO <<
"Point cloud provider already started: " << providerName;
340 providerInfo.
proxy = getProxy<PointCloudProviderInterfacePrx>(providerName,
waitForProxy);
341 ARMARX_DEBUG <<
"getProxy '" << providerName <<
"'...done!";
347 size_t pointCloudBufferSize =
static_cast<size_t>(providerInfo.
pointCloudFormat->size);
348 providerInfo.
buffer.resize(pointCloudBufferSize);
359 statistics[providerName].pointCloudProviderFPS.reset();
361 if (!providerInfo.
proxy->hasSharedMemorySupport())
363 ARMARX_WARNING <<
"shared memory not available for provider " << providerName;
386 std::string providerName;
393 ARMARX_ERROR <<
"Calling getPointCloudProvider without "
394 <<
"PointCloudProvider name but using multiple "
395 <<
"PointCloudProviders";
403 std::vector<std::string>
406 std::vector<std::string>
names;
410 names.push_back(name);
424 PointContentType pointContentType)
426 if (resultProviderName ==
"")
428 resultProviderName =
getName() +
"Result";
435 ARMARX_WARNING <<
"result point cloud provider already exists: " << resultProviderName;
440 Component::create<ResultPointCloudProvider>();
441 resultProvider->setName(resultProviderName);
442 resultProvider->setShmCapacity(shmCapacity);
443 resultProvider->setPointContentType(pointContentType);
453 resultProvider->getObjectScheduler()->waitForObjectState(eManagedIceObjectStarted);
465 ARMARX_ERROR <<
"Calling waitForPointClouds without PointCloudProvider name but using "
466 "multiple PointCloudProviders";
488 <<
"Trying to wait for PointClouds from unknown PointCloud provider '"
489 << providerName <<
"'. Call usingPointCloudProvider before."
494 if (iter->second.pointCloudAvailable)
500 auto cond = iter->second.pointCloudAvailableEvent;
506 std::unique_lock lock2(mut);
507 auto td = std::chrono::milliseconds(milliseconds);
510 return cond->wait_for(lock2, td) != std::cv_status::timeout;
523 <<
"Asked for new point cloud data for unknown PointCloud provider '"
524 << providerName <<
"'. Call usingPointCloudProvider() beforehand."
530 return iter->second.pointCloudAvailable;
533 MetaPointCloudFormatPtr
538 MetaPointCloudFormatPtr format;
545 <<
"Trying to wait for PointClouds from unknown PointCloud provider '"
546 << providerName <<
"'. Call usingPointCloudProvider before."
551 format = iter->second.proxy->getPointCloudFormat();
565 ARMARX_ERROR <<
"Requesting statistics for unknown PointCloud provider '"
566 << providerName <<
"'"
576 iter->second.pollingFPS.reset();
580 iter->second.pointCloudProviderFPS.recalculate();
581 iter->second.pollingFPS.recalculate();
589 const std::string& defaultFrame)
595 <<
"Requesting information about unknown point cloud provider ''" << providerName
600 auto frameProv = ReferenceFrameInterfacePrx::checkedCast(providerInfo.
proxy);
602 return frameProv ? frameProv->getReferenceFrame() : defaultFrame;
612 std::map<std::string, PointCloudProviderInfo>::iterator iter =
617 ARMARX_ERROR <<
"Received notification from unknown point cloud provider '"
618 << providerName <<
"'."
623 iter->second.pointCloudAvailable =
true;
624 iter->second.pointCloudAvailableEvent->notify_all();
628 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.
constexpr std::size_t find(string_view str, char_type c) noexcept
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.