SetCustomGazeTarget.cpp
Go to the documentation of this file.
2
3#include <memory>
4#include <string>
5
6#include <Eigen/Core>
7#include <Eigen/Geometry>
8
12
18
24
26{
27
29 Base(DefaultSkillDescription()), srv_(services)
30 {
31 ;
32 }
33
34 void
36 {
37 srv_.emplace(srv);
38 }
39
41 SetCustomGazeTarget::init(const Base::SpecializedInitInput& in)
42 {
43 gazeTarget.emplace(); // populate optional
44 std::string frame = in.parameters.frame;
45 std::string agent = in.parameters.agent;
46 FramedPosition targetPos{
47 Eigen::Vector3f{in.parameters.x, in.parameters.y, in.parameters.z}, frame, agent};
48 gaze_targets::TargetPriority priority{gaze_targets::AttentionType::TaskDriven,
49 in.parameters.priority};
51 armarx::core::time::Duration::MilliSeconds(in.parameters.duration_ms);
52 gaze_targets::GazeTarget target{
53 in.parameters.gazeTargetName, targetPos, priority, duration, false};
54 gazeTarget.emplace(target);
55
56 //fromAron(in.params.target, gazeTarget.value());
57
58 return ::armarx::skills::Skill::InitResult{
60 }
61
62 ::armarx::skills::Skill::MainResult
63 SetCustomGazeTarget::main(const Base::SpecializedMainInput& in)
64 {
65 ARMARX_CHECK(gazeTarget.has_value());
66
67 return commitAndMaybeWait(srv_->viewSelectionClient,
68 gazeTarget.value(),
69 in.parameters.waitUntilFinished,
70 in.parameters.waitTimeout_ms,
71 [this]() { return shouldSkillTerminate(); });
72 }
73
74 void
75 SetCustomGazeTarget::onStopRequested()
76 {
77 if (gazeTarget.has_value())
78 {
79 srv_->viewSelectionClient.commitGazeTarget(gazeTarget.value());
80 }
81 }
82
83 armarx::skills::SkillDescription
85 {
86 ParamType defaultParameters;
87 defaultParameters.frame = "root";
88 defaultParameters.agent = "Armar7";
89 defaultParameters.gazeTargetName = "SetCustomGazeTarget";
90 defaultParameters.priority = 1;
91 defaultParameters.duration_ms = 1000;
92 defaultParameters.x = 0;
93 defaultParameters.y = 1500;
94 defaultParameters.z = 1500;
95 // waitUntilFinished must be "false" for legacy reasons. The parameter has been
96 // retrospectively introduced and this makes it backwards-compatible.
97 defaultParameters.waitUntilFinished = false;
98 // The aron default for the timeout is "wait forever"; the root profile supplies a sane
99 // bound so a caller that does not think about it still gets one.
100 defaultParameters.waitTimeout_ms = 10000;
102 .skillId =
104 .description = "Set a gaze target by coordinate, agent and frame. Supported frames "
105 "include the Global frame and the robot root frames. With "
106 "waitUntilFinished, the skill blocks until the robot's gaze is fixed on "
107 "the target and fails if it never gets there.",
108 .rootProfileDefaults = defaultParameters.toAron(),
109 // Generous: the caller's waitTimeout_ms is the real bound, this is only a backstop
110 // (navigation's blocking NavigateTo uses an hour for the same reason).
112 .parametersType = Params::ToAronType(),
113 };
114 }
115
116
117} // namespace armarx::view_selection::skills
The FramedPosition class.
Definition FramedPose.h:158
Represents a duration.
Definition Duration.h:17
static Duration Hours(std::int64_t hours)
Constructs a duration in hours.
Definition Duration.cpp:120
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition Duration.cpp:48
::armarx::skills::SimpleSpecializedSkill< Params > Base
static armarx::skills::SkillDescription DefaultSkillDescription()
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
@ TaskDriven
Task-Driven attention has highest priority.
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.
A result struct for skill initialization.
Definition Skill.h:50