WhatCanYouSeeNow.cpp
Go to the documentation of this file.
1 #include "WhatCanYouSeeNow.h"
2 
4 
6 
7 namespace armarx::skills
8 {
9 
10  SkillDescription WhatCanYouSeeNow::Description = skills::SkillDescription(
11  {"WhatCanYouSeeNow"},
12  "Move the head to three known configurations and search for objects",
13  nullptr,
15  visual_search::arondto::WhatCanYouSeeNowAcceptedType::ToAronType());
16 
18  armarx::viz::Client& arviz,
19  VisualSearchSkillContext& context) :
20  VisualSearchSkill(mns, arviz, Description.skillId.toString(), context),
21  SimpleSpecializedSkill<ArgType>(Description)
22  {
23  }
24 
26  WhatCanYouSeeNow::main(const SpecializedMainInput& in)
27  {
29  armem::obj::instance::Writer objectWriter;
30  armem::obj::instance::Reader objectReader;
31 
32  robotReader.connect(mns);
33  objectWriter.connect(mns);
34  objectReader.connect(mns);
35 
36  // //////////////////////////////
37  // get robot
38  // //////////////////////////////
39  auto robot =
40  robotReader.getSynchronizedRobot(in.parameters.robotName,
42  VirtualRobot::RobotIO::RobotDescription::eStructure);
43  if (!robot)
44  {
45  ARMARX_ERROR << "Lost robot.";
46  return {TerminatedSkillStatus::Failed, nullptr};
47  }
48 
49  // Look down
50  {
51  skills::joint_control::arondto::MoveJointsToPositionAcceptedType params;
52  params.robotName = in.parameters.robotName;
53  params.jointTargetTolerance = 0.03; // Todo
54  params.jointMaxSpeed = 0.75;
55  params.accelerationTime = 500;
56  params.setVelocitiesToZeroAtEnd = true;
57  params.targetJointMap["Neck_1_Pitch"] = 0.6;
58 
59  SkillProxy prx({manager,
62 
63  if (prx.executeFullSkill(getSkillId().toString(in.executorName), params.toAron())
65  {
66  return {TerminatedSkillStatus::Failed, nullptr};
67  }
68  }
69 
70  // //////////////////////////////
71  // get object pose
72  // //////////////////////////////
73  objectReader.requestLocalization(
74  in.parameters.objectEntityId, "", core::time::Duration::MilliSeconds(500));
75  std::this_thread::sleep_for(std::chrono::milliseconds(500));
76 
77  // Look up
78  {
79  skills::joint_control::arondto::MoveJointsToPositionAcceptedType params;
80  params.robotName = in.parameters.robotName;
81  params.jointTargetTolerance = 0.03; // Todo
82  params.jointMaxSpeed = 0.75;
83  params.accelerationTime = 500;
84  params.setVelocitiesToZeroAtEnd = true;
85  params.targetJointMap["Neck_1_Pitch"] = 0.0;
86 
87  SkillProxy prx({manager,
90 
91  if (prx.executeFullSkill(getSkillId().toString(in.executorName), params.toAron())
93  {
94  return {TerminatedSkillStatus::Failed, nullptr};
95  }
96  }
97 
98  return {TerminatedSkillStatus::Succeeded, nullptr};
99  }
100 } // namespace armarx::skills
armarx::skills::mixin::MNSSkillMixin::mns
armem::client::MemoryNameSystem mns
Definition: MNSSkillMixin.h:11
armarx::armem::obj::instance::Reader::requestLocalization
std::map< std::string, bool > requestLocalization(const ObjectID &instanceId, const armarx::core::time::Duration &until)
Definition: ObjectReader.cpp:57
armarx::armem::robot_state::VirtualRobotReader
The VirtualRobotReader class.
Definition: VirtualRobotReader.h:40
armarx::skills::Skill::manager
manager::dti::SkillManagerInterfacePrx manager
Definition: Skill.h:327
armarx::skills::TerminatedSkillStatus::Succeeded
@ Succeeded
armarx::skills
This file is part of ArmarX.
Definition: PeriodicUpdateWidget.cpp:11
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:55
armarx::skills::WhatCanYouSeeNow::Description
static SkillDescription Description
Definition: WhatCanYouSeeNow.h:46
armarx::skills::VisualSearchSkill
Definition: VisualSearchSkill.h:65
armarx::armem::robot_state::RobotReader::connect
virtual void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: RobotReader.cpp:48
armarx::armem::obj::instance::Reader
Definition: ObjectReader.h:40
armarx::skills::WhatCanYouSeeNow::ArgType
armarx::skills::visual_search::arondto::WhatCanYouSeeNowAcceptedType ArgType
Definition: WhatCanYouSeeNow.h:36
MoveJointsToPosition.h
armarx::skills::VisualSearchSkillContext
Definition: VisualSearchSkill.h:49
armarx::skills::WhatCanYouSeeNow::WhatCanYouSeeNow
WhatCanYouSeeNow(armem::client::MemoryNameSystem &mns, armarx::viz::Client &arviz, VisualSearchSkillContext &context)
Definition: WhatCanYouSeeNow.cpp:17
armarx::armem::obj::instance::Writer
Definition: ObjectWriter.h:36
armarx::skills::SimpleSpecializedSkill
Definition: SimpleSpecializedSkill.h:10
armarx::armem::obj::instance::Reader::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: ObjectReader.cpp:33
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::robot_state::VirtualRobotReader::getSynchronizedRobot
VirtualRobot::RobotPtr getSynchronizedRobot(const std::string &name, const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure, bool blocking=true)
armarx::skills::VisualSearchSkillContext::jointControlSkillProvider
std::string jointControlSkillProvider
Definition: VisualSearchSkill.h:52
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition: Skill.h:48
WhatCanYouSeeNow.h
armarx::armem::obj::instance::Writer::connect
void connect(armem::client::MemoryNameSystem &memoryNameSystem)
Definition: ObjectWriter.cpp:39
armarx::skills::TerminatedSkillStatus::Failed
@ Failed
armarx::skills::SimpleSpecializedSkill< visual_search::arondto::WhatCanYouSeeNowAcceptedType >::main
Skill::MainResult main() final
Definition: SimpleSpecializedSkill.h:71
VisualSearchUtil.h
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:27
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::skills::VisualSearchSkill::context
VisualSearchSkillContext & context
Definition: VisualSearchSkill.h:72
armarx::viz::Client
Definition: Client.h:109
armarx::skills::Skill::getSkillId
SkillID getSkillId() const
Get the id of the skill.
Definition: Skill.h:74
armarx::core::time::Duration::MilliSeconds
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition: Duration.cpp:55
armarx::skills::MoveJointsToPosition::Description
static SkillDescription Description
Definition: MoveJointsToPosition.h:48