4#include <Eigen/Geometry>
16 LookAtHumanHand::init(
const Base::SpecializedInitInput& in)
20 fromAron(in.parameters.humanTrackingId, humanTrackingId);
23 if (in.parameters.hand == armarx::view_selection::skills::arondto::Hand::LEFT)
27 else if (in.parameters.hand == armarx::view_selection::skills::arondto::Hand::RIGHT)
33 ARMARX_WARNING <<
"Could not parse which hand is requested to look at.";
37 handoverTargetProvider = std::make_unique<target_provider::handover::RobotReceiver>(
38 humanTrackingId, srv_->robot);
42 return ::armarx::skills::Skill::InitResult{
46 ::armarx::skills::Skill::MainResult
47 LookAtHumanHand::main(
const Base::SpecializedMainInput& in)
53 const auto metronomeTargetPeriod =
55 armarx::Metronome metronome(metronomeTargetPeriod);
61 metronome.waitForNextTick();
64 return ::armarx::skills::Skill::MainResult{
69 LookAtHumanHand::update()
71 std::optional<armem::human::HumanPose> latestPoseOfRequestedHuman =
72 getLatestPoseOfRequestedHuman();
74 if (latestPoseOfRequestedHuman.has_value())
78 std::vector<gaze_targets::GazeTarget> gazeTargets =
79 handoverTargetProvider->updateTargetsAfterHandover(
80 latestPoseOfRequestedHuman.value());
81 for (
const auto& gazeTarget : gazeTargets)
83 ARMARX_INFO <<
"Committing gaze target " << gazeTarget;
85 srv_->viewSelectionClient.commitGazeTargets(gazeTargets);
89 ARMARX_VERBOSE <<
"Did not find any pose for the requested human tracking ID";
93 std::optional<armem::human::HumanPose>
94 LookAtHumanHand::getLatestPoseOfRequestedHuman()
99 .
withName(srv_->humanPoseMemoryID.coreSegmentName)
106 armem::client::QueryResult result =
107 srv_->memoryNameSystem.getReader(srv_->humanPoseMemoryID)
110 std::optional<armem::human::HumanPose> latestPoseOfRequestedHuman = std::nullopt;
114 [
this, &latestPoseOfRequestedHuman](
const armem::wm::EntityInstance& instance)
116 armem::human::HumanPose humanPose;
117 armarx::human::arondto::HumanPose dto =
118 armarx::human::arondto::HumanPose::FromAron(instance.
data());
121 (!latestPoseOfRequestedHuman.has_value() ||
122 humanPose.
timestamp > latestPoseOfRequestedHuman->timestamp))
124 latestPoseOfRequestedHuman = humanPose;
132 return latestPoseOfRequestedHuman;
136 LookAtHumanHand::onStopRequested()
static Duration MilliSeconds(std::int64_t 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()
bool shouldSkillTerminate() const override
Returns whether the skill should terminate as soon as possible.
LookAtHumanHand(const Services &srv)
::armarx::skills::SimpleSpecializedSkill< Params > Base
static armarx::skills::SkillDescription DefaultSkillDescription()
#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
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.