32 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
47 def->topic<WorkingMemoryListenerInterface>(
"WorkingMemory",
"WorkingMemoryName");
48 def->optional(minOrientationDistance,
"MinOrientationDistance",
"Min Distance an object has to rotate until the memory receives an update");
49 def->optional(minPositionDistance,
"MinPositrionDistance",
"Min Distance an object has to move until the memory receives an update");
54 minOrientationDistance(0.25 *
M_PI),
55 minPositionDistance(100)
61 return "SimpleEpisodicMemoryWorkingMemoryConnector";
77 memoryPrx = getProxy<WorkingMemoryInterfacePrx>(
"WorkingMemory");
95 if (segmentName !=
"objectInstances")
100 EntityPtr entity = EntityPtr::dynamicCast(newEntity);
103 std::map<int, memoryx::EntityBasePtr> entitiesForSegment = entityMap[segmentName];
104 entitiesForSegment[std::stoi(entity->getId())] = entity;
106 EntityAttributePtr pos = EntityAttributePtr::dynamicCast(entity->getAttribute(
"position"));
108 auto framedPos = posValue->getClass<armarx::FramedPositionBase>();
110 memoryx::ObjectPoseEvent o;
111 o.objectName = entity->getName();
115 o.frame = framedPos->frame;
116 o.type = memoryx::ObjectPoseEventType::NEW_OBJECT_RECOGNIZED;
117 o.receivedInMs = IceUtil::Time::now().toMilliSecondsDouble();
122 const memoryx::EntityBasePtr& entityOld,
123 const memoryx::EntityBasePtr& entityNew,
const Ice::Current&)
128 if (segmentName !=
"objectInstances")
133 EntityPtr prevEntity = EntityPtr::dynamicCast(entityOld);
134 EntityPtr currEntity = EntityPtr::dynamicCast(entityNew);
136 EntityAttributePtr prevPos = EntityAttributePtr::dynamicCast(prevEntity->getAttribute(
"position"));
137 armarx::VariantPtr prevPosValue = armarx::VariantPtr::dynamicCast(prevPos->getValue());
138 auto prevFramedPos = prevPosValue->getClass<armarx::FramedPositionBase>();
140 EntityAttributePtr currPos = EntityAttributePtr::dynamicCast(currEntity->getAttribute(
"position"));
141 armarx::VariantPtr currPosValue = armarx::VariantPtr::dynamicCast(currPos->getValue());
142 auto currFramedPos = currPosValue->getClass<armarx::FramedPositionBase>();
144 Eigen::Vector3f prevPosVector(prevFramedPos->x, prevFramedPos->y, prevFramedPos->z);
145 Eigen::Vector3f currPosVector(currFramedPos->x, currFramedPos->y, currFramedPos->z);
147 float distance = (currPosVector - prevPosVector).
norm();
149 if (
distance > minPositionDistance )
152 std::map<int, memoryx::EntityBasePtr> entitiesForSegment = entityMap[segmentName];
153 entitiesForSegment[std::stoi(currEntity->getId())] = currEntity;
155 memoryx::ObjectPoseEvent o;
156 o.objectName = currEntity->getName();
157 o.x = currPosVector(0);
158 o.y = currPosVector(1);
159 o.z = currPosVector(2);
160 o.type = memoryx::ObjectPoseEventType::OBJECT_POSE_UPDATE;
161 o.receivedInMs = IceUtil::Time::now().toMilliSecondsDouble();
169 ARMARX_DEBUG <<
"Entity removed: id = " << entity->getId();