30 return "ArMemToPointCloudProvider";
39 defs->optional(p.memoryName,
"mem.01_MemoryName",
"Name of the memory.");
42 "mem.02_CoreSegmentName",
43 "Name of the core segment. If empty or (auto), this is derived from the point type.");
44 defs->optional(p.providerSegmentName,
45 "mem.03_ProviderSegmentName",
46 "Name of the provider segment(s).");
47 defs->optional(p.entityName,
"mem.04_EntityName",
"Name of the entity.");
49 defs->optional(p.pointtype,
"pc.01_PointType",
"The type of the point cloud.");
50 defs->optional(p.width,
"pc.02_Width",
"Width of the buffer.");
51 defs->optional(p.height,
"pc.03_Height",
"Height of the buffer.");
52 defs->optional(p.elementPath,
54 "Path inside the ARON structure to the point cloud element (delimited by '" +
55 p.elementPathDelimiter +
"').");
56 defs->optional(p.robotName,
"p.robotName",
"Name of the robot.");
59 defs->optional(p.convertToGlobalFrame,
"p.convertToGlobalFrame",
"");
72 registerToUpdates<pcl::PointXYZ>();
75 registerToUpdates<pcl::PointXYZL>();
78 registerToUpdates<pcl::PointXYZRGBA>();
81 registerToUpdates<pcl::PointXYZRGBL>();
103 ArMemToPointCloudProvider::runPolling()
109 ARMARX_INFO <<
"Done processing initial point clouds";
120 ArMemToPointCloudProvider::processUpdates(
122 const std::vector<armarx::armem::MemoryID>& updatedSnapshotIDs)
125 if (not processing.exchange(
true))
133 queryAndProvide<pcl::PointXYZ, arondto::PointCloudXYZ>();
136 queryAndProvide<pcl::PointXYZL, arondto::PointCloudXYZL>();
139 queryAndProvide<pcl::PointXYZRGBA, arondto::PointCloudXYZRGBA>();
142 queryAndProvide<pcl::PointXYZRGBL, arondto::PointCloudXYZRGBL>();
150 MetaPointCloudFormatPtr
154 MetaPointCloudFormatPtr info =
new MetaPointCloudFormat();
159 info->type = PointContentType::ePoints;
160 info->capacity = p.width * p.height *
sizeof(Point3D);
163 info->type = PointContentType::eLabeledPoints;
164 info->capacity = p.width * p.height *
sizeof(LabeledPoint3D);
167 info->type = PointContentType::eColoredPoints;
168 info->capacity = p.width * p.height *
sizeof(ColoredPoint3D);
171 info->type = PointContentType::eColoredLabeledPoints;
172 info->capacity = p.width * p.height *
sizeof(ColoredLabeledPoint3D);
177 info->size = info->capacity;
181 template <
class Po
intT>
183 ArMemToPointCloudProvider::registerToUpdates()
187 const std::vector<armarx::armem::MemoryID>& updatedSnapshotIDs)
188 { this->processUpdates(entityID, updatedSnapshotIDs); };
190 p.memoryName, p.getCoreSegmentName<
PointT>(), p.providerSegmentName, p.entityName);
195 template <
class Po
intT,
class AronT>
197 ArMemToPointCloudProvider::queryAndProvide()
200 armarx::armem::MemoryID toQuery(
201 p.memoryName, p.getCoreSegmentName<
PointT>(), p.providerSegmentName, p.entityName);
202 std::optional<armarx::armem::wm::EntitySnapshot>
data =
203 memoryReader.getLatestSnapshotIn(toQuery);
205 if (
data.has_value())
217 aronAdapted->setElement(
"pointcloud", aronPointCloud);
219 AronT arondto = AronT::FromAron(aronAdapted);
221 typename pcl::PointCloud<PointT>::Ptr toProvide(
new pcl::PointCloud<PointT>());
222 *toProvide = arondto.pointcloud;
224 if (p.convertToGlobalFrame)
231 virtualRobotReaderPlugin->get().getSynchronizedRobot(p.robotName);
236 ARMARX_VERBOSE <<
"Providing point cloud with " << toProvide->points.size()
244 template <
class Po
intT>
246 ArMemToPointCloudProvider::Properties::getCoreSegmentName()
const
248 if (coreSegmentName.empty() or coreSegmentName ==
"(auto)")
254 return coreSegmentName;
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
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
static std::string GetDefaultName()
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.