23 return "ArMemToPointCloudProvider";
32 defs->optional(p.memoryName,
"mem.01_MemoryName",
"Name of the memory.");
35 "mem.02_CoreSegmentName",
36 "Name of the core segment. If empty or (auto), this is derived from the point type.");
37 defs->optional(p.providerSegmentName,
38 "mem.03_ProviderSegmentName",
39 "Name of the provider segment(s).");
40 defs->optional(p.entityName,
"mem.04_EntityName",
"Name of the entity.");
42 defs->optional(p.pointtype,
"pc.01_PointType",
"The type of the point cloud.");
43 defs->optional(p.width,
"pc.02_Width",
"Width of the buffer.");
44 defs->optional(p.height,
"pc.03_Height",
"Height of the buffer.");
45 defs->optional(p.elementPath,
47 "Path inside the ARON structure to the point cloud element (delimited by '" +
48 p.elementPathDelimiter +
"').");
49 defs->optional(p.robotName,
"p.robotName",
"Name of the robot.");
52 defs->optional(p.convertToGlobalFrame,
"p.convertToGlobalFrame",
"");
65 registerToUpdates<pcl::PointXYZ>();
68 registerToUpdates<pcl::PointXYZL>();
71 registerToUpdates<pcl::PointXYZRGBA>();
74 registerToUpdates<pcl::PointXYZRGBL>();
96 ArMemToPointCloudProvider::runPolling()
102 ARMARX_INFO <<
"Done processing initial point clouds";
113 ArMemToPointCloudProvider::processUpdates(
115 const std::vector<armarx::armem::MemoryID>& updatedSnapshotIDs)
118 if (not processing.exchange(
true))
126 queryAndProvide<pcl::PointXYZ, arondto::PointCloudXYZ>();
129 queryAndProvide<pcl::PointXYZL, arondto::PointCloudXYZL>();
132 queryAndProvide<pcl::PointXYZRGBA, arondto::PointCloudXYZRGBA>();
135 queryAndProvide<pcl::PointXYZRGBL, arondto::PointCloudXYZRGBL>();
143 MetaPointCloudFormatPtr
147 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
152 info->type = PointContentType::ePoints;
153 info->capacity = p.width * p.height *
sizeof(Point3D);
156 info->type = PointContentType::eLabeledPoints;
157 info->capacity = p.width * p.height *
sizeof(LabeledPoint3D);
160 info->type = PointContentType::eColoredPoints;
161 info->capacity = p.width * p.height *
sizeof(ColoredPoint3D);
164 info->type = PointContentType::eColoredLabeledPoints;
165 info->capacity = p.width * p.height *
sizeof(ColoredLabeledPoint3D);
170 info->size = info->capacity;
174 template <
class Po
intT>
176 ArMemToPointCloudProvider::registerToUpdates()
180 const std::vector<armarx::armem::MemoryID>& updatedSnapshotIDs)
181 { this->processUpdates(entityID, updatedSnapshotIDs); };
183 p.memoryName, p.getCoreSegmentName<
PointT>(), p.providerSegmentName, p.entityName);
188 template <
class Po
intT,
class AronT>
190 ArMemToPointCloudProvider::queryAndProvide()
193 armarx::armem::MemoryID toQuery(
194 p.memoryName, p.getCoreSegmentName<
PointT>(), p.providerSegmentName, p.entityName);
195 std::optional<armarx::armem::wm::EntitySnapshot>
data =
196 memoryReader.getLatestSnapshotIn(toQuery);
198 if (
data.has_value())
210 aronAdapted->setElement(
"pointcloud", aronPointCloud);
212 AronT arondto = AronT::FromAron(aronAdapted);
214 typename pcl::PointCloud<PointT>::Ptr toProvide(
new pcl::PointCloud<PointT>());
215 *toProvide = arondto.pointcloud;
217 if (p.convertToGlobalFrame)
224 virtualRobotReaderPlugin->get().getSynchronizedRobot(p.robotName);
229 ARMARX_VERBOSE <<
"Providing point cloud with " << toProvide->points.size()
237 template <
class Po
intT>
239 ArMemToPointCloudProvider::Properties::getCoreSegmentName()
const
241 if (coreSegmentName.empty() or coreSegmentName ==
"(auto)")
247 return coreSegmentName;
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Reader useReader(const MemoryID &memoryID)
Use a memory server and get a reader for it.
void setComponent(ManagedIceObject *component)
MemoryNameSystem & memoryNameSystem()
SubscriptionHandle subscribe(const MemoryID &subscriptionID, Callback Callback)
Indicates that a query to the Memory Name System failed.
static Path FromString(const std::string &, const std::string &rootIdentifier=DEFAULT_ROOT_IDENTIFIER, const std::string &delimeter=DEFAULT_DELIMETER)
static const constexpr char * DEFAULT_ROOT_IDENTIFIER
void onConnectPointCloudProvider() override
This is called when the Component::onConnectComponent() setup is called.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onInitPointCloudProvider() override
This is called when the Component::onInitComponent() is called.
MetaPointCloudFormatPtr getDefaultPointCloudFormat() override
default point cloud format used to initialize shared memory
ArMemToPointCloudProvider()
void onExitPointCloudProvider() override
This is called when the Component::onExitComponent() setup is called.
std::string getDefaultName() const override
Retrieve default name of component.
void providePointCloud(PointCloudPtrT pointCloudPtr)
offer the new point cloud.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::string const GlobalFrame
Variable of the global coordinate system.
std::shared_ptr< Dict > DictPtr
std::shared_ptr< Variant > VariantPtr
aron::data::DictPtr make_dict(_Args &&... args)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
SimpleRunningTask(Ts...) -> SimpleRunningTask< std::function< void(void)> >
std::string GetCoreSegmentNameFor()
std::map< std::string, PointType > String2PointType
void transformPointCloudFromTo(const pcl::PointCloud< PointT > &sourceCloud, pcl::PointCloud< PointT > &targetCloud, const std::string &sourceFrame, const std::string &targetFrame, const VirtualRobot::RobotConstPtr &robot)
Transform a point cloud from a robot frame to another.