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
23
25{
26
28 Base(DefaultSkillDescription()), srv_(services)
29 {
30 ;
31 }
32
33 void
35 {
36 srv_.emplace(srv);
37 }
38
40 SetCustomGazeTarget::init(const Base::SpecializedInitInput& in)
41 {
42 gazeTarget.emplace(); // populate optional
43 std::string frame = in.parameters.frame;
44 std::string agent = in.parameters.agent;
45 FramedPosition targetPos{
46 Eigen::Vector3f{in.parameters.x, in.parameters.y, in.parameters.z}, frame, agent};
47 gaze_targets::TargetPriority priority{gaze_targets::AttentionType::TaskDriven,
48 in.parameters.priority};
50 armarx::core::time::Duration::MilliSeconds(in.parameters.duration_ms);
51 gaze_targets::GazeTarget target{
52 in.parameters.gazeTargetName, targetPos, priority, duration, false};
53 gazeTarget.emplace(target);
54
55 //fromAron(in.params.target, gazeTarget.value());
56
57 return ::armarx::skills::Skill::InitResult{
59 }
60
61 ::armarx::skills::Skill::MainResult
62 SetCustomGazeTarget::main(const Base::SpecializedMainInput& in)
63 {
64 ARMARX_CHECK(gazeTarget.has_value());
65
66 ARMARX_INFO << "Committing gaze target " << gazeTarget.value();
67 srv_->viewSelectionClient.commitGazeTarget(gazeTarget.value());
68
69 if (in.parameters.waitUntilFinished)
70 {
71 ARMARX_IMPORTANT << "NYI! Waiting for head to reach target (waitUntilFinished) "
72 "parameter is not yet implemented.";
73 }
74
75 return ::armarx::skills::Skill::MainResult{
77 }
78
79 void
80 SetCustomGazeTarget::onStopRequested()
81 {
82 if (gazeTarget.has_value())
83 {
84 srv_->viewSelectionClient.commitGazeTarget(gazeTarget.value());
85 }
86 }
87
88 armarx::skills::SkillDescription
90 {
91 ParamType defaultParameters;
92 defaultParameters.frame = "root";
93 defaultParameters.agent = "Armar7";
94 defaultParameters.gazeTargetName = "SetCustomGazeTarget";
95 defaultParameters.priority = 1;
96 defaultParameters.duration_ms = 1000;
97 defaultParameters.x = 0;
98 defaultParameters.y = 1500;
99 defaultParameters.z = 1500;
100 // waitUntilFinished must be "false" for legacy reasons. The parameter has been
101 // retrospectively introduced and this makes it backwards-compatible.
102 defaultParameters.waitUntilFinished = false;
104 .skillId =
106 .description = "Set a gaze target by coordinate, agent and frame. Supported frames "
107 "include the Global frame and the robot root frames. Please note that "
108 "the waitUntilFinished parameter is not yet implemented.",
109 .rootProfileDefaults = defaultParameters.toAron(),
111 .parametersType = Params::ToAronType(),
112 };
113 }
114
115
116} // namespace armarx::view_selection::skills
The FramedPosition class.
Definition FramedPose.h:158
Represents a duration.
Definition Duration.h:17
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.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
@ TaskDriven
Task-Driven attention has highest priority.
This file is part of ArmarX.
Definition constants.cpp:26
A result struct for skill initialization.
Definition Skill.h:50