25 #include <SimoxUtility/algorithm/string/string_tools.h>
26 #include <SimoxUtility/math/pose/pose.h>
43 defs->topic(debugObserver);
45 defs->optional(initialObjectIDs,
"Objects",
"Object IDs of objects to be tracked.")
46 .map(simox::alg::join(initialObjectIDs,
", "), initialObjectIDs);
48 defs->optional(singleShot,
"SingleShot",
"If true, publishes only one snapshot.");
55 return "ObjectPoseProviderExample";
60 for (
const auto& initial : initialObjectIDs)
67 providerInfo.objectType = objpose::ObjectType::KnownObject;
69 for (
const auto& obj : objects)
71 providerInfo.supportedObjects.push_back(
armarx::toIce(obj.id()));
80 this->poseEstimationTaskRun();
82 poseEstimationTask->start();
99 const objpose::provider::RequestObjectsInput&
input,
const Ice::Current&)
101 ARMARX_INFO <<
"Requested object IDs for " <<
input.relativeTimeoutMS <<
" ms: "
104 std::scoped_lock lock(requestedObjectsMutex);
108 objpose::provider::RequestObjectsOutput output;
110 for (
const auto&
id :
input.objectIDs)
112 output.results[id].success =
true;
117 void ObjectPoseProviderExample::poseEstimationTaskRun()
122 std::map<ObjectID, ObjectInfo> objectInfos;
124 while (poseEstimationTask and not poseEstimationTask->isStopped())
127 float t =
float((now - start).toSecondsDouble());
131 std::scoped_lock lock(requestedObjectsMutex);
135 if (
update.added.size() > 0 ||
update.removed.size() > 0)
138 <<
"Removed: " <<
update.removed;
145 if (objectInfos.count(
id) == 0)
147 if (std::optional<ObjectInfo> info = objectFinder.
findObject(
id))
149 objectInfos.emplace(
id, *info);
156 const ObjectInfo& info = objectInfos.at(
id);
160 pose.
objectType = objpose::ObjectType::KnownObject;
164 Eigen::Vector3f pos = 200 * Eigen::Vector3f(std::sin(t - i), std::cos(t - i), 1 + i);
165 Eigen::AngleAxisf ori((t - i) / M_PI_2, Eigen::Vector3f::UnitZ());
166 pose.
objectPose = simox::math::pose(pos, ori);
174 const float posVar = 10 + 10 * std::sin(t - i);
180 Eigen::Matrix3f rot = Eigen::AngleAxisf(0.25 * (t - i), Eigen::Vector3f::UnitZ()).toRotationMatrix();
186 const float oriVar = (M_PI_4) + (M_PI_4) * std::sin(t - i);
192 Eigen::Matrix3f rot = Eigen::AngleAxisf(0.25 * (t - i), Eigen::Vector3f::UnitZ()).toRotationMatrix();
197 pose.
confidence = 0.75 + 0.25 * std::sin(t - i);
203 ARMARX_VERBOSE <<
"Reporting " << poses.size() <<
" object poses";
211 cycle.waitForCycleDuration();