MultiHandUnit.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotAPI::ArmarXObjects::MultiHandUnit
17 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * @date 2019
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "MultiHandUnit.h"
24
26
27namespace armarx
28{
34
35 std::string
37 {
38 return "MultiHandUnit";
39 }
40
41 void
43 {
44 const auto units = getPropertyAsCSV<std::string>("HandUnitNameCSV");
45 if (units.empty())
46 {
47 ARMARX_ERROR << "PROPERTY HandUnitNameCSV IS EMPTY";
48 }
49 _handInfos.reserve(units.size());
50 for (const auto& name : units)
51 {
52 _handInfos.emplace_back();
53 _handInfos.back().proxyName = name;
54 usingProxy(name);
55 }
56 }
57
58 void
60 {
61 for (auto& info : _handInfos)
62 {
63 getProxy(info.proxy, info.proxyName);
64 info.handName = info.proxy->getHandName();
65 _hands[info.handName] = info.proxy;
66 }
67 }
68
69 void
71 {
72 _hands.clear();
73 }
74
75 void
79
86
87 HandInfoSeq
88 MultiHandUnit::getHandInfos(const Ice::Current&)
89 {
90 return _handInfos;
91 }
92
93 void
94 MultiHandUnit::setJointValues(const std::string& handName,
95 const NameValueMap& jointValues,
96 const Ice::Current&)
97 {
98 _hands.at(handName)->setJointAngles(jointValues);
99 }
100
101 NameValueMap
102 MultiHandUnit::getJointValues(const std::string& handName, const Ice::Current&)
103 {
104 return _hands.at(handName)->getCurrentJointValues();
105 }
106
108} // namespace armarx
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Definition Decoupled.h:29
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
MultiHandUnitPropertyDefinitions(std::string prefix)
Brief description of class MultiHandUnit.
void setJointValues(const std::string &handName, const NameValueMap &jointValues, const Ice::Current &=Ice::emptyCurrent) override
virtual void onInitComponent() override
virtual void onDisconnectComponent() override
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
HandInfoSeq getHandInfos(const Ice::Current &=Ice::emptyCurrent) override
virtual void onConnectComponent() override
NameValueMap getJointValues(const std::string &handName, const Ice::Current &=Ice::emptyCurrent) override
virtual void onExitComponent() override
virtual std::string getDefaultName() const override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
void getPropertyAsCSV(ContainerT &val, const std::string &name, const std::string &splitBy=",;", bool trimElements=true, bool removeEmptyElements=true)
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.