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 
27 #include <cmath>
28 #include <string>
29 
30 #include <IceUtil/Time.h>
31 
34 
37 
38 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
39 
40 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
41 
42 namespace armarx
43 {
44  /**
45  * @class HandUnitDynamicSimulationPropertyDefinitions
46  * @brief
47  * @ingroup SensorActorUnits
48  */
50  {
51  public:
54  {
55  defineOptionalProperty<std::string>(
56  "SimulatorProxyName", "Simulator", "Name of the simulator proxy to use.");
57  defineOptionalProperty<std::string>(
58  "RobotStateComponentName",
59  "RobotStateComponent",
60  "Name of the RobotStateComponent that should be used");
61  defineOptionalProperty<bool>(
62  "UseLegacyWorkingMemory",
63  false,
64  "Require the legacy MemoryX working memory to be available before starting.");
65  defineRequiredProperty<std::string>("KinematicUnitName",
66  "Name of the kinematic unit that should be used");
67  }
68  };
69 
70  /**
71  * @class HandUnitDynamicSimulation
72  * @brief This unit connects to the physics simulator topic (default: "Simulator") and implements a HandUnit.
73  *
74  * @ingroup SensorActorUnits
75  * @ingroup ArmarXSimulatorComponents
76  */
77  class HandUnitDynamicSimulation : virtual public HandUnit
78  //, virtual public HandUnitDynamicSimulationInterface
79  {
80  public:
81  // inherited from Component
82  std::string
83  getDefaultName() const override
84  {
85  return "HandUnitDynamicSimulation";
86  }
87 
88  void onInitHandUnit() override;
89  void onStartHandUnit() override;
90  void onExitHandUnit() override;
91 
92  /**
93  * Send command to the hand to open all fingers.
94  */
95  //virtual void open(const Ice::Current&);
96 
97 
98  /**
99  * @see PropertyUser::createPropertyDefinitions()
100  */
102 
103  void setObjectGrasped(const std::string& objectName, const Ice::Current&) override;
104  void setObjectReleased(const std::string& objectName, const Ice::Current&) override;
105 
106  NameValueMap getCurrentJointValues(const Ice::Current& c = Ice::emptyCurrent) override;
107 
108  protected:
109  std::string simulatorPrxName;
110 
111  SimulatorInterfacePrx simulatorPrx;
112 
113  KinematicUnitInterfacePrx kinematicUnitPrx;
114 
115  memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
116 
119 
120  std::string objectPoseStorageName = "ObjectMemory";
121 
123  std::string getRobotNameFromHandUnitName();
124  std::string getHandSideFromHandUnitName();
125 
126  // HandUnitInterface interface
127  public:
128  void setShape(const std::string& shapeName, const Ice::Current&) override;
129  void setShapeWithObjectInstance(const std::string& shapeName,
130  const std::string& objectInstanceName,
131  const Ice::Current& c = Ice::emptyCurrent) override;
132  void setJointAngles(const NameValueMap& jointAngles, const Ice::Current&) override;
133  };
134 } // namespace armarx
armarx::HandUnit
Base unit for high-level access to robot hands.
Definition: HandUnit.h:70
armarx::HandUnitDynamicSimulation::setShape
void setShape(const std::string &shapeName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:178
armarx::HandUnitDynamicSimulation::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: HandUnitDynamicSimulation.h:83
armarx::HandUnitDynamicSimulation::robotStateComponentName
std::string robotStateComponentName
Definition: HandUnitDynamicSimulation.h:117
armarx::HandUnitDynamicSimulation::workingMemoryPrx
memoryx::WorkingMemoryInterfacePrx workingMemoryPrx
Definition: HandUnitDynamicSimulation.h:115
armarx::HandUnitDynamicSimulationPropertyDefinitions
Definition: HandUnitDynamicSimulation.h:49
armarx::HandUnitDynamicSimulation::kinematicUnitPrx
KinematicUnitInterfacePrx kinematicUnitPrx
Definition: HandUnitDynamicSimulation.h:113
Pose.h
armarx::HandUnitDynamicSimulationPropertyDefinitions::HandUnitDynamicSimulationPropertyDefinitions
HandUnitDynamicSimulationPropertyDefinitions(std::string prefix)
Definition: HandUnitDynamicSimulation.h:52
armarx::HandUnitDynamicSimulation::handUnitJointsToRobotJoints
armarx::NameValueMap handUnitJointsToRobotJoints(const armarx::NameValueMap &joints)
Definition: HandUnitDynamicSimulation.cpp:398
armarx::HandUnitDynamicSimulation::setObjectReleased
void setObjectReleased(const std::string &objectName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:141
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::HandUnitDynamicSimulation::onInitHandUnit
void onInitHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:52
PeriodicTask.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::HandUnitDynamicSimulation::setJointAngles
void setJointAngles(const NameValueMap &jointAngles, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:381
armarx::HandUnitDynamicSimulation
This unit connects to the physics simulator topic (default: "Simulator") and implements a HandUnit.
Definition: HandUnitDynamicSimulation.h:77
armarx::HandUnitDynamicSimulation::objectPoseStorageName
std::string objectPoseStorageName
Definition: HandUnitDynamicSimulation.h:120
armarx::HandUnitDynamicSimulation::getCurrentJointValues
NameValueMap getCurrentJointValues(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnitDynamicSimulation.cpp:158
HandUnit.h
armarx::HandUnitDynamicSimulation::simulatorPrxName
std::string simulatorPrxName
Definition: HandUnitDynamicSimulation.h:109
armarx::HandUnitDynamicSimulation::getHandSideFromHandUnitName
std::string getHandSideFromHandUnitName()
Definition: HandUnitDynamicSimulation.cpp:438
armarx::HandUnitPropertyDefinitions
Defines all necessary properties for armarx::HandUnit.
Definition: HandUnit.h:42
armarx::HandUnitDynamicSimulation::setObjectGrasped
void setObjectGrasped(const std::string &objectName, const Ice::Current &) override
Definition: HandUnitDynamicSimulation.cpp:122
armarx::HandUnitDynamicSimulation::setShapeWithObjectInstance
void setShapeWithObjectInstance(const std::string &shapeName, const std::string &objectInstanceName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnitDynamicSimulation.cpp:231
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
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:109
armarx::HandUnitDynamicSimulation::simulatorPrx
SimulatorInterfacePrx simulatorPrx
Definition: HandUnitDynamicSimulation.h:111
IceUtil::Handle
Definition: forward_declarations.h:30
armarx::HandUnitDynamicSimulation::robotStateComponentPrx
RobotStateComponentInterfacePrx robotStateComponentPrx
Definition: HandUnitDynamicSimulation.h:118
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::HandUnitDynamicSimulation::onExitHandUnit
void onExitHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:85
armarx::HandUnitDynamicSimulation::onStartHandUnit
void onStartHandUnit() override
Definition: HandUnitDynamicSimulation.cpp:71
armarx::HandUnitDynamicSimulation::getRobotNameFromHandUnitName
std::string getRobotNameFromHandUnitName()
Definition: HandUnitDynamicSimulation.cpp:432
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ImportExportComponent.h