8 #include <SimoxUtility/algorithm/string.h>
13 std::optional<Eigen::Vector3f>
17 Eigen::Vector3f sumPosition = Eigen::Vector3f::Zero();
19 for (
const auto& [
id, keypoint] : humanPose.
keypoints)
25 sumPosition += keypoint.positionCamera.toEigen();
33 if (keypoint.positionGlobal)
35 sumPosition += keypoint.positionGlobal.value().toEigen();
42 if (keypoint.positionRobot)
44 sumPosition += keypoint.positionRobot.value().toEigen();
53 if (sumWeights == 0)
return std::nullopt;
55 return sumPosition / sumWeights;
59 std::optional<HumanPose>
63 std::optional<HumanPose> nearestHumanPose = std::nullopt;
64 double minDistance = std::numeric_limits<double>::infinity();
65 for (
const HumanPose &humanPose : humanPoses)
67 if (parameters.
modelIDs.empty() or parameters.
modelIDs.count(humanPose.poseModelId))
69 const std::optional<Eigen::Vector3f> meanPosition
71 if (not meanPosition)
continue;
76 nearestHumanPose = humanPose;
84 return nearestHumanPose;
88 const std::string &prefix)
90 const std::string prefix_ = prefix +
"nearestHuman.";
91 def->optional(
positionMM.x(), prefix_ +
"position.x",
"Anchor position (x-coordinate) in mm.");
92 def->optional(
positionMM.y(), prefix_ +
"position.y",
"Anchor position (y-coordinate) in mm.");
93 def->optional(
positionMM.z(), prefix_ +
"position.z",
"Anchor position (z-coordinate) in mm.");
94 def->optional(
coordSystem, prefix_ +
"coordSystem",
"Coordinate system of the anchor position.")
99 .setCaseInsensitive(
true);
100 def->optional(
distanceThresholdMM, prefix_ +
"distanceThreshold",
"Optional minimum distance threshold in mm.");
101 def->optional(
modelIDs, prefix_ +
"allowedModelIDs",
"Allowed pose model ids, seperated by commas.");
113 modelIDs = std::set<std::string>(ids.begin(), ids.end());