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";
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)
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
std::string m_simple_episodic_memory_proxy_name
memoryx::SimpleEpisodicMemoryInterface::ProxyType m_simple_episodic_memory
void onInitComponent() override
void reportEntityUpdated(const std::string &, const EntityBasePtr &, const EntityBasePtr &, const Ice::Current &) override
SimpleEpisodicMemoryWorkingMemoryConnector()
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportEntityRemoved(const std::string &, const EntityBasePtr &, const Ice::Current &) override
void reportSnapshotCompletelyLoaded(const Ice::Current &) override
void onConnectComponent() override
void reportSnapshotLoaded(const std::string &, const Ice::Current &) override
void reportEntityCreated(const std::string &, const EntityBasePtr &, const Ice::Current &) override
void onExitComponent() override
void reportMemoryCleared(const std::string &, const Ice::Current &) override
std::string getDefaultName() const override
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
IceInternal::Handle< Variant > VariantPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< EntityAttribute > EntityAttributePtr
Typedef of EntityAttributePtr as IceInternal::Handle<EntityAttribute> for convenience.
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
double norm(const Point &a)
double distance(const Point &a, const Point &b)