8#include <Eigen/Geometry>
9#include <Eigen/src/Core/Matrix.h>
25#include <armarx/view_selection/gaze_targets/aron/AttentionType.aron.generated.h>
31#include <VisionX/libraries/armem_human/aron/HumanPose.aron.generated.h>
43 LookAtHumanFace::init(
const Base::SpecializedInitInput& in)
47 fromAron(in.parameters.humanTrackingId, humanTrackingId);
49 handoverTargetProvider = std::make_unique<target_provider::handover::RobotReceiver>(
50 humanTrackingId, srv_->robot);
53 return ::armarx::skills::Skill::InitResult{
58 LookAtHumanFace::main(
const Base::SpecializedMainInput& in)
66 const auto metronomeTargetPeriod =
77 metronome.waitForNextTick();
81 ARMARX_INFO <<
"Timeout (skill parameter " << in.parameters.timeout <<
" ) reached";
88 return ::armarx::skills::Skill::MainResult{
93 LookAtHumanFace::update()
95 std::optional<armem::human::HumanPose> latestPoseOfRequestedHuman =
96 getLatestPoseOfRequestedHuman();
98 if (latestPoseOfRequestedHuman.has_value())
101 std::vector<gaze_targets::GazeTarget> gazeTargets =
102 handoverTargetProvider->updateTargetsAfterHandover(
103 latestPoseOfRequestedHuman.value());
108 for (
auto& gazeTarget : gazeTargets)
110 gazeTarget.priority.priority = in.priority;
111 if (in.zOffset.has_value())
113 gazeTarget.position.z += in.zOffset.value();
122 srv_->viewSelectionClient.commitGazeTargets(gazeTargets);
126 ARMARX_VERBOSE <<
"Did not find any pose for the requested human tracking ID";
130 std::optional<armem::human::HumanPose>
131 LookAtHumanFace::getLatestPoseOfRequestedHuman()
136 .
withName(srv_->humanPoseMemoryID.coreSegmentName)
143 armem::client::QueryResult result =
144 srv_->memoryNameSystem.getReader(srv_->humanPoseMemoryID)
147 std::optional<armem::human::HumanPose> latestPoseOfRequestedHuman = std::nullopt;
151 [
this, &latestPoseOfRequestedHuman](
const armem::wm::EntityInstance& instance)
153 armem::human::HumanPose humanPose;
154 armarx::human::arondto::HumanPose dto =
155 armarx::human::arondto::HumanPose::FromAron(instance.
data());
158 (!latestPoseOfRequestedHuman.has_value() ||
159 humanPose.
timestamp > latestPoseOfRequestedHuman->timestamp))
161 latestPoseOfRequestedHuman = humanPose;
169 return latestPoseOfRequestedHuman;
173 LookAtHumanFace::onStopRequested()
176 stop_requested_ =
true;
179 armarx::skills::SkillDescription
182 using armarx::view_selection::gaze_targets::arondto::AttentionType;
185 defaultParameters.priority = 1;
186 defaultParameters.attentionType = AttentionType::TaskDriven;
188 defaultParameters.zOffset = std::nullopt;
192 .description =
"Look at the face of a human specified by their tracking ID.",
193 .rootProfileDefaults = defaultParameters.toAron(),
195 .parametersType = Params::ToAronType()};
static DateTime Now()
Current time on the virtual clock.
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
static Duration MilliSecondsDouble(double milliSeconds)
Constructs a duration in milliseconds.
const DataT & data() const
QueryInput buildQueryInput() const
CoreSegmentSelector & coreSegments()
Start specifying core segments.
CoreSegmentSelector & withName(const std::string &name) override
ProviderSegmentSelector & providerSegments()
Start specifying provider segments.
EntitySelector & all() override
SnapshotSelector & snapshots()
Start specifying entity snapshots.
EntitySelector & entities()
Start specifying entities.
ProviderSegmentSelector & all() override
SnapshotSelector & latest()
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
arondto::LookAtHumanFaceParams ParamType
bool shouldSkillTerminate() const override
Returns whether the skill should terminate as soon as possible.
arondto::LookAtHumanFaceParams getParameters() const
::armarx::skills::SimpleSpecializedSkill< Params > Base
static armarx::skills::SkillDescription DefaultSkillDescription()
LookAtHumanFace(const Services &srv)
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
query::Builder QueryBuilder
const std::string LookAtHumanFace
This file is part of ArmarX.
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
bool forEachInstance(InstanceFunctionT &&func)
wm::Memory memory
The slice of the memory that matched the query.
std::optional< std::string > humanTrackingId
A result struct for skill initialization.
A result struct for th main method of a skill.