RobotHandLocalizationDynamicSimulation.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2013-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::Component
19  * @author Kai Welke (welke at kit dot edu)
20  * @date 2013
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
28 
29 // MemoryX
30 #include <MemoryX/interface/workingmemory/WorkingMemoryUpdaterBase.h>
31 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
35 
36 // Simulator
37 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
38 
40 
41 namespace armarx
42 {
45  {
46  public:
49  {
50  defineOptionalProperty<std::string>("TCPNameLeft", "TCP L", "Name of the TCP of the left robot hand.");
51  defineOptionalProperty<std::string>("TCPNameRight", "TCP R", "Name of the TCP of the right robot hand.");
52  defineOptionalProperty<std::string>("SimulatorName", "Simulator", "Name of the simulator component that should be used");
53  defineOptionalProperty<std::string>("ReferenceFrameName", "EyeLeftCamera", "Sets the reference frame name of the pose provided by this recognizer. Must be a frame name known in Pose from the robot model.");
54  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the RobotStateComponent that should be used");
55 
56  }
57  };
58 
59 
60  /**
61  * RobotHandLocalizationDynamicSimulation queries the armarx simulator for the current poses of the hand/TCP coordinate systems of the robot.
62  * The hand localization is invoked automatically by the working memory if the object has been requested there.
63  */
65  virtual public ::armarx::Component,
66  virtual public ::memoryx::ObjectLocalizerInterface
67  {
68  public:
69 
71 
72  /**
73  * @see PropertyUser::createPropertyDefinitions()
74  */
76  {
78  }
79 
80  void onInitComponent() override;
81  void onConnectComponent() override;
82  void onDisconnectComponent() override;
83  void onExitComponent() override {}
84 
85  /**
86  * @see Component::getDefaultName()
87  *
88  * Use "HandMarkerLocalization" here in order to mimic the execution on the real robot.
89  */
90  std::string getDefaultName() const override
91  {
92  return "HandMarkerLocalization";
93  }
94 
95  protected:
96 
97 
98  /**
99  * Add a memory entity representing the hand marker in order to set its properties
100  *
101  * @param objectClassEntity entity containing all information available for the object class
102  * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
103  *
104  * @return success of adding this entity
105  */
106  virtual bool addObjectClass(const memoryx::EntityPtr& objectClassEntity, const memoryx::GridFileManagerPtr& fileManager);
107 
108  /**
109  * localize one or both hand markers
110  *
111  * @param objectClassNames
112  *
113  * @return list of object instances
114  */
115  memoryx::ObjectLocalizationResultList localizeObjectClasses(const ::memoryx::ObjectClassNameList&, const ::Ice::Current& = Ice::emptyCurrent) override;
116 
117 
118  private:
119 
120  ::memoryx::MultivariateNormalDistributionPtr computePositionNoise(const Eigen::Vector3f& pos);
121 
122 
123  // remote robot for pose calculation
124  std::shared_ptr<RemoteRobot> remoteRobot;
125  std::string tcpNameLeft, tcpNameRight;
126 
127  SimulatorInterfacePrx simulatorProxy;
128 
129  // reference frame name (e.g. a camera frame)
130  std::string referenceFrame;
131 
132  };
133 }
134 
armarx::RobotHandLocalizationDynamicSimulation::RobotHandLocalizationDynamicSimulation
RobotHandLocalizationDynamicSimulation()
RemoteRobot.h
armarx::RobotHandLocalizationDynamicSimulation::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: RobotHandLocalizationDynamicSimulation.cpp:92
armarx::RobotHandLocalizationDynamicSimulation
RobotHandLocalizationDynamicSimulation queries the armarx simulator for the current poses of the hand...
Definition: RobotHandLocalizationDynamicSimulation.h:64
armarx::RobotHandLocalizationDynamicSimulation::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: RobotHandLocalizationDynamicSimulation.h:75
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
GridFileManager.h
armarx::RobotHandLocalizationDynamicSimulation::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: RobotHandLocalizationDynamicSimulation.cpp:45
armarx::RobotHandLocalizationDynamicSimulation::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: RobotHandLocalizationDynamicSimulation.h:83
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::RobotHandLocalizationDynamicSimulationPropertyDefinitions::RobotHandLocalizationDynamicSimulationPropertyDefinitions
RobotHandLocalizationDynamicSimulationPropertyDefinitions(std::string prefix)
Definition: RobotHandLocalizationDynamicSimulation.h:47
armarx::RobotHandLocalizationDynamicSimulation::addObjectClass
virtual bool addObjectClass(const memoryx::EntityPtr &objectClassEntity, const memoryx::GridFileManagerPtr &fileManager)
Add a memory entity representing the hand marker in order to set its properties.
Definition: RobotHandLocalizationDynamicSimulation.cpp:109
armarx::RobotHandLocalizationDynamicSimulation::localizeObjectClasses
memoryx::ObjectLocalizationResultList localizeObjectClasses(const ::memoryx::ObjectClassNameList &, const ::Ice::Current &=Ice::emptyCurrent) override
localize one or both hand markers
Definition: RobotHandLocalizationDynamicSimulation.cpp:117
armarx::RobotHandLocalizationDynamicSimulation::getDefaultName
std::string getDefaultName() const override
Definition: RobotHandLocalizationDynamicSimulation.h:90
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::RobotHandLocalizationDynamicSimulation::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: RobotHandLocalizationDynamicSimulation.cpp:61
ProbabilityMeasures.h
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:32
Entity.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::RobotHandLocalizationDynamicSimulationPropertyDefinitions
Definition: RobotHandLocalizationDynamicSimulation.h:43
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28