21 const WorkingMemoryInterfacePrx& workingMemory,
27 this->robotStateComponent = robotStateComponent;
29 VirtualRobot::RobotIO::RobotDescription::eStructure);
30 this->objectInstanceSegment = workingMemory->getObjectInstancesSegment();
40 <<
input.object.className <<
"' found.";
44 ARMARX_VERBOSE <<
"Attaching object '" << instance->getId() <<
"' (class '" << instance->getMostProbableClass() <<
"')"
45 <<
" to robot node '" <<
input.robotNodeName <<
"'.";
47 Attachment attachment;
48 attachment.robotNode =
input.robotNodeName;
49 if (
input.useCurrentPose)
54 if (
input.objectOffset)
56 attachment.objectOffset = armarx::PosePtr::dynamicCast(
input.objectOffset)->toEigen();
67 ARMARX_WARNING <<
"No object instance with ID '" << detachment.object.memoryID <<
"' or class '"
68 << detachment.object.className <<
"' found.";
72 if (
auto it = attachments.find(
id); it != attachments.end())
74 ARMARX_VERBOSE <<
"Detaching object '" <<
id <<
"' from robot node '" << it->second.robotNode <<
"'.";
75 attachments.erase(it);
87 EntityBaseList entities = objectInstanceSegment->getAllEntities();
89 std::vector<ObjectInstancePtr> instances;
90 for (
const auto& entity : entities)
95 instances.push_back(
object);
105 if (
auto it = attachments.find(object->getId()); it != attachments.end())
107 return getAttachedObjectPoseInFrame(it->second, frame);
115 Eigen::Matrix4f ObjectInstanceToRobotNodeAttachments::getAttachedObjectPoseInFrame(
const Attachment& attachment,
const std::string& frame)
120 attachment.robotNode, robot->getName());
124 return framed.toGlobalEigen(robot);
128 framed.changeFrame(robot, frame);
129 return framed.toEigen();
133 Eigen::Matrix4f ObjectInstanceToRobotNodeAttachments::getDetachedObjectPoseInFrame(
136 if (object->getPose()->getFrame() == frame)
138 return object->getPose()->toEigen();
142 auto it = objectPoseCache.find(object->getId());
143 if (it != objectPoseCache.end() && object->hasLocalizationTimestamp())
145 const IceUtil::Time localizationTimestamp =
object->getLocalizationTimestamp();
147 if (previousTimestamp >= localizationTimestamp)
163 ?
object->getLocalizationTimestamp()
173 objectPoseCache[
object->getId()] = std::make_pair(ts, pose);
181 return attachments.count(
id) > 0;
188 return object.memoryID;
192 return instance->getId();
207 if (instance && instance->getId() ==
object.memoryID)
219 if (instance && instance->getMostProbableClass() ==
object.className)