LookAt.cpp
Go to the documentation of this file.
1#include "LookAt.h"
2
3#include <Eigen/Core>
4#include <Eigen/Geometry>
5
9
11{
12
13 LookAt::LookAt(const Context& services) : Base(DefaultSkillDescription()), srv_(services)
14 {
15 }
16
18 LookAt::init(const Base::SpecializedInitInput& in)
19 {
20 gazeTarget.emplace(); // populate optional
21
22 fromAron(in.parameters.target, gazeTarget.value());
23
24 return ::armarx::skills::Skill::InitResult{
26 }
27
29 LookAt::main(const Base::SpecializedMainInput& in)
30 {
31 ARMARX_CHECK(gazeTarget.has_value());
32
33 return commitAndMaybeWait(srv_->viewSelectionClient,
34 gazeTarget.value(),
35 in.parameters.waitUntilReached,
36 in.parameters.waitTimeout_ms,
37 [this]() { return shouldSkillTerminate(); });
38 }
39
40 void
41 LookAt::onStopRequested()
42 {
43 if (gazeTarget.has_value())
44 {
45 srv_->viewSelectionClient.commitGazeTarget(gazeTarget.value());
46 }
47 }
48
49 ::armarx::skills::SkillDescription
51 {
52 ParamType defaultParameters;
53 defaultParameters.target.duration = armarx::Duration::Seconds(0);
54 defaultParameters.target.name = "";
55 defaultParameters.target.keepInQueue = false;
56 // Off by default so existing callers are unaffected; the aron default for the timeout is
57 // "wait forever", so the root profile supplies a sane bound instead.
58 defaultParameters.waitUntilReached = false;
59 defaultParameters.waitTimeout_ms = 10000;
60
62 .skillId = skill_ids::LookAt,
63 .description = "",
64 .rootProfileDefaults = defaultParameters.toAron(),
65 // Generous: the caller's waitTimeout_ms is the real bound, this is only a backstop
66 // (navigation's blocking NavigateTo uses an hour for the same reason).
68 .parametersType = Params::ToAronType(),
69 };
70 }
71
72
73} // namespace armarx::view_selection::skills
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
Definition Duration.cpp:72
static Duration Hours(std::int64_t hours)
Constructs a duration in hours.
Definition Duration.cpp:120
LookAt(const Context &services)
Definition LookAt.cpp:13
::armarx::skills::SimpleSpecializedSkill< Params > Base
Definition LookAt.h:37
static armarx::skills::SkillDescription DefaultSkillDescription()
Definition LookAt.cpp:50
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
const armarx::skills::SkillID LookAt
Definition skill_ids.cpp:36
This file is part of ArmarX.
::armarx::skills::Skill::MainResult commitAndMaybeWait(client::ViewSelection &viewSelection, const gaze_targets::GazeTarget &target, const bool waitUntilReached, const std::int64_t waitTimeout_ms, const std::function< bool()> &shouldAbort)
Commit a gaze target, optionally blocking until the robot's gaze is fixed on it.
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
A result struct for skill initialization.
Definition Skill.h:50
A result struct for th main method of a skill.
Definition Skill.h:62