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>
56 defs->optional(properties.object.maxFrequencyHz,
"p.object.maxFrequency");
70 return "ObjectInstanceToIndex";
136 const std::vector<armem::MemoryID>& snapshotIDs)
139 if (not robotMemoryReader)
145 catch (
const armem::error::CouldNotResolveMemoryServer& e)
154 std::map<armem::MemoryID, const armem::MemoryID*> entityToSnapshot;
158 if (
auto it = entityToSnapshot.find(entityID); it != entityToSnapshot.end())
160 if (it->second->timestamp < snapshotID.timestamp)
162 entityToSnapshot[entityID] = &snapshotID;
167 entityToSnapshot[entityID] = &snapshotID;
172 std::vector<armem::MemoryID> queryIDs;
173 for (
const auto& [_, snapshotID] : entityToSnapshot)
175 queryIDs.push_back(*snapshotID);
178 armem::client::QueryResult result = robotMemoryReader.queryMemoryIDs(queryIDs);
187 result.memory.forEachInstance(
190 const armem::arondto::ObjectInstance
data = instance.dataAs<armem::arondto::ObjectInstance>();
192 armem::index::arondto::Spatial spatial;
199 update.referencedTime = instance.id().timestamp;
200 update.instancesData = { spatial.toAron() };
214 ObjectInstanceToIndex::processObjectInstance(
const armem::MemoryID&
id,
215 const std::vector<armem::MemoryID>& snapshotIDs)
217 std::scoped_lock lock(objectMutex);
218 if (not
object.has_value())
220 object = armem::objects::ObjectInstanceToIndex{
222 .indexSpatialMemoryWriter = indexSpatialMemoryWriter,
223 .indexSpatialProviderSegmentID =
225 .indexNamedProviderSegmentID =
227 .params = armem::objects::ObjectInstanceToIndex::Parameters{
235 object->fetchAndCommitObjectInstances(snapshotIDs);