30 #include <MemoryX/interface/core/EntityBase.h>
31 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
32 #include <MemoryX/interface/memorytypes/MemorySegments.h>
40 virtual public PersistentObjectInstanceSegmentBase
45 bool useMongoIds =
true) :
47 PersistentObjectInstanceSegmentBase()
53 const ::Ice::Current& = Ice::emptyCurrent)
const override
55 return ObjectInstanceBasePtr::dynamicCast(getEntityById(
id));
60 const ::Ice::Current& = Ice::emptyCurrent)
const override
62 return ObjectInstanceBasePtr::dynamicCast(getEntityByName(name));
67 const ::Ice::Current&
c = Ice::emptyCurrent)
const override
69 ObjectInstanceList result;
71 classList.push_back(className);
72 return getObjectInstancesByClassList(classList,
c);
77 const ::Ice::Current& = Ice::emptyCurrent)
const override
79 ObjectInstanceList result;
80 const EntityBaseList entityList = getEntitiesByAttrValueList(
"classes", classList);
82 for (EntityBaseList::const_iterator it = entityList.begin(); it != entityList.end();
85 const ObjectInstanceBasePtr instance = ObjectInstanceBasePtr::dynamicCast(*it);
89 result.push_back(instance);
98 const ::memoryx::MotionModelInterfacePtr& newMotionModel,
99 const ::Ice::Current& = Ice::emptyCurrent)
override
101 throw armarx::LocalException()
102 <<
"This function does not work on the persistent instance segment since the "
103 "motion model is only temporary!";
107 ObjectInstancePtr::dynamicCast(getObjectInstanceById(entityId));
108 MotionModelInterfacePtr oldMotionModel =
object->getMotionModel();
112 armarx::LinkedPoseBasePtr oldPose = oldMotionModel->getPoseAtLastLocalisation();
116 newMotionModel->setPoseAtLastLocalisation(oldPose, NULL, NULL);
121 <<
"Object has an old motion model, but that motion model has no pose.";
127 <<
"Object didn't have a motion model before, this may cause problems";
130 object->setMotionModel(AbstractMotionModelPtr::dynamicCast(newMotionModel));
135 const armarx::LinkedPoseBasePtr& objectPose,
136 const ::Ice::Current& = Ice::emptyCurrent)
override
139 ObjectInstancePtr::dynamicCast(getObjectInstanceById(entityId));
142 armarx::Vector3Ptr::dynamicCast(objectPose->position)->toEigen(),
145 object->setPosition(position);
147 armarx::QuaternionPtr::dynamicCast(objectPose->orientation)->toEigen(),
150 object->setOrientation(orientation);
156 object->getMotionModel()->setPoseAtLastLocalisation(objectPose, NULL, NULL);
161 const armarx::FramedPoseBasePtr& objectPose,
162 const Ice::Current&)
override
165 ObjectInstancePtr::dynamicCast(getObjectInstanceById(entityId));
168 armarx::Vector3Ptr::dynamicCast(objectPose->position)->toEigen(),
171 object->setPosition(position);
172 object->setPositionUncertainty(
175 armarx::QuaternionPtr::dynamicCast(objectPose->orientation)->toEigen(),
178 object->setOrientation(orientation);
181 if (object->getMotionModel())
184 <<
" has a motion model - You should not call "
185 "setObjectPoseWithoutMotionModel() when a motion model is set. "
186 "Use set setObjectPose() instead!";
192 const std::string& className,
193 const armarx::LinkedPoseBasePtr& objectPose,
194 const ::memoryx::MotionModelInterfacePtr& motionModel,
195 const ::Ice::Current& = Ice::emptyCurrent)
override
199 armarx::Vector3Ptr::dynamicCast(objectPose->position)->toEigen(),
202 object->setPosition(position);
204 armarx::QuaternionPtr::dynamicCast(objectPose->orientation)->toEigen(),
207 object->setOrientation(orientation);
209 objectPose->position->x, objectPose->position->y, objectPose->position->z};
213 object->setPositionUncertainty(uncertainty);
214 object->addClass(className, 1.0);
215 object->setExistenceCertainty(1.0);
217 motionModel->setPoseAtLastLocalisation(objectPose, NULL, NULL);
218 object->setMotionModel(AbstractMotionModelPtr::dynamicCast(motionModel));
220 return addEntity(
object);