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
36namespace armarx
37{
38 /**
39 * \class HandUnitPropertyDefinitions
40 * \brief Defines all necessary properties for armarx::HandUnit
41 */
43 {
44 public:
46 {
48 "RobotFileName", "VirtualRobot XML file in which the endeffector is is stored.");
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 startTare(const Ice::Current&) override;
152
153 void tare(const Ice::Current&) override;
154
155 void rebootEmbeddedSystem(const Ice::Current&) override;
156
157 protected:
158 /**
159 * HandUnitListener proxy for publishing state updates
160 */
161 HandUnitListenerPrx listenerPrx;
162 /**
163 * Ice Topic name on which armarx::HandUnit::listenerPrx publishes information
164 */
166 /**
167 * List containing the names of all valid shapes.
168 */
170
171 std::string kinematicUnitName;
172
174 VirtualRobot::EndEffectorPtr eef;
175
176 std::string robotName;
177 std::string tcpName;
178
179 std::map<std::string, float> handJoints;
180
181 std::string graspedObject;
182
183
184 // HandUnitInterface interface
185 public:
186 std::string getHandName(const Ice::Current& = Ice::emptyCurrent) override;
187 void setJointForces(const NameValueMap& targetJointForces, const Ice::Current&) override;
188 void sendJointCommands(const NameCommandMap& targetJointCommands,
189 const Ice::Current&) override;
190 };
191} // namespace armarx
constexpr T c
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
HandUnitPropertyDefinitions(std::string prefix)
Definition HandUnit.h:45
Base unit for high-level access to robot hands.
Definition HandUnit.h:71
virtual void onExitHandUnit()=0
void onInitComponent() override
Retrieve proxy for publishing State information and call armarx::PlatformUnit::onInitPlatformUnit().
Definition HandUnit.cpp:55
std::string getHandName(const Ice::Current &=Ice::emptyCurrent) override
Definition HandUnit.cpp:215
HandUnitListenerPrx listenerPrx
HandUnitListener proxy for publishing state updates.
Definition HandUnit.h:161
SingleTypeVariantListPtr shapeNames
List containing the names of all valid shapes.
Definition HandUnit.h:169
std::string describeHandState(const Ice::Current &) override
Definition HandUnit.cpp:237
VirtualRobot::RobotPtr robot
Definition HandUnit.h:173
VirtualRobot::EndEffectorPtr eef
Definition HandUnit.h:174
std::string kinematicUnitName
Definition HandUnit.h:171
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:154
void setObjectReleased(const std::string &objectName, const Ice::Current &) override
Definition HandUnit.cpp:208
void setJointForces(const NameValueMap &targetJointForces, const Ice::Current &) override
Definition HandUnit.cpp:221
virtual void onInitHandUnit()=0
void sendJointCommands(const NameCommandMap &targetJointCommands, const Ice::Current &) override
Definition HandUnit.cpp:226
std::map< std::string, float > handJoints
Definition HandUnit.h:179
SingleTypeVariantListBasePtr getShapeNames(const Ice::Current &c=Ice::emptyCurrent) override
Definition HandUnit.cpp:167
std::string graspedObject
Definition HandUnit.h:181
std::string tcpName
Definition HandUnit.h:177
void setObjectGrasped(const std::string &objectName, const Ice::Current &) override
Definition HandUnit.cpp:201
void onConnectComponent() override
Calls armarx::PlatformUnit::onStartPlatformUnit().
Definition HandUnit.cpp:139
void setJointAngles(const NameValueMap &targetJointAngles, const Ice::Current &) override
Definition HandUnit.cpp:231
NameValueMap getCurrentJointValues(const Ice::Current &c=Ice::emptyCurrent) override
Definition HandUnit.cpp:188
void tare(const Ice::Current &) override
Definition HandUnit.cpp:255
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition HandUnit.cpp:173
void reloadPreshapes(const Ice::Current &) override
Definition HandUnit.cpp:243
std::string listenerChannelName
Ice Topic name on which armarx::HandUnit::listenerPrx publishes information.
Definition HandUnit.h:165
void startTare(const Ice::Current &) override
Definition HandUnit.cpp:249
void onExitComponent() override
Calls armarx::PlatformUnit::onExitPlatformUnit().
Definition HandUnit.cpp:148
void rebootEmbeddedSystem(const Ice::Current &) override
Definition HandUnit.cpp:261
std::string robotName
Definition HandUnit.h:176
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:159
virtual void onStartHandUnit()=0
NameValueMap getShapeJointValues(const std::string &shapeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition HandUnit.cpp:179
std::string getDefaultName() const override
Retrieve default name of component.
Definition HandUnit.h:75
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
SensorActorUnit()
Constructs a SensorActorUnit.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.