20 const WorkingMemoryInterfacePrx& workingMemory,
26 this->robotStateComponent = robotStateComponent;
28 robotStateComponent,
"", {}, VirtualRobot::RobotIO::RobotDescription::eStructure);
29 this->objectInstanceSegment = workingMemory->getObjectInstancesSegment();
34 const AttachObjectToRobotNodeInput&
input)
40 <<
"' or class '" <<
input.object.className <<
"' found.";
44 ARMARX_VERBOSE <<
"Attaching object '" << instance->getId() <<
"' (class '"
45 << instance->getMostProbableClass() <<
"')"
46 <<
" to robot node '" <<
input.robotNodeName <<
"'.";
48 Attachment attachment;
49 attachment.robotNode =
input.robotNodeName;
50 if (
input.useCurrentPose)
55 if (
input.objectOffset)
57 attachment.objectOffset = armarx::PosePtr::dynamicCast(
input.objectOffset)->toEigen();
65 const DetachObjectFromRobotNodeInput& detachment)
70 ARMARX_WARNING <<
"No object instance with ID '" << detachment.object.memoryID
71 <<
"' or class '" << detachment.object.className <<
"' found.";
75 if (
auto it = attachments.find(
id); it != attachments.end())
77 ARMARX_VERBOSE <<
"Detaching object '" <<
id <<
"' from robot node '"
78 << it->second.robotNode <<
"'.";
79 attachments.erase(it);
87 std::vector<ObjectInstancePtr>
90 EntityBaseList entities = objectInstanceSegment->getAllEntities();
92 std::vector<ObjectInstancePtr> instances;
93 for (
const auto& entity : entities)
98 instances.push_back(
object);
107 const std::string& frame)
109 if (
auto it = attachments.find(object->getId()); it != attachments.end())
111 return getAttachedObjectPoseInFrame(it->second, frame);
120 ObjectInstanceToRobotNodeAttachments::getAttachedObjectPoseInFrame(
const Attachment& attachment,
121 const std::string& frame)
126 attachment.robotNode,
131 return framed.toGlobalEigen(robot);
135 framed.changeFrame(robot, frame);
136 return framed.toEigen();
141 ObjectInstanceToRobotNodeAttachments::getDetachedObjectPoseInFrame(
ObjectInstancePtr object,
142 const std::string& frame)
144 if (object->getPose()->getFrame() == frame)
146 return object->getPose()->toEigen();
150 auto it = objectPoseCache.find(object->getId());
151 if (it != objectPoseCache.end() && object->hasLocalizationTimestamp())
153 const IceUtil::Time localizationTimestamp =
object->getLocalizationTimestamp();
155 if (previousTimestamp >= localizationTimestamp)
171 ?
object->getLocalizationTimestamp()
181 objectPoseCache[
object->getId()] = std::make_pair(ts, pose);
188 return attachments.count(
id) > 0;
196 return object.memoryID;
200 return instance->getId();
216 if (instance && instance->getId() ==
object.memoryID)
228 if (instance && instance->getMostProbableClass() ==
object.className)