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