41 const std::string Component::defaultName =
"ObjectMemoryToSimulation";
57 def->component(simulator);
61 def->optional(properties.objectPoseProviderName,
"p.objectPoseProviderName");
112 synchronizeSimulator();
131 return Component::defaultName;
138 return Component::defaultName;
146 void Component::synchronizeSimulator(const ::Ice::Current&)
148 ARMARX_INFO <<
"Synchronizing memory and simulator";
151 const std::vector<armarx::objpose::ObjectPose> objectPoses = (properties.objectPoseProviderName.empty()) ?
getObjectPoses() :
getObjectPosesByProvider(properties.objectPoseProviderName);
153 ARMARX_INFO <<
"Found " << objectPoses.size() <<
" objects";
155 for (
const auto& objectPose : objectPoses)
160 const auto objectInfo = finder.
findObject(objectPose);
163 const auto globalPoseIce =
armarx::toIce(objectPose.objectPoseGlobal);
164 const auto instanceName = objectPose.objectID.str();
166 const auto articulatedModelFile = objectInfo->getArticulatedModel();
167 if (articulatedModelFile.has_value())
169 ARMARX_INFO <<
"Found robot: " << articulatedModelFile->absolutePath;
171 const auto robotName = simulator->addRobotFromFile(
toPackagePath(articulatedModelFile.value()).
serialize());
173 simulator->setRobotPose(robotName, globalPoseIce);
181 simulator->addObjectFromFile(
182 packagePath.serialize(), instanceName, globalPoseIce, objectPose.isStatic);