25#include <Eigen/Geometry>
27#include <SimoxUtility/math/pose/pose.h>
28#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
37#include <RobotAPI/libraries/armem_index/aron/Spatial.aron.generated.h>
39#include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h>
41#include <RobotAPI/libraries/armem_robot_state/aron/RobotState.aron.generated.h>
55 defs->optional(properties.object.maxFrequencyHz,
"p.object.maxFrequency");
68 return "ObjectInstanceToIndex";
127 const std::vector<armem::MemoryID>& snapshotIDs)
130 if (not robotMemoryReader)
145 std::map<armem::MemoryID, const armem::MemoryID*> entityToSnapshot;
146 for (
const armem::MemoryID& snapshotID : snapshotIDs)
148 const armem::MemoryID entityID = snapshotID.getEntityID();
149 if (
auto it = entityToSnapshot.find(entityID); it != entityToSnapshot.end())
151 if (it->second->timestamp < snapshotID.timestamp)
153 entityToSnapshot[entityID] = &snapshotID;
158 entityToSnapshot[entityID] = &snapshotID;
163 std::vector<armem::MemoryID> queryIDs;
164 for (
const auto& [_, snapshotID] : entityToSnapshot)
166 queryIDs.push_back(*snapshotID);
169 armem::client::QueryResult result = robotMemoryReader.queryMemoryIDs(queryIDs);
174 armem::MemoryID provSegID = indexSpatialSegmentID.withProviderSegmentName(
getName());
176 armem::Commit commit;
179 [&commit, &provSegID](
const armem::wm::EntityInstance& instance)
181 const armem::arondto::ObjectInstance
data = instance.
dataAs<armem::arondto::ObjectInstance>();
183 armem::index::arondto::Spatial spatial;
188 armem::EntityUpdate&
update = commit.
add();
191 update.instancesData = { spatial.toAron() };
204 ObjectInstanceToIndex::processObjectInstance(
const armem::MemoryID&
id,
205 const std::vector<armem::MemoryID>& snapshotIDs)
207 std::scoped_lock lock(objectMutex);
208 if (not
object.has_value())
210 object = armem::objects::ObjectInstanceToIndex{
211 .objectPoseClient = objectClientPlugin->createClient(),
212 .indexSpatialMemoryWriter = indexSpatialMemoryWriter,
213 .indexSpatialProviderSegmentID =
215 .indexNamedProviderSegmentID =
218 armem::objects::ObjectInstanceToIndex::Parameters{
224 object->fetchAndCommitObjectInstances(snapshotIDs);
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
static Frequency Hertz(std::int64_t hertz)
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
std::string getName() const
Retrieve name of object.
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
void RemoteGui_update() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
Pure virtual hook for the subclass.
void onExitComponent() override
Hook for subclass.
void createRemoteGuiTab()
std::string getDefaultName() const override
MemoryID withProviderSegmentName(const std::string &name) const
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
MemoryID withEntityName(const std::string &name) const
AronDtoT dataAs() const
Get the data converted to a generated Aron DTO class.
Reader getReader(const MemoryID &memoryID)
Get a reader to the given memory name.
Writer useWriter(const MemoryID &memoryID)
Use a memory server and get a writer 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.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
const MemoryID spatialSegmentID
const MemoryID namedSegmentID
const MemoryID instaceSegmentID
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void RemoteGui_startRunningTask()
void RemoteGui_createTab(std::string const &name, RemoteGui::Client::Widget const &rootWidget, RemoteGui::Client::Tab *tab)
bool forEachInstance(InstanceFunctionT &&func)
wm::Memory memory
The slice of the memory that matched the query.