MovePlatformForGrasp.cpp
Go to the documentation of this file.
1 #include "MovePlatformForGrasp.h"
2 
4 #include <RobotAPI/libraries/skills/provider/SkillProxy.h>
5 
7 
8 #include "util/GraspObjectUtil.h"
9 
10 namespace armarx::skills
11 {
12  namespace
13  {
14  grasp_object::arondto::MovePlatformForGraspAcceptedType
15  GetDefaultParameterization()
16  {
17  grasp_object::arondto::MovePlatformForGraspAcceptedType ret;
18  ret.orientationalAccuracy = 0.01;
19  ret.positionalAccuracy = 25;
20  return ret;
21  }
22  } // namespace
23 
24  SkillDescription MovePlatformForGraspSkill::Description = skills::SkillDescription{
25  "MovePlatformForGrasp",
26  "Move Platform in order to ease the grasp of an object",
27  {},
29  grasp_object::arondto::MovePlatformForGraspAcceptedType::ToAronType(),
30  GetDefaultParameterization().toAron()};
31 
33  armarx::viz::Client& arviz,
35  TwoArmGraspControlSkill(mns, arviz, Description.skillName, context),
36  SimpleSpecializedSkill<ArgType>(Description)
37  {
38  }
39 
41  MovePlatformForGraspSkill::main(const SpecializedMainInput& in)
42  {
44  armem::obj::instance::Reader objectReader(mns);
45 
46  robotReader.connect();
47  objectReader.connect();
48 
49  // //////////////////////////////
50  // get robot
51  // //////////////////////////////
52  auto robot =
53  robotReader.getSynchronizedRobot(in.parameters.robotName,
55  VirtualRobot::RobotIO::RobotDescription::eStructure);
56  if (!robot)
57  {
58  ARMARX_ERROR << "Lost robot.";
59  return {TerminatedSkillStatus::Failed, nullptr};
60  }
61 
62  // //////////////////////////////
63  // get object pose
64  // //////////////////////////////
65  auto objInstance = objectReader.queryLatestObjectInstance(in.parameters.objectEntityId);
66  if (!objInstance)
67  {
68  ARMARX_ERROR << "Lost object pose.";
69  return {TerminatedSkillStatus::Failed, nullptr};
70  }
71 
72  // //////////////////////////////
73  // Exec move skill
74  // //////////////////////////////
76  {*objInstance, *robot, in.parameters.tcpName});
77 
78  skills::platform_control::arondto::MovePlatformToPoseAcceptedType params;
79  params.robotName = in.parameters.robotName;
80  params.orientationalAccuracy = in.parameters.orientationalAccuracy;
81  params.positionalAccuracy = in.parameters.positionalAccuracy;
82  params.pose = targetPose.platformGlobalPose;
83 
84  SkillProxy prx({manager,
87  return {
88  prx.executeFullSkill(getSkillId().toString(in.executorName), params.toAron()).status,
89  nullptr};
90  }
91 } // namespace armarx::skills
armarx::skills::mixin::MNSSkillMixin::mns
armem::client::MemoryNameSystem mns
Definition: MNSSkillMixin.h:11
MovePlatformForGrasp.h
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::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
armarx::skills::grasp_control::util::GetGlobalPlatformPoseForObjectGrasp
GetPlatformOffsetForObjectGraspOutput GetGlobalPlatformPoseForObjectGrasp(const GetPlatformOffsetForObjectGraspInput &in)
Definition: GraspObjectUtil.cpp:85
armarx::skills::MovePlatformForGraspSkill::MovePlatformForGraspSkill
MovePlatformForGraspSkill(armem::client::MemoryNameSystem &mns, armarx::viz::Client &arviz, TwoArmGraspControlSkillContext &)
Definition: MovePlatformForGrasp.cpp:32
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::TwoArmGraspControlSkill::context
TwoArmGraspControlSkillContext & context
Definition: GraspControlSkill.h:84
armarx::skills::MovePlatformToPose::Description
static SkillDescription Description
Definition: MovePlatformToPose.h:66
GraspObjectUtil.h
armarx::armem::obj::instance::Reader
Definition: ObjectReader.h:40
MovePlatformToPose.h
armarx::skills::TwoArmGraspControlSkillContext::platformControlSkillProvider
std::string platformControlSkillProvider
Definition: GraspControlSkill.h:51
FramedPose.h
armarx::skills::MovePlatformForGraspSkill::Description
static SkillDescription Description
Definition: MovePlatformForGrasp.h:27
armarx::skills::SimpleSpecializedSkill
Definition: SimpleSpecializedSkill.h:10
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition: Skill.h:48
armarx::skills::grasp_control::util::GetPlatformOffsetForObjectGraspOutput::platformGlobalPose
Eigen::Matrix4f platformGlobalPose
Definition: GraspObjectUtil.h:52
armarx::skills::MovePlatformForGraspSkill::ArgType
grasp_object::arondto::MovePlatformForGraspAcceptedType ArgType
Definition: MovePlatformForGrasp.h:19
armarx::skills::TerminatedSkillStatus::Failed
@ Failed
armarx::skills::SimpleSpecializedSkill< grasp_object::arondto::MovePlatformForGraspAcceptedType >::main
Skill::MainResult main() final
Definition: SimpleSpecializedSkill.h:71
armarx::skills::TwoArmGraspControlSkill
Definition: GraspControlSkill.h:77
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:27
armarx::skills::TwoArmGraspControlSkillContext
Definition: GraspControlSkill.h:46
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
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