HandUnitDynamicSimulation.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 ArmarXSimulation::units
19  * @author Nikolaus Vahrenkamp (vahrenkamp at kit dot edu)
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
28 
32 
33 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
34 
35 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
36 
37 #include <IceUtil/Time.h>
38 
39 #include <string>
40 #include <cmath>
41 
42 namespace armarx
43 {
44  /**
45  * @class HandUnitDynamicSimulationPropertyDefinitions
46  * @brief
47  * @ingroup SensorActorUnits
48  */
51  {
52  public:
55  {
56  defineOptionalProperty<std::string>("SimulatorProxyName", "Simulator", "Name of the simulator proxy to use.");
57  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the RobotStateComponent that should be used");
58  defineOptionalProperty<bool>("UseLegacyWorkingMemory", false,
59  "Require the legacy MemoryX working memory to be available before starting.");
60  defineRequiredProperty<std::string>("KinematicUnitName", "Name of the kinematic unit that should be used");
61  }
62  };
63 
64  /**
65  * @class HandUnitDynamicSimulation
66  * @brief This unit connects to the physics simulator topic (default: "Simulator") and implements a HandUnit.
67  *
68  * @ingroup SensorActorUnits
69  * @ingroup ArmarXSimulatorComponents
70  */
72  virtual public HandUnit
73  //, virtual public HandUnitDynamicSimulationInterface
74  {
75  public:
76  // inherited from Component
77  std::string getDefaultName() const override
78  {
79  return "HandUnitDynamicSimulation";
80  }
81 
82  void onInitHandUnit() override;
83  void onStartHandUnit() override;
84  void onExitHandUnit() override;
85 
86  /**
87  * Send command to the hand to open all fingers.
88  */
89  //virtual void open(const Ice::Current&);
90 
91 
92  /**
93  * @see PropertyUser::createPropertyDefinitions()
94  */
96 
97  void setObjectGrasped(const std::string& objectName, const Ice::Current&) override;
98  void setObjectReleased(const std::string& objectName, const Ice::Current&) override;
99 
100  NameValueMap getCurrentJointValues(const Ice::Current& c = Ice::emptyCurrent) override;
101 
102  protected:
103 
104  std::string simulatorPrxName;
105 
106  SimulatorInterfacePrx simulatorPrx;
107 
108  KinematicUnitInterfacePrx kinematicUnitPrx;
109 
110  memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
111 
114 
115  std::string objectPoseStorageName = "ObjectMemory";
116 
118  std::string getRobotNameFromHandUnitName();
119  std::string getHandSideFromHandUnitName();
120 
121  // HandUnitInterface interface
122  public:
123  void setShape(const std::string& shapeName, const Ice::Current&) override;
124  void setShapeWithObjectInstance(const std::string& shapeName, const std::string& objectInstanceName, const Ice::Current& c = Ice::emptyCurrent) override;
125  void setJointAngles(const NameValueMap& jointAngles, const Ice::Current&) override;
126  };
127 }
128 
armarx::HandUnit
Base unit for high-level access to robot hands.
Definition: HandUnit.h:71
armarx::HandUnitDynamicSimulation::setShape
void setShape(const std::string &shapeName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:169
armarx::HandUnitDynamicSimulation::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: HandUnitDynamicSimulation.h:77
armarx::HandUnitDynamicSimulation::robotStateComponentName
std::string robotStateComponentName
Definition: HandUnitDynamicSimulation.h:112
armarx::HandUnitDynamicSimulation::workingMemoryPrx
memoryx::WorkingMemoryInterfacePrx workingMemoryPrx
Definition: HandUnitDynamicSimulation.h:110
armarx::HandUnitDynamicSimulationPropertyDefinitions
Definition: HandUnitDynamicSimulation.h:49
armarx::HandUnitDynamicSimulation::kinematicUnitPrx
KinematicUnitInterfacePrx kinematicUnitPrx
Definition: HandUnitDynamicSimulation.h:108
Pose.h
armarx::HandUnitDynamicSimulationPropertyDefinitions::HandUnitDynamicSimulationPropertyDefinitions
HandUnitDynamicSimulationPropertyDefinitions(std::string prefix)
Definition: HandUnitDynamicSimulation.h:53
armarx::HandUnitDynamicSimulation::handUnitJointsToRobotJoints
armarx::NameValueMap handUnitJointsToRobotJoints(const armarx::NameValueMap &joints)
Definition: HandUnitDynamicSimulation.cpp:369
armarx::HandUnitDynamicSimulation::setObjectReleased
void setObjectReleased(const std::string &objectName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:134
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::HandUnitDynamicSimulation::onInitHandUnit
void onInitHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:49
PeriodicTask.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::navigation::platform_controller::platform_global_trajectory::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformGlobalTrajectoryController.h:93
armarx::HandUnitDynamicSimulation::setJointAngles
void setJointAngles(const NameValueMap &jointAngles, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:355
armarx::HandUnitDynamicSimulation
This unit connects to the physics simulator topic (default: "Simulator") and implements a HandUnit.
Definition: HandUnitDynamicSimulation.h:71
armarx::HandUnitDynamicSimulation::objectPoseStorageName
std::string objectPoseStorageName
Definition: HandUnitDynamicSimulation.h:115
armarx::HandUnitDynamicSimulation::getCurrentJointValues
NameValueMap getCurrentJointValues(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnitDynamicSimulation.cpp:150
HandUnit.h
armarx::HandUnitDynamicSimulation::simulatorPrxName
std::string simulatorPrxName
Definition: HandUnitDynamicSimulation.h:104
armarx::HandUnitDynamicSimulation::getHandSideFromHandUnitName
std::string getHandSideFromHandUnitName()
Definition: HandUnitDynamicSimulation.cpp:406
armarx::HandUnitPropertyDefinitions
Defines all necessary properties for armarx::HandUnit.
Definition: HandUnit.h:44
armarx::HandUnitDynamicSimulation::setObjectGrasped
void setObjectGrasped(const std::string &objectName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:117
armarx::HandUnitDynamicSimulation::setShapeWithObjectInstance
void setShapeWithObjectInstance(const std::string &shapeName, const std::string &objectInstanceName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnitDynamicSimulation.cpp:220
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::HandUnitDynamicSimulation::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Send command to the hand to open all fingers.
Definition: HandUnitDynamicSimulation.cpp:105
armarx::HandUnitDynamicSimulation::simulatorPrx
SimulatorInterfacePrx simulatorPrx
Definition: HandUnitDynamicSimulation.h:106
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::HandUnitDynamicSimulation::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: HandUnitDynamicSimulation.h:113
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::HandUnitDynamicSimulation::onExitHandUnit
void onExitHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:80
armarx::HandUnitDynamicSimulation::onStartHandUnit
void onStartHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:67
armarx::HandUnitDynamicSimulation::getRobotNameFromHandUnitName
std::string getRobotNameFromHandUnitName()
Definition: HandUnitDynamicSimulation.cpp:401
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ImportExportComponent.h