PointCloudProcessor.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::Core
19  * @author David Gonzalez Aguirre (david dot gonzalez at kit dot edu)
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 // ArmarXCore
32 
33 // VisionXInterfaces
34 #include <VisionX/interface/core/DataTypes.h>
35 #include <VisionX/interface/core/PointCloudProcessorInterface.h>
36 
37 // VisionXTools
38 #include <condition_variable>
39 #include <mutex>
40 #include <shared_mutex>
41 
42 #include <IceUtil/IceUtil.h>
43 
45 
46 #include "PointCloudConversions.h"
47 #include "PointCloudProvider.h"
48 
49 namespace visionx
50 {
51  // ====================================================================== //
52  // == class PointCloudTransferStats declaration ============================== //
53  // ====================================================================== //
54 
55  /**
56  * The PointCloudTransferStats class provides information on the connection
57  * between PointCloudProvider and PointCloudProcessor. Use
58  * PointCloudProcessorBase::getPointCloudTransferStats() in order to retrieve the
59  * statistics
60  */
62  {
63 
64  public:
66  {
68  pollingFPS.reset();
69  }
70 
71  /// Statistics for the PointClouds announced by the PointCloudProvider.
73 
74  /// Statistics for the PointClouds polled by the PointCloudProcessor.
76  };
77 
78  // ====================================================================== //
79  // == class PointCloudProviderInfo declaration ========================== //
80  // ====================================================================== //
81 
83  {
84  public:
85  /// Proxy to PointCloud provider.
86  PointCloudProviderInterfacePrx proxy;
87 
88  /// Memory block.
89  std::vector<unsigned char> buffer;
90 
91  /// PointCloud format struct that contains all necessary PointCloud information.
92  MetaPointCloudFormatPtr pointCloudFormat;
93 
94  /// Indicates whether an PointCloud is available.
96 
97  /// Transfer mode of images
98  ImageTransferMode pointCloudTransferMode;
99 
100  /// Conditional variable used internally for synchronization purposes
101  std::shared_ptr<std::condition_variable> pointCloudAvailableEvent;
102  };
103 
105  {
106  public:
108  };
109 
110  // ====================================================================== //
111  // == class ResultPointCloudProvider declaration ======================== //
112  // ====================================================================== //
113  /**
114  * The ResultPointCloudProvider is used by the PointCloudProcessor to stream
115  * result PointClouds to any other processor (e.g. PointCloudMonitor)
116  * Use PointCloudProcessor::enableVisualization() and PointCloudProcessor::provideResultPointClouds()
117  * in order to offer result PointClouds in an PointCloud processor.
118  */
120  {
121  friend class PointCloudProcessor;
122 
123  public:
125 
126  template <typename PointCloudPtrT>
127  void
128  provideResultPointClouds(PointCloudPtrT pointCloudPtr)
129  {
130  providePointCloud(pointCloudPtr);
131  }
132 
133  protected:
134  void setResultPointCloudProviderName(const std::string& name);
135 
136  virtual std::string getDefaultName() const override;
137 
138  void setShmCapacity(size_t shmCapacity);
139  size_t getShmCapacity();
140 
141  void setPointContentType(PointContentType type);
142  PointContentType getPointContentType() const;
143 
144 
145  virtual void onInitPointCloudProvider() override;
146  virtual void onExitPointCloudProvider() override;
147 
148  virtual MetaPointCloudFormatPtr getDefaultPointCloudFormat() override;
150 
151  private:
152  std::string resultPointCloudProviderName;
153 
154  size_t shmCapacity;
155 
156  PointContentType pointContentType;
157  };
158 
159  /**
160  * @brief Properties of `PointCloudProcessor`.
161  *
162  * Let your own point cloud processor's properties derive from this class
163  * to get the default properties of `PointCloudProcessor`. These include
164  * `ProviderName`, `FrameRate` and `AutomaticTypeConversion`.
165  */
167  {
168  public:
170  };
171 
172  /**
173  * The PointCloudProcessor class provides an interface for access to
174  * PointCloudProviders via Ice and shared memory. The interface defines a set of
175  * convenience methods which simplify the PointCloud access.
176  */
178  virtual public armarx::Component,
179  virtual public PointCloudProcessorInterface
180  {
181  public:
182  /**
183  * Registers a delayed topic subscription and a delayed provider proxy
184  * retrieval which will be available on the start of the component.
185  *
186  * @param name Provider name
187  */
188  void usingPointCloudProvider(std::string providerName);
189 
190  void
191  usingPointCloudProviderFromProperty(const std::string& prop)
192  {
193  usingPointCloudProvider(getProperty<std::string>(prop).getValue());
194  }
195 
196  /**
197  * Removes topic subscription and provider proxy dependency to release
198  * a point cloud provider. After this, provider is not available in
199  * waitForPointClouds() or getPointClouds() calls.
200  */
201  void releasePointCloudProvider(std::string providerName);
202 
203  /**
204  * Select an PointCloudProvider.
205  *
206  * This method subscribes to an an PointCloudProvider and makes the provider
207  * available in the waitForPointClouds() and getPointClouds() methods.
208  *
209  * @param name Ice adapter name of the PointCloudProvider
210  * @param waitForProxy If true, this function blocks until the proxy for the pointCloudProvider becomes available.
211  *
212  * @return Information of the PointCloud provider
213  */
214  PointCloudProviderInfo getPointCloudProvider(std::string name, bool waitForProxy = false);
216 
217  /// Get the names of providers for which `usingPointCloudProvider()` has been called.
218  std::vector<std::string> getPointCloudProviderNames() const;
219  /// Indicate whether the given name identifies a known point cloud provider.
220  bool isPointCloudProviderKnown(const std::string& providerName) const;
221 
222  /**
223  * Enables visualization
224  *
225  * @param numberPointClouds number of PointClouds provided by the visualization
226  * @param PointCloud::Grid2DDimensions size of PointClouds
227  * @param PointCloudFormatInfo type of PointClouds
228  *
229  * @return Information of the PointCloud provider
230  */
231  template <typename PointT>
232  void
233  enableResultPointClouds(std::string resultProviderName = "")
234  {
235  std::shared_lock lock(pointCloudProviderInfoMutex);
236 
237  if (pointCloudProviderInfoMap.size() == 1)
238  {
239  enableResultPointCloudForInputProvider<PointT>(
240  pointCloudProviderInfoMap.begin()->first, resultProviderName);
241  }
242  else
243  {
244  ARMARX_ERROR << "unable to determine shared memory capacity for result provider. "
245  "(result provider is not enabled!)";
246  }
247  }
248 
249  template <typename PointT>
250  void
251  enableResultPointCloudForInputProvider(const std::string& inputProviderName,
252  const std::string& resultProviderName = "")
253  {
254  std::shared_lock lock(pointCloudProviderInfoMutex);
255 
256  if (pointCloudProviderInfoMap.count(inputProviderName))
257  {
258  MetaPointCloudFormatPtr info =
259  pointCloudProviderInfoMap.at(inputProviderName).pointCloudFormat;
260 
261  PointContentType pointContentType = tools::getPointContentType<PointT>();
262 
263  size_t capacity = info->capacity * tools::getBytesPerPoint(pointContentType) /
264  tools::getBytesPerPoint(info->type);
265 
266  enableResultPointClouds(resultProviderName, capacity, pointContentType);
267  }
268  else
269  {
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;
273  }
274  }
275 
276  void enableResultPointClouds(std::string resultProviderName,
277  size_t shmCapacity,
278  PointContentType pointContentType);
279 
280  /**
281  * sends result PointClouds for visualization
282  * @see enableVisualization
283  *
284  * @param PointClouds array of PointClouds to send
285  */
286  template <typename PointCloudPtrT>
287  void
288  provideResultPointClouds(const PointCloudPtrT& pointClouds, std::string providerName = "")
289  {
290  std::shared_lock lock(resultProviderMutex);
291 
292  if (providerName == "" && resultPointCloudProviders.size() > 0)
293  {
294  providerName = resultPointCloudProviders.begin()->first;
295  }
296 
297  if (resultPointCloudProviders.count(providerName))
298  {
299  resultPointCloudProviders[providerName]->template provideResultPointClouds(
300  pointClouds);
301  }
302  else
303  {
304  ARMARX_WARNING << "unable to find provider name: " << providerName
305  << "\nknown names :\n"
307  }
308  }
309 
310  template <typename PointCloudPtrT>
311  void
312  provideResultPointClouds(const std::string& providerName, const PointCloudPtrT& pointClouds)
313  {
314  provideResultPointClouds(pointClouds, providerName);
315  }
316 
317  /**
318  * Wait for new PointClouds.
319  *
320  * Wait for new PointCloud of an PointCloud provider. Use if only one
321  * PointCloudProvider is used (see usingPointCloudProvider).
322  *
323  * @param milliseconds Timeout for waiting
324  *
325  * @return True if new PointClouds are available. False in case of error or
326  * timeout
327  */
328  bool waitForPointClouds(int milliseconds = 1000);
329 
330  /**
331  * Wait for new PointClouds.
332  *
333  * Wait for new PointCloud of an PointCloud provider. Use if multiple
334  * PointCloudProviders are used (see usingPointCloudProvider).
335  *
336  * @param providerName Name of provider to wait for PointClouds
337  * @param milliseconds Timeout for waiting
338  *
339  * @return True if new PointClouds are available. False in case of error or
340  * timeout
341  */
342  bool waitForPointClouds(const std::string& providerName, int milliseconds = 1000);
343 
344  /**
345  * Returns current status for the given point cloud. True if new data is available, false otherwise.
346  *
347  * This operation does not block. It just returns the current status.
348  * Use this if you want to get status of a point cloud without polling
349  * it for a given time like the other methods do.
350  *
351  * @param providerName Name of provider to wait for PointClouds
352  *
353  * @return True if new data from the provider is available. False otherwise.
354  */
355  bool pointCloudHasNewData(std::string providerName);
356 
357  /**
358  * Poll PointClouds from provider.
359  *
360  * Polls PointClouds from a used PointCloudProvider either via shared memory or
361  * via Ice. If both components run on the same machine, shared memory
362  * transfer is used. Otherwise Ice is used for PointCloud transmission. The
363  * transfer type is decided in the usingPointCloudProvider method and is set
364  * in the corresponding PointCloudFormatInfo.
365  *
366  * Use this method if only one PointCloudProvider is used.
367  *
368  * @param ppPointClouds PointCloud buffers where the PointClouds are
369  * copied to. The buffers have to be
370  * initialized by the component. All
371  * required information for the allocation
372  * of the buffers can be found in the
373  * corresponding PointCloudFormatInfo.
374  *
375  * @return Number of PointClouds copied. Zero if no new PointClouds have been
376  * available.
377  */
378  template <typename PointCloudPtrT>
379  int
380  getPointClouds(const PointCloudPtrT& pointCloudPtr)
381  {
382  if (pointCloudProviderInfoMap.size() != 1)
383  {
384  ARMARX_ERROR << "Calling getPointClouds without PointCloudProvider name but using "
385  "multiple PointCloudProviders or without usingPointCloudProvider";
386  return false;
387  }
388 
389  std::shared_lock lock(pointCloudProviderInfoMutex);
390 
391  std::string providerName = pointCloudProviderInfoMap.begin()->first;
392 
393  lock.unlock();
394 
395  return getPointClouds(providerName, pointCloudPtr);
396  }
397 
398  /**
399  * Poll PointClouds from provider.
400  *
401  * Polls PointClouds from a used PointCloudProvider either via shared memory or
402  * via Ice. If both components run on the same machine, shared memory
403  * transfer is used. Otherwise Ice is used for PointCloud transmission. The
404  * transfer type is decided in the usingPointCloudProvider method and is set
405  * in the corresponding PointCloudFormatInfo.
406  *
407  * Use this method if multiple PointCloudProviders are used.
408  *
409  * @param providerName Name of provider to poll from
410  *
411  * @param ppPointClouds PointCloud buffers where the PointClouds are
412  * copied to. The buffers have to be
413  * initialized by the component. All
414  * required information for the allocation
415  * PointCloudProcessor.h of the buffers can be found in the
416  * corresponding PointCloudFormatInfo.
417  *
418  * @return Number of PointClouds copied. Zero if no new PointClouds have been
419  * available.
420  */
421  template <typename PointCloudPtrT>
422  bool
423  getPointClouds(std::string providerName, const PointCloudPtrT& pointClouds)
424  {
425  using PointCloudT = typename PointCloudPtrT::element_type;
426  using PointT = typename PointCloudT::PointType;
427 
428  if (pointClouds == NULL)
429  {
430  ARMARX_ERROR << "pointClouds is NULL";
431  return false;
432  }
433 
434  std::shared_lock lock(pointCloudProviderInfoMutex);
435 
436  // find PointCloud provider
437  std::map<std::string, PointCloudProviderInfo>::iterator iter =
438  pointCloudProviderInfoMap.find(providerName);
439 
440  if (iter == pointCloudProviderInfoMap.end())
441  {
442  ARMARX_ERROR << "Trying to retrieve PointClouds from unknown PointCloud provider. "
443  "Call usingPointCloudProvider before";
444  return false;
445  }
446 
447  // check if new PointClouds are available
448  if (!iter->second.pointCloudAvailable)
449  {
450  ARMARX_WARNING << "no point cloud available. use waitForPointCloud()";
451  return false;
452  }
453 
454  PointCloudProviderInfo& providerInfo = iter->second;
455 
456  if (providerInfo.pointCloudFormat->type !=
457  visionx::tools::getPointContentType<PointT>() &&
459  {
460  auto requested = visionx::tools::getPointContentType<PointT>();
461  ARMARX_WARNING << deactivateSpam(5) << "Requested point cloud format ("
462  << tools::toString(requested) << ")"
463  << " differs from provided format ("
464  << tools::toString(providerInfo.pointCloudFormat->type) << "),"
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.";
471  return false;
472  }
473 
474  try
475  {
476  if (providerInfo.pointCloudTransferMode == eIceTransfer)
477  {
478  // providerInfo.info->timeProvided = TimeUtil::GetTime().toMicroSeconds();
479  std::vector<Ice::Byte> blob =
480  providerInfo.proxy->getPointCloud(providerInfo.pointCloudFormat);
481  blob.swap(providerInfo.buffer);
482  }
483  else
484  {
485  usedPointCloudProviders[providerName]->getData(providerInfo.buffer,
486  providerInfo.pointCloudFormat);
487  }
488  // usedPointCloudProviders[providerName]->getData(providerInfo.buffer, providerInfo.pointCloudFormat);
489 
490  void* bufferPtr = providerInfo.buffer.data();
491  void** bufferPtrPtr = &bufferPtr; // Why though?
493  bufferPtrPtr, providerInfo.pointCloudFormat, pointClouds);
494  }
495  catch (...)
496  {
497  ARMARX_ERROR << "unable to get point cloud: "
499  return false;
500  }
501 
502 
503  // todo lock for writing...
504  iter->second.pointCloudAvailable = false;
505 
506  IceUtil::Time timeReceived = IceUtil::Time::now();
507  IceUtil::Time timeProvided =
508  IceUtil::Time::microSeconds(providerInfo.pointCloudFormat->timeProvided);
509 
510  pointClouds->header.stamp = providerInfo.pointCloudFormat->timeProvided;
511  pointClouds->header.seq = providerInfo.pointCloudFormat->seq;
512  //pointClouds->header.frame_id = providerInfo.pointCloudFormat->frameId;
513 
514  long transferTime = (timeReceived - timeProvided).toMilliSeconds();
515 
516  ARMARX_DEBUG << "received point cloud size: " << pointClouds->width << "x"
517  << pointClouds->height << ". took " << transferTime << " ms.";
518 
519  std::unique_lock lock2(statisticsMutex);
520 
521  statistics[providerName].pollingFPS.update();
522 
523  return true;
524  }
525 
526  MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName);
527 
528 
529  /**
530  * Retrieve statistics for a connection to an PointCloudProvider.
531  *
532  * @param providerName Name of the provider
533  * @param resetStats Reset statistics
534  *
535  * @return Reference to statistics for the connection to the provder
536  */
537  PointCloudTransferStats getPointCloudTransferStats(std::string providerName,
538  bool resetStats = false);
539 
540  /**
541  * @brief Get the reference frame of the point cloud by given provider.
542  * @param providerName The point cloud provider's name.
543  * @return The point cloud's reference frame, or empty string if provider
544  * is unknown or has not specified a reference frame.
545  */
546  std::string getPointCloudFrame(const std::string& providerName,
547  const std::string& defaultFrame = "");
548 
549  protected:
550  // ================================================================== //
551  // == Interface of an PointCloudProcessor =========================== //
552  // ================================================================== //
553  /**
554  * Setup the vision component.
555  *
556  * Implement this method in the PointCloudProcessor in order to setup its
557  * parameters. Use this for the registration of adaptars and
558  * subscription to topics
559  *
560  * @param argc number of filtered command line arguments
561  * @param argv filtered command line arguments
562  */
563  virtual void onInitPointCloudProcessor() = 0;
564 
565  /**
566  * Implement this method in the PointCloudProcessor in order execute parts
567  * when the component is fully initialized and about to run.
568  */
569  virtual void onConnectPointCloudProcessor() = 0;
570 
571  /**
572  * Implement this method in the PointCloudProcessor in order execute parts
573  * when the component looses network connectivity.
574  */
575  virtual void
577  {
578  }
579 
580  /**
581  * Exit the ImapeProcessor component.
582  *
583  * Implement this method in order to clean up the PointCloudProcessor
584  */
585  virtual void onExitPointCloudProcessor() = 0;
586 
587  /**
588  * Process the vision component.
589  *
590  * The main loop of the PointCloudProcessor to be implemented in the
591  * subclass. Do not block this method. One process should execute
592  * exactly one PointCloud processing step.
593  */
594  virtual void process() = 0;
595 
596  // ================================================================== //
597  // == RunningComponent implementation =============================== //
598  // ================================================================== //
599 
600  /// @see Component::onInitComponent()
601  virtual void onInitComponent() override;
602 
603  /// @see Component::onConnectComponent()
604  virtual void onConnectComponent() override;
605 
606  /// @see Component::onDisconnectComponent()
607  virtual void onDisconnectComponent() override;
608 
609  /// @see Component::onExitComponent()
610  virtual void onExitComponent() override;
611 
612  /// @see RunningTask
613  virtual void runProcessor();
614 
615 
616  protected:
617  // ================================================================== //
618  // == PointCloudListener Ice interface ============================== //
619  // ================================================================== //
620  /**
621  * Listener callback function. This is called by the used PointCloud
622  * providers to report the availability of a newly captured
623  * PointCloud.
624  *
625  * @param providerName The reporting PointCloud provider name
626  */
627  void reportPointCloudAvailable(const std::string& providerName,
628  const Ice::Current& c = Ice::emptyCurrent) override;
629 
630  // PointCloud provider.
631 
632  using PointCloudProviderMap = std::map<
633  std::string,
636 
637  std::map<std::string, PointCloudProviderInfo> pointCloudProviderInfoMap;
638  std::shared_mutex pointCloudProviderInfoMutex;
639 
640  // Result PointCloud visualization.
641  std::map<std::string, IceInternal::Handle<ResultPointCloudProvider>>
643  std::shared_mutex resultProviderMutex;
644 
645  // Statistics.
646  std::mutex statisticsMutex;
647  std::map<std::string, PointCloudTransferStats> statistics;
648 
650 
652  float frameRate;
653 
655  };
656 
657  /// Shared pointer for convenience.
659 
660 } // namespace visionx
visionx::ResultPointCloudProvider::getShmCapacity
size_t getShmCapacity()
Definition: PointCloudProcessor.cpp:77
armarx::ManagedIceObject::waitForProxy
void waitForProxy(std::string const &name, bool addToDependencies)
Definition: ManagedIceObject.cpp:178
visionx::PointCloudProcessor::provideResultPointClouds
void provideResultPointClouds(const std::string &providerName, const PointCloudPtrT &pointClouds)
Definition: PointCloudProcessor.h:312
visionx::PointCloudProcessor::pointCloudHasNewData
bool pointCloudHasNewData(std::string providerName)
Returns current status for the given point cloud.
Definition: PointCloudProcessor.cpp:514
algorithm.h
visionx::PointCloudProcessor::getPointCloudTransferStats
PointCloudTransferStats getPointCloudTransferStats(std::string providerName, bool resetStats=false)
Retrieve statistics for a connection to an PointCloudProvider.
Definition: PointCloudProcessor.cpp:558
visionx::PointCloudProcessor::usingPointCloudProviderFromProperty
void usingPointCloudProviderFromProperty(const std::string &prop)
Definition: PointCloudProcessor.h:191
visionx::armem::pointcloud::PointType
PointType
Definition: constants.h:78
visionx::PointCloudProcessor::getPointCloudFormat
MetaPointCloudFormatPtr getPointCloudFormat(std::string providerName)
Definition: PointCloudProcessor.cpp:534
visionx::PointCloudProcessor::automaticConversion
bool automaticConversion
Definition: PointCloudProcessor.h:654
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ResultPointCloudProvider::getPointContentType
PointContentType getPointContentType() const
Definition: PointCloudProcessor.cpp:89
visionx::PointCloudProcessor::enableResultPointCloudForInputProvider
void enableResultPointCloudForInputProvider(const std::string &inputProviderName, const std::string &resultProviderName="")
Definition: PointCloudProcessor.h:251
visionx::ResultPointCloudProvider::getDefaultName
virtual std::string getDefaultName() const override
Retrieve default name of component.
Definition: PointCloudProcessor.cpp:65
visionx::PointCloudProviderInfo::buffer
std::vector< unsigned char > buffer
Memory block.
Definition: PointCloudProcessor.h:89
visionx::ResultPointCloudProviderPropertyDefinitions
Definition: PointCloudProcessor.h:104
visionx::PointCloudProviderInfo::proxy
PointCloudProviderInterfacePrx proxy
Proxy to PointCloud provider.
Definition: PointCloudProcessor.h:86
visionx::PointCloudProcessor::onConnectPointCloudProcessor
virtual void onConnectPointCloudProcessor()=0
Implement this method in the PointCloudProcessor in order execute parts when the component is fully i...
visionx::ResultPointCloudProvider::onInitPointCloudProvider
virtual void onInitPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
Definition: PointCloudProcessor.cpp:95
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
visionx::PointCloudProcessor::onDisconnectComponent
virtual void onDisconnectComponent() override
Definition: PointCloudProcessor.cpp:234
PointCloudProvider.h
visionx::PointCloudProcessor::isPointCloudProviderKnown
bool isPointCloudProviderKnown(const std::string &providerName) const
Indicate whether the given name identifies a known point cloud provider.
Definition: PointCloudProcessor.cpp:416
visionx::PointCloudProcessor::statisticsMutex
std::mutex statisticsMutex
Definition: PointCloudProcessor.h:646
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
visionx::PointCloudProcessorPropertyDefinitions::PointCloudProcessorPropertyDefinitions
PointCloudProcessorPropertyDefinitions(std::string prefix)
Definition: PointCloudProcessor.cpp:121
visionx::PointCloudProcessor::pointCloudProviderInfoMutex
std::shared_mutex pointCloudProviderInfoMutex
Definition: PointCloudProcessor.h:638
visionx::PointCloudProcessor::onInitPointCloudProcessor
virtual void onInitPointCloudProcessor()=0
Setup the vision component.
RunningTask.h
visionx::PointCloudProcessor::processorTask
armarx::RunningTask< PointCloudProcessor >::pointer_type processorTask
Definition: PointCloudProcessor.h:649
visionx::PointCloudProcessor::onExitComponent
virtual void onExitComponent() override
Definition: PointCloudProcessor.cpp:241
visionx::PointCloudProcessor::getPointCloudFrame
std::string getPointCloudFrame(const std::string &providerName, const std::string &defaultFrame="")
Get the reference frame of the point cloud by given provider.
Definition: PointCloudProcessor.cpp:588
visionx::PointCloudProviderInfo
Definition: PointCloudProcessor.h:82
IceInternal::Handle
Definition: forward_declarations.h:8
visionx::PointCloudProcessor::onExitPointCloudProcessor
virtual void onExitPointCloudProcessor()=0
Exit the ImapeProcessor component.
armarx::GetHandledExceptionString
std::string GetHandledExceptionString()
Definition: Exception.cpp:165
visionx::FPSCounter::reset
void reset()
Resets the FPS counter to its initial state.
Definition: FPSCounter.cpp:51
visionx::PointCloudProcessor::pointCloudProviderInfoMap
std::map< std::string, PointCloudProviderInfo > pointCloudProviderInfoMap
Definition: PointCloudProcessor.h:637
visionx::ResultPointCloudProvider::provideResultPointClouds
void provideResultPointClouds(PointCloudPtrT pointCloudPtr)
Definition: PointCloudProcessor.h:128
visionx::PointCloudProcessor::provideResultPointClouds
void provideResultPointClouds(const PointCloudPtrT &pointClouds, std::string providerName="")
sends result PointClouds for visualization
Definition: PointCloudProcessor.h:288
visionx::PointCloudProviderInfo::pointCloudTransferMode
ImageTransferMode pointCloudTransferMode
Transfer mode of images.
Definition: PointCloudProcessor.h:98
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:177
visionx::PointCloudProviderInfo::pointCloudAvailable
bool pointCloudAvailable
Indicates whether an PointCloud is available.
Definition: PointCloudProcessor.h:95
visionx::PointCloudProcessor::PointCloudProviderMap
std::map< std::string, armarx::IceSharedMemoryConsumer< unsigned char, MetaPointCloudFormat >::pointer_type > PointCloudProviderMap
Definition: PointCloudProcessor.h:634
visionx::PointCloudProcessor::process
virtual void process()=0
Process the vision component.
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
visionx::ResultPointCloudProvider::ResultPointCloudProvider
ResultPointCloudProvider()
Definition: PointCloudProcessor.cpp:52
visionx::PointCloudProviderPropertyDefinitions
Definition: PointCloudProvider.h:42
visionx::ResultPointCloudProvider::setPointContentType
void setPointContentType(PointContentType type)
Definition: PointCloudProcessor.cpp:83
visionx::PointCloudProcessor::waitForPointClouds
bool waitForPointClouds(int milliseconds=1000)
Wait for new PointClouds.
Definition: PointCloudProcessor.cpp:458
visionx::PointCloudTransferStats::pollingFPS
FPSCounter pollingFPS
Statistics for the PointClouds polled by the PointCloudProcessor.
Definition: PointCloudProcessor.h:75
visionx::PointCloudProviderInfo::pointCloudFormat
MetaPointCloudFormatPtr pointCloudFormat
PointCloud format struct that contains all necessary PointCloud information.
Definition: PointCloudProcessor.h:92
IceSharedMemoryConsumer.h
visionx::ResultPointCloudProvider::setResultPointCloudProviderName
void setResultPointCloudProviderName(const std::string &name)
Definition: PointCloudProcessor.cpp:59
visionx::PointCloudProcessor::fpsCounter
FPSCounter fpsCounter
Definition: PointCloudProcessor.h:651
visionx::ResultPointCloudProvider::onExitPointCloudProvider
virtual void onExitPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: PointCloudProcessor.cpp:100
IceManager.h
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:32
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
visionx::PointCloudProcessorPropertyDefinitions
Properties of PointCloudProcessor.
Definition: PointCloudProcessor.h:166
visionx::tools::toString
std::string toString(PointContentType pointContent)
Definition: PointCloudConversions.cpp:839
visionx::PointCloudProcessor::getPointClouds
int getPointClouds(const PointCloudPtrT &pointCloudPtr)
Poll PointClouds from provider.
Definition: PointCloudProcessor.h:380
visionx::ResultPointCloudProvider
The ResultPointCloudProvider is used by the PointCloudProcessor to stream result PointClouds to any o...
Definition: PointCloudProcessor.h:119
visionx::ResultPointCloudProvider::createPropertyDefinitions
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PointCloudProcessor.cpp:115
visionx::PointCloudProviderInfo::pointCloudAvailableEvent
std::shared_ptr< std::condition_variable > pointCloudAvailableEvent
Conditional variable used internally for synchronization purposes.
Definition: PointCloudProcessor.h:101
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
visionx::PointCloudProcessor::frameRate
float frameRate
Definition: PointCloudProcessor.h:652
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
visionx::tools::convertToPCL
void convertToPCL(void **source, visionx::MetaPointCloudFormatPtr pointCloudFormat, pcl::PointCloud< pcl::PointXYZRGBA >::Ptr targetPtr)
Definition: PointCloudConversions.cpp:169
PointCloudConversions.h
visionx::PointCloudProcessor::releasePointCloudProvider
void releasePointCloudProvider(std::string providerName)
Removes topic subscription and provider proxy dependency to release a point cloud provider.
Definition: PointCloudProcessor.cpp:295
visionx::PointCloudProcessor::getPointClouds
bool getPointClouds(std::string providerName, const PointCloudPtrT &pointClouds)
Poll PointClouds from provider.
Definition: PointCloudProcessor.h:423
visionx::PointCloudProcessor::onConnectComponent
virtual void onConnectComponent() override
Definition: PointCloudProcessor.cpp:216
visionx::PointCloudProvider::providePointCloud
void providePointCloud(PointCloudPtrT pointCloudPtr)
offer the new point cloud.
Definition: PointCloudProvider.h:122
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
visionx::PointCloudProcessor::onDisconnectPointCloudProcessor
virtual void onDisconnectPointCloudProcessor()
Implement this method in the PointCloudProcessor in order execute parts when the component looses net...
Definition: PointCloudProcessor.h:576
visionx::ResultPointCloudProviderPropertyDefinitions::ResultPointCloudProviderPropertyDefinitions
ResultPointCloudProviderPropertyDefinitions(std::string prefix)
Definition: PointCloudProcessor.cpp:46
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::PointCloudProcessor::usingPointCloudProvider
void usingPointCloudProvider(std::string providerName)
Registers a delayed topic subscription and a delayed provider proxy retrieval which will be available...
Definition: PointCloudProcessor.cpp:279
visionx::PointCloudProcessor::onInitComponent
virtual void onInitComponent() override
Definition: PointCloudProcessor.cpp:136
visionx::ResultPointCloudProvider::setShmCapacity
void setShmCapacity(size_t shmCapacity)
Definition: PointCloudProcessor.cpp:71
visionx::PointCloudProcessor::statistics
std::map< std::string, PointCloudTransferStats > statistics
Definition: PointCloudProcessor.h:647
visionx::PointCloudTransferStats
The PointCloudTransferStats class provides information on the connection between PointCloudProvider a...
Definition: PointCloudProcessor.h:61
visionx::tools::getBytesPerPoint
size_t getBytesPerPoint(visionx::PointContentType pointContent)
Definition: PointCloudConversions.cpp:85
armarx::Logging::deactivateSpam
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.
Definition: Logging.cpp:99
visionx::PointCloudProcessor::getPointCloudProvider
PointCloudProviderInfo getPointCloudProvider(std::string name, bool waitForProxy=false)
Select an PointCloudProvider.
Definition: PointCloudProcessor.cpp:325
visionx::PointCloudTransferStats::PointCloudTransferStats
PointCloudTransferStats()
Definition: PointCloudProcessor.h:65
visionx::ResultPointCloudProvider::getDefaultPointCloudFormat
virtual MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
Definition: PointCloudProcessor.cpp:105
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
visionx::PointCloudTransferStats::pointCloudProviderFPS
FPSCounter pointCloudProviderFPS
Statistics for the PointClouds announced by the PointCloudProvider.
Definition: PointCloudProcessor.h:72
visionx::PointCloudProcessor::enableResultPointClouds
void enableResultPointClouds(std::string resultProviderName="")
Enables visualization.
Definition: PointCloudProcessor.h:233
visionx::PointCloudProcessor::getPointCloudProviderNames
std::vector< std::string > getPointCloudProviderNames() const
Get the names of providers for which usingPointCloudProvider() has been called.
Definition: PointCloudProcessor.cpp:404
FPSCounter.h
armarx::getMapKeys
void getMapKeys(const MapType &map, OutputIteratorType it)
Definition: algorithm.h:173
visionx::PointCloudProvider
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
Definition: PointCloudProvider.h:58
visionx::PointCloudProcessor::resultProviderMutex
std::shared_mutex resultProviderMutex
Definition: PointCloudProcessor.h:643
visionx::PointCloudProcessor::runProcessor
virtual void runProcessor()
Definition: PointCloudProcessor.cpp:255
visionx::FPSCounter
The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic t...
Definition: FPSCounter.h:36
visionx::PointCloudProcessor::resultPointCloudProviders
std::map< std::string, IceInternal::Handle< ResultPointCloudProvider > > resultPointCloudProviders
Definition: PointCloudProcessor.h:642
visionx::PointT
pcl::PointXYZRGBA PointT
Definition: MaskRCNNPointCloudObjectLocalizer.h:77
visionx::PointCloudProcessor::usedPointCloudProviders
PointCloudProviderMap usedPointCloudProviders
Definition: PointCloudProcessor.h:635
visionx::PointCloudProcessor::reportPointCloudAvailable
void reportPointCloudAvailable(const std::string &providerName, const Ice::Current &c=Ice::emptyCurrent) override
Listener callback function.
Definition: PointCloudProcessor.cpp:606