31 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
46 def->topic<WorkingMemoryListenerInterface>(
"WorkingMemory",
"WorkingMemoryName");
47 def->optional(minOrientationDistance,
48 "MinOrientationDistance",
49 "Min Distance an object has to rotate until the memory receives an update");
50 def->optional(minPositionDistance,
51 "MinPositrionDistance",
52 "Min Distance an object has to move until the memory receives an update");
57 minOrientationDistance(0.25 *
M_PI), minPositionDistance(100)
64 return "SimpleEpisodicMemoryWorkingMemoryConnector";
79 memoryPrx = getProxy<WorkingMemoryInterfacePrx>(
"WorkingMemory");
94 const std::string& segmentName,
95 const memoryx::EntityBasePtr& newEntity,
98 if (segmentName !=
"objectInstances")
103 EntityPtr entity = EntityPtr::dynamicCast(newEntity);
106 std::map<int, memoryx::EntityBasePtr> entitiesForSegment = entityMap[segmentName];
107 entitiesForSegment[std::stoi(entity->getId())] = entity;
109 EntityAttributePtr pos = EntityAttributePtr::dynamicCast(entity->getAttribute(
"position"));
111 auto framedPos = posValue->getClass<armarx::FramedPositionBase>();
113 memoryx::ObjectPoseEvent o;
114 o.objectName = entity->getName();
118 o.frame = framedPos->frame;
119 o.type = memoryx::ObjectPoseEventType::NEW_OBJECT_RECOGNIZED;
120 o.receivedInMs = IceUtil::Time::now().toMilliSecondsDouble();
126 const std::string& segmentName,
127 const memoryx::EntityBasePtr& entityOld,
128 const memoryx::EntityBasePtr& entityNew,
134 if (segmentName !=
"objectInstances")
139 EntityPtr prevEntity = EntityPtr::dynamicCast(entityOld);
140 EntityPtr currEntity = EntityPtr::dynamicCast(entityNew);
143 EntityAttributePtr::dynamicCast(prevEntity->getAttribute(
"position"));
144 armarx::VariantPtr prevPosValue = armarx::VariantPtr::dynamicCast(prevPos->getValue());
145 auto prevFramedPos = prevPosValue->getClass<armarx::FramedPositionBase>();
148 EntityAttributePtr::dynamicCast(currEntity->getAttribute(
"position"));
149 armarx::VariantPtr currPosValue = armarx::VariantPtr::dynamicCast(currPos->getValue());
150 auto currFramedPos = currPosValue->getClass<armarx::FramedPositionBase>();
152 Eigen::Vector3f prevPosVector(prevFramedPos->x, prevFramedPos->y, prevFramedPos->z);
153 Eigen::Vector3f currPosVector(currFramedPos->x, currFramedPos->y, currFramedPos->z);
155 float distance = (currPosVector - prevPosVector).
norm();
157 if (
distance > minPositionDistance )
160 std::map<int, memoryx::EntityBasePtr> entitiesForSegment = entityMap[segmentName];
161 entitiesForSegment[std::stoi(currEntity->getId())] = currEntity;
163 memoryx::ObjectPoseEvent o;
164 o.objectName = currEntity->getName();
165 o.x = currPosVector(0);
166 o.y = currPosVector(1);
167 o.z = currPosVector(2);
168 o.type = memoryx::ObjectPoseEventType::OBJECT_POSE_UPDATE;
169 o.receivedInMs = IceUtil::Time::now().toMilliSecondsDouble();
176 const std::string& segmentName,
177 const memoryx::EntityBasePtr& entity,
180 ARMARX_DEBUG <<
"Entity removed: id = " << entity->getId();
192 const Ice::Current&
c)