26 #include <Eigen/Geometry>
28 #include <IceUtil/Time.h>
30 #include <SimoxUtility/math/pose/pose.h>
31 #include <VirtualRobot/Robot.h>
32 #include <VirtualRobot/VirtualRobot.h>
33 #include <VirtualRobot/XML/RobotIO.h>
59 defs->topic(debugObserver);
61 defs->optional(p.updateFrequency,
"updateFrequency",
"Memory update frequency (write).");
63 defs->optional(p.obj.dataset,
"p.obj.dataset",
"");
64 defs->optional(p.obj.className,
"p.obj.class",
"");
73 return "ArticulatedObjectLocalizerExample";
80 auto& articulatedObjectWriter = articulatedObjectWriterPlugin->get();
82 articulatedObjectWriter.setProviderName(
getName());
94 static_cast<int>(1000.f / p.updateFrequency));
110 ArticulatedObjectLocalizerExample::createArticulatedObject()
112 auto& articulatedObjectReader = articulatedObjectReaderPlugin->get();
114 const std::string dishwasherName = p.obj.dataset +
"/" + p.obj.className;
116 const auto descriptions =
117 articulatedObjectReader.queryDescriptions(
armem::Time::Now(), std::nullopt);
119 ARMARX_INFO <<
"Found " << descriptions.size() <<
" articulated object descriptions";
121 for (
const auto& description : descriptions)
126 const auto it = std::find_if(
127 descriptions.begin(),
130 { return desc.name == dishwasherName; });
132 if (it == descriptions.end())
134 ARMARX_WARNING <<
"Articulated object " << dishwasherName <<
" not (yet) available";
138 auto obj = VirtualRobot::RobotIO::loadRobot(it->xml.toSystemPath(),
139 VirtualRobot::RobotIO::eStructure);
147 obj->setType(it->name);
155 if (articulatedObject ==
nullptr)
157 articulatedObject = createArticulatedObject();
159 if (articulatedObject ==
nullptr)
165 const auto state = articulatedObjectReaderPlugin->get().queryState(
166 articulatedObject->getType() +
"/" + articulatedObject->getName(),
168 p.obj.readProviderName);
171 articulatedObject->setGlobalPose(state->globalPose.matrix());
176 const float t =
static_cast<float>((now - start).toSecondsDouble());
179 const float k = (1 + std::sin(t / (M_2_PI))) / 2;
181 auto jointValues = articulatedObject->getJointValues();
183 for (
auto& [name, jointValue] : jointValues)
185 const auto node = articulatedObject->getRobotNode(name);
186 jointValue = node->unscaleJointValue(k, 0, 1);
190 articulatedObject->setJointValues(jointValues);
192 auto& articulatedObjectWriter = articulatedObjectWriterPlugin->get();
193 articulatedObjectWriter.storeArticulatedObject(articulatedObject, now);