HandUnit.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-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 ArmarXCore::units
19  * @author Manfred Kroehnert (manfred dot kroehnert 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 #include <RobotAPI/interface/units/HandUnitInterface.h>
30 
34 
35 #include <VirtualRobot/VirtualRobot.h>
36 
37 
38 namespace armarx
39 {
40  /**
41  * \class HandUnitPropertyDefinitions
42  * \brief Defines all necessary properties for armarx::HandUnit
43  */
46  {
47  public:
50  {
51  defineRequiredProperty<std::string>("RobotFileName", "VirtualRobot XML file in which the endeffector is is stored.");
52  defineRequiredProperty<std::string>("EndeffectorName", "Name of the endeffector as stored in the XML file (will publish values on EndeffectorName + 'State')");
53  }
54  };
55 
56 
57  /**
58  * @ingroup Component-HandUnit HandUnit
59  * \brief Base unit for high-level access to robot hands.
60  * \ingroup RobotAPI-SensorActorUnits
61  *
62  * An instance of a HandUnit provides means to open, close, and preshape hands.
63  * It uses the HandUnitListener Ice interface to report updates of its current state
64  *
65  */
66 
67  /**
68  * @brief The HandUnit class
69  * @ingroup Component-HandUnit
70  */
71  class HandUnit :
72  virtual public HandUnitInterface,
73  virtual public SensorActorUnit
74  {
75  public:
76  // inherited from Component
77  std::string getDefaultName() const override
78  {
79  return "HandUnit";
80  }
81 
82  /**
83  * Retrieve proxy for publishing State information and call
84  * armarx::PlatformUnit::onInitPlatformUnit().
85  * \see armarx::Component::onInitComponent()
86  */
87  void onInitComponent() override;
88  /**
89  * Calls armarx::PlatformUnit::onStartPlatformUnit().
90  * \see armarx::Component::onConnectComponent()
91  */
92  void onConnectComponent() override;
93  /**
94  * Calls armarx::PlatformUnit::onExitPlatformUnit().
95  * \see armarx::Component::onExitComponent()
96  */
97  void onExitComponent() override;
98 
99  /**
100  *
101  */
102  virtual void onInitHandUnit() = 0;
103  /**
104  *
105  */
106  virtual void onStartHandUnit() = 0;
107  /**
108  *
109  */
110  virtual void onExitHandUnit() = 0;
111 
112  /**
113  * Send command to the hand to form a specific shape position. The shapes are defined in the robot.xml file.
114  */
115  void setShape(const std::string& shapeName, const Ice::Current& c = Ice::emptyCurrent) override;
116 
117  /**
118  * @brief setShapeWithObjectInstance Send command to the hand to form a specific shape position.
119  * While trying to form the specified shape, collison checking with the named object instance is performed.
120  * The resulting joint angles of the hand might differ from the predefined joint angles for the given shape.
121  *
122  * @param shapeName Name of the well known shape that the hand should form
123  * @param graspedObjectInstanceName name of the object instance which is used to check for collisions while setting the shape
124  */
125  void setShapeWithObjectInstance(const std::string& shapeName, const std::string& objectInstanceName, const Ice::Current& c = Ice::emptyCurrent) override;
126 
127  /**
128  * \return a list of strings for shape positions which can be used together with HandUnit::shape().
129  */
130  SingleTypeVariantListBasePtr getShapeNames(const Ice::Current& c = Ice::emptyCurrent) override;
131 
132  NameValueMap getShapeJointValues(const std::string& shapeName, const Ice::Current& c = Ice::emptyCurrent) override;
133  NameValueMap getCurrentJointValues(const Ice::Current& c = Ice::emptyCurrent) override;
134 
135  void setObjectGrasped(const std::string& objectName, const Ice::Current&) override;
136  void setObjectReleased(const std::string& objectName, const Ice::Current&) override;
137  void setJointAngles(const NameValueMap& targetJointAngles, const Ice::Current&) override;
138 
139  std::string describeHandState(const Ice::Current&) override;
140 
141  /**
142  * \see armarx::PropertyUser::createPropertyDefinitions()
143  */
145 
146  protected:
147  /**
148  * HandUnitListener proxy for publishing state updates
149  */
150  HandUnitListenerPrx listenerPrx;
151  /**
152  * Ice Topic name on which armarx::HandUnit::listenerPrx publishes information
153  */
154  std::string listenerChannelName;
155  /**
156  * List containing the names of all valid shapes.
157  */
159 
160  std::string kinematicUnitName;
161 
163  VirtualRobot::EndEffectorPtr eef;
164 
165  std::string robotName;
166  std::string tcpName;
167 
168  std::map <std::string, float> handJoints;
169 
170  std::string graspedObject;
171 
172 
173  // HandUnitInterface interface
174  public:
175  std::string getHandName(const Ice::Current& = Ice::emptyCurrent) override;
176  void setJointForces(const NameValueMap& targetJointForces, const Ice::Current&) override;
177  void sendJointCommands(const NameCommandMap& targetJointCommands, const Ice::Current&) override;
178  };
179 }
180 
armarx::HandUnit
Base unit for high-level access to robot hands.
Definition: HandUnit.h:71
armarx::HandUnit::onConnectComponent
void onConnectComponent() override
Calls armarx::PlatformUnit::onStartPlatformUnit().
Definition: HandUnit.cpp:124
SingleTypeVariantList.h
armarx::HandUnit::shapeNames
SingleTypeVariantListPtr shapeNames
List containing the names of all valid shapes.
Definition: HandUnit.h:158
armarx::HandUnit::describeHandState
std::string describeHandState(const Ice::Current &) override
Definition: HandUnit.cpp:217
armarx::HandUnit::robot
VirtualRobot::RobotPtr robot
Definition: HandUnit.h:162
Properties.h
armarx::HandUnit::setObjectReleased
void setObjectReleased(const std::string &objectName, const Ice::Current &) override
Definition: HandUnit.cpp:188
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::HandUnit::graspedObject
std::string graspedObject
Definition: HandUnit.h:170
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::HandUnit::listenerChannelName
std::string listenerChannelName
Ice Topic name on which armarx::HandUnit::listenerPrx publishes information.
Definition: HandUnit.h:154
armarx::HandUnit::getHandName
std::string getHandName(const Ice::Current &=Ice::emptyCurrent) override
Definition: HandUnit.cpp:196
armarx::HandUnit::listenerPrx
HandUnitListenerPrx listenerPrx
HandUnitListener proxy for publishing state updates.
Definition: HandUnit.h:150
armarx::HandUnit::setObjectGrasped
void setObjectGrasped(const std::string &objectName, const Ice::Current &) override
Definition: HandUnit.cpp:182
IceInternal::Handle< SingleTypeVariantList >
armarx::HandUnit::onInitComponent
void onInitComponent() override
Retrieve proxy for publishing State information and call armarx::PlatformUnit::onInitPlatformUnit().
Definition: HandUnit.cpp:40
armarx::HandUnit::eef
VirtualRobot::EndEffectorPtr eef
Definition: HandUnit.h:163
armarx::HandUnit::setJointForces
void setJointForces(const NameValueMap &targetJointForces, const Ice::Current &) override
Definition: HandUnit.cpp:201
armarx::HandUnit::getShapeNames
SingleTypeVariantListBasePtr getShapeNames(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnit.cpp:150
armarx::HandUnit::getCurrentJointValues
NameValueMap getCurrentJointValues(const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnit.cpp:170
armarx::HandUnit::onExitHandUnit
virtual void onExitHandUnit()=0
armarx::HandUnit::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: HandUnit.cpp:156
armarx::HandUnit::setShape
void setShape(const std::string &shapeName, const Ice::Current &c=Ice::emptyCurrent) override
Send command to the hand to form a specific shape position.
Definition: HandUnit.cpp:140
SensorActorUnit.h
armarx::HandUnit::setShapeWithObjectInstance
void setShapeWithObjectInstance(const std::string &shapeName, const std::string &objectInstanceName, const Ice::Current &c=Ice::emptyCurrent) override
setShapeWithObjectInstance Send command to the hand to form a specific shape position.
Definition: HandUnit.cpp:144
armarx::HandUnit::getShapeJointValues
NameValueMap getShapeJointValues(const std::string &shapeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: HandUnit.cpp:163
armarx::HandUnitPropertyDefinitions
Defines all necessary properties for armarx::HandUnit.
Definition: HandUnit.h:44
armarx::HandUnit::robotName
std::string robotName
Definition: HandUnit.h:165
armarx::HandUnitPropertyDefinitions::HandUnitPropertyDefinitions
HandUnitPropertyDefinitions(std::string prefix)
Definition: HandUnit.h:48
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::HandUnit::onExitComponent
void onExitComponent() override
Calls armarx::PlatformUnit::onExitPlatformUnit().
Definition: HandUnit.cpp:133
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::HandUnit::onStartHandUnit
virtual void onStartHandUnit()=0
armarx::HandUnit::tcpName
std::string tcpName
Definition: HandUnit.h:166
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::SensorActorUnit
Base Class for SensorActorUnits.
Definition: SensorActorUnit.h:42
armarx::HandUnit::sendJointCommands
void sendJointCommands(const NameCommandMap &targetJointCommands, const Ice::Current &) override
Definition: HandUnit.cpp:206
armarx::HandUnit::handJoints
std::map< std::string, float > handJoints
Definition: HandUnit.h:168
armarx::HandUnit::onInitHandUnit
virtual void onInitHandUnit()=0
armarx::HandUnit::kinematicUnitName
std::string kinematicUnitName
Definition: HandUnit.h:160
armarx::HandUnit::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: HandUnit.h:77
armarx::HandUnit::setJointAngles
void setJointAngles(const NameValueMap &targetJointAngles, const Ice::Current &) override
Definition: HandUnit.cpp:212
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
ImportExportComponent.h