LookDirection.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5#include <string>
6
10
13#include <armarx/view_selection/skills/aron/LookDirection.aron.generated.h>
14
16{
17 namespace direction
18 {
19 const Eigen::Vector3f centerPosition{0., 1500., 1500.};
20 const Eigen::Vector3f downstraightPosition{0., 1500., 500.};
21 const Eigen::Vector3f DeltaUp{0., 0., 1000.};
22 const Eigen::Vector3f deltaDown{0., 0., -1000.};
23 const Eigen::Vector3f deltaLeft{-1000., 0., 0.};
24 const Eigen::Vector3f deltaRight{1000., 0., 0.};
25
26 /**
27 * The namespace state contains the states of allowed directions.
28 * There are 9 states in total:
29 * Left+Up Center+Up Right + Up
30 * Left+Center Center Right+Center
31 * Left+Down Center+Down Right+Down
32 */
33 namespace state
34 {
35 using Type = std::uint8_t;
36 constexpr std::uint8_t Center = 0;
37 constexpr std::uint8_t Up = 0b1;
38 constexpr std::uint8_t Down = 0b10;
39 constexpr std::uint8_t Left = 0b1000;
40 constexpr std::uint8_t Right = 0b10000;
41 constexpr std::uint8_t Downstraight = 0b100000;
42
44
45 state::Type from(Eigen::Vector3f targetPosition);
46
48
50 state::Type up(state::Type previous);
54
56
57 } // namespace state
58
59 } // namespace direction
60
61 /*
62 * The LookDirection class implements all functions except DefaultSkillDescription().
63 *
64 * For each implemented direction there is a specialized subclass below.
65 */
66
68 virtual public armarx::skills::SimpleSpecializedSkill<arondto::LookDirectionParams>
69 {
70 public:
71 using Params = arondto::LookDirectionParams;
73
74 struct Context
75 {
77 // RobotReader from RobotAPI? Would be another option to get current state.
78 };
79
80 LookDirection(const Context& services,
82 armarx::skills::SkillDescription skillDescription);
83
84 void connect(const Context& srv);
85
86 private:
87 using Base::init;
88 using Base::main;
89
90 private:
91 ::armarx::skills::Skill::InitResult init(const Base::SpecializedInitInput& in) override;
92 ::armarx::skills::Skill::MainResult main(const Base::SpecializedMainInput& in) override;
93
94 void onStopRequested() override;
95
96 protected:
98 generateDefaultSkillDescription(std::string name, std::string directionText);
99
100 private:
101 std::optional<Context> srv_;
103
104 // will be initialized in "init()"
105 std::optional<gaze_targets::GazeTarget> gazeTarget;
106 };
107
108 /*
109 * Specialized classes for each direction
110 */
111
112 class LookUp : public LookDirection
113 {
114 public:
115 LookUp(const Context& services);
116
118 };
119
120 class LookDown : public LookDirection
121 {
122 public:
123 LookDown(const Context& services);
124
126 };
127
128 /**
129 * This direction forces to look down in the middle
130 */
132 {
133 public:
134 LookDownstraight(const Context& services);
135
137 };
138
139 class LookLeft : public LookDirection
140 {
141 public:
142 LookLeft(const Context& services);
143
145 };
146
148 {
149 public:
150 LookRight(const Context& services);
151
153 };
154
156 {
157 public:
158 LookAhead(const Context& services);
159
161 };
162} // namespace armarx::view_selection::skills
virtual Skill::MainResult main(const SpecializedMainInput &)
virtual Skill::InitResult init(const SpecializedInitInput &)
static armarx::skills::SkillDescription DefaultSkillDescription()
::armarx::skills::SimpleSpecializedSkill< Params > Base
static armarx::skills::SkillDescription generateDefaultSkillDescription(std::string name, std::string directionText)
LookDirection(const Context &services, direction::state::StateModFn *stateModFn, armarx::skills::SkillDescription skillDescription)
static armarx::skills::SkillDescription DefaultSkillDescription()
static armarx::skills::SkillDescription DefaultSkillDescription()
static armarx::skills::SkillDescription DefaultSkillDescription()
static armarx::skills::SkillDescription DefaultSkillDescription()
static armarx::skills::SkillDescription DefaultSkillDescription()
The namespace state contains the states of allowed directions.
state::Type downstraight(state::Type previous)
Eigen::Vector3f generateTargetPosition(state::Type state)
state::Type from(Eigen::Vector3f targetPosition)
This file is part of ArmarX.
Definition constants.cpp:26
A result struct for skill initialization.
Definition Skill.h:50
A result struct for th main method of a skill.
Definition Skill.h:62