RetrieveHand.cpp
Go to the documentation of this file.
1 #include "RetrieveHand.h"
2 
4 
6 
7 #include <armarx/control/deprecated_njoint_mp_controller/task_space/ControllerInterface.h>
9 
11 {
12 
15  {
16  ParamType defaults;
17  defaults.targetPose.header.agent = "Armar7";
18  defaults.targetPose.header.frame = "root";
19  defaults.targetPose.position = Eigen::Matrix<float, 3, 1>{-234.0f, 284.06f, 1103.0f};
20  defaults.targetPose.orientation =
21  Eigen::Quaternion<float>{0.7640368, -0.63349, 0.06744281, -0.10187};
22 
23  armarx::arondto::PackagePath& packagePath = defaults.fileNames.emplace_back();
24  packagePath.package = "armar7_motions";
25  packagePath.path = "tcp_trajectories/dmp/default_left.csv";
26 
27  // ARMARX_INFO << VAROUT(defaultParams.targetPose);
28  // ARMARX_INFO << VAROUT(defaultParams.targetPose.position) << VAROUT(defaultParams.targetPose.orientation);
29  // ARMARX_INFO << VAROUT(defaultParams.targetPose.header.frame) << VAROUT(defaultParams.targetPose.header.agent);
30 
31  // defaultParams.exampleStringParam = "exampleDefaultValue";
32 
33  auto skillId = armarx::skills::SkillID{
35 
36  return ::armarx::skills::SkillDescription{.skillId = skillId,
37  .description =
38  "TODO: Description of skill RetrieveHand.",
39  .rootProfileDefaults = defaults.toAron(),
40  .timeout = ::armarx::Duration::MilliSeconds(1000),
41  .parametersType = ParamType::ToAronType()};
42  }
43 
44  RetrieveHand::RetrieveHand(const Remote& r) : Base(GetSkillDescription()), remote(r)
45 
46  {
47  }
48 
49  RetrieveHand::RetrieveHand() : Base(GetSkillDescription())
50  {
51  }
52 
53  /*
54  ::armarx::skills::Skill::InitResult
55  RetrieveHand::init(const SpecializedInitInput&)
56  {
57  return InitResult{.status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
58  }
59  */
60 
61 
63  RetrieveHand::main(const SpecializedMainInput& in)
64  {
65  // Enter main code of the skill here.
67  .robotUnit = remote.robotUnit};
68 
69  armarx::FramedPose targetPose{in.parameters.targetPose.position,
70  in.parameters.targetPose.orientation,
71  in.parameters.targetPose.header.frame,
72  in.parameters.targetPose.header.agent};
73 
74  std::vector<std::string> fileNames;
75  for (const auto& aronPackagePath : in.parameters.fileNames)
76  {
77  armarx::PackagePath packagePath = fromAron<armarx::PackagePath>(aronPackagePath);
78  fileNames.push_back(packagePath.toSystemPath().string());
79  }
80 
82  .robotName = in.parameters.robotName,
83  .robotNodeSet = in.parameters.robotNodeSet,
84  .timeDurationInSec = in.parameters.timeDurationInSec,
85  .targetPose = targetPose,
86  .kpLinear = in.parameters.kpLinear,
87  .kpAngular = in.parameters.kpAngular,
88  .kdLinear = in.parameters.kdLinear,
89  .kdAngular = in.parameters.kdAngular,
90  .fileNames = fileNames,
91  };
92 
93 
94  impl = std::make_unique<core::RetrieveHand>(rem, props);
95 
96  auto res = impl->execute();
97  if (res)
98  {
99  return MakeSucceededResult();
100  }
101  return MakeFailedResult();
102  }
103 
104 
105  void
107  {
108  ARMARX_INFO << "requesting to stop TSVMP controller ";
109  if (impl)
110  {
111  impl->stop();
112  }
113  }
114 
115  /*
116  ::armarx::skills::Skill::ExitResult
117  RetrieveHand::exit(const SpecializedExitInput&)
118  {
119  return ExitResult{.status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
120  }
121  */
122 
123 } // namespace armarx::control::retrieve_hand::skills
armarx::control::retrieve_hand::skills
Definition: RetrieveHand.cpp:10
armarx::control::retrieve_hand::constants::SKILL_NAME
constexpr auto SKILL_NAME
Definition: constants.h:6
armarx::control::retrieve_hand::skills::RetrieveHand::Remote::robotUnit
armarx::RobotUnitInterfacePrx robotUnit
Definition: RetrieveHand.h:28
RetrieveHand.h
armarx::skills::SimpleSpecializedSkill< RetrieveHandParams >::ParamType
RetrieveHandParams ParamType
Definition: SimpleSpecializedSkill.h:14
armarx::FramedPose
The FramedPose class.
Definition: FramedPose.h:258
armarx::skills::SkillID::skillName
std::string skillName
Definition: SkillID.h:60
armarx::skills::SkillDescription
Definition: SkillDescription.h:18
armarx::control::retrieve_hand::core::RetrieveHand::Remote
Definition: RetrieveHand.h:48
constants.h
armarx::control::retrieve_hand::skills::RetrieveHand::GetSkillDescription
::armarx::skills::SkillDescription GetSkillDescription()
Definition: RetrieveHand.cpp:14
armarx::control::retrieve_hand::skills::RetrieveHand::Remote::memoryNameSystem
armarx::armem::client::MemoryNameSystem memoryNameSystem
Definition: RetrieveHand.h:26
armarx::skills::Skill::MakeFailedResult
static MainResult MakeFailedResult()
Definition: Skill.cpp:324
armarx::control::retrieve_hand::skills::RetrieveHand::Remote
Definition: RetrieveHand.h:23
armarx::PackagePath::toSystemPath
static std::filesystem::path toSystemPath(const data::PackagePath &pp)
Definition: PackagePath.cpp:54
armarx::skills::SimpleSpecializedSkill< RetrieveHandParams >
armarx::control::retrieve_hand::skills::RetrieveHand::RetrieveHand
RetrieveHand()
Definition: RetrieveHand.cpp:49
packagepath.cpp
armarx::control::retrieve_hand::core::RetrieveHand::Remote::memoryNameSystem
armarx::armem::client::MemoryNameSystem memoryNameSystem
Definition: RetrieveHand.h:51
armarx::control::retrieve_hand::core::RetrieveHand::Properties
Definition: RetrieveHand.h:56
armarx::skills::Skill::MakeSucceededResult
static MainResult MakeSucceededResult(aron::data::DictPtr data=nullptr)
Definition: Skill.cpp:315
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition: Skill.h:48
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::skills::SimpleSpecializedSkill< RetrieveHandParams >::main
Skill::MainResult main() final
Definition: SimpleSpecializedSkill.h:71
armarx::control::retrieve_hand::core::RetrieveHand::Properties::robotName
std::string robotName
Definition: RetrieveHand.h:58
Eigen::Matrix< float, 3, 1 >
armarx::control::retrieve_hand::skills::RetrieveHand::onStopRequested
void onStopRequested() override
Definition: RetrieveHand.cpp:106
Logging.h
armarx::PackagePath
Definition: PackagePath.h:55
armarx::skills::SkillID
Definition: SkillID.h:17
armarx::core::time::Duration::MilliSeconds
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition: Duration.cpp:55