25 #include <SimoxUtility/algorithm/string/string_tools.h>
26 #include <SimoxUtility/math/pose/pose.h>
44 defs->topic(debugObserver);
46 defs->optional(initialObjectIDs,
"Objects",
"Object IDs of objects to be tracked.")
47 .map(simox::alg::join(initialObjectIDs,
", "), initialObjectIDs);
49 defs->optional(singleShot,
"SingleShot",
"If true, publishes only one snapshot.");
57 return "ObjectPoseProviderExample";
63 for (
const auto& initial : initialObjectIDs)
70 providerInfo.objectType = objpose::ObjectType::KnownObject;
72 for (
const auto& obj : objects)
74 providerInfo.supportedObjects.push_back(
armarx::toIce(obj.id()));
83 poseEstimationTask->start();
102 objpose::provider::RequestObjectsOutput
107 <<
" ms: " <<
input.objectIDs;
109 std::scoped_lock lock(requestedObjectsMutex);
113 objpose::provider::RequestObjectsOutput output;
115 for (
const auto&
id :
input.objectIDs)
117 output.results[id].success =
true;
123 ObjectPoseProviderExample::poseEstimationTaskRun()
128 std::map<ObjectID, ObjectInfo> objectInfos;
130 while (poseEstimationTask and not poseEstimationTask->isStopped())
133 float t =
float((now - start).toSecondsDouble());
137 std::scoped_lock lock(requestedObjectsMutex);
141 if (
update.added.size() > 0 ||
update.removed.size() > 0)
150 if (objectInfos.count(
id) == 0)
152 if (std::optional<ObjectInfo> info = objectFinder.
findObject(
id))
154 objectInfos.emplace(
id, *info);
161 const ObjectInfo& info = objectInfos.at(
id);
165 pose.
objectType = objpose::ObjectType::KnownObject;
169 Eigen::Vector3f pos =
170 200 * Eigen::Vector3f(std::sin(t - i), std::cos(t - i), 1 + i);
171 Eigen::AngleAxisf ori((t - i) / M_PI_2, Eigen::Vector3f::UnitZ());
172 pose.
objectPose = simox::math::pose(pos, ori);
180 const float posVar = 10 + 10 * std::sin(t - i);
187 Eigen::AngleAxisf(0.25 * (t - i), Eigen::Vector3f::UnitZ())
194 const float oriVar = (M_PI_4) + (M_PI_4)*std::sin(t - i);
201 Eigen::AngleAxisf(0.25 * (t - i), Eigen::Vector3f::UnitZ())
207 pose.
confidence = 0.75 + 0.25 * std::sin(t - i);
213 ARMARX_VERBOSE <<
"Reporting " << poses.size() <<
" object poses";
221 cycle.waitForCycleDuration();