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
25namespace armarx
26{
32
33 std::string
35 {
36 return "MultiHandUnit";
37 }
38
39 void
41 {
42 const auto units = getPropertyAsCSV<std::string>("HandUnitNameCSV");
43 if (units.empty())
44 {
45 ARMARX_ERROR << "PROPERTY HandUnitNameCSV IS EMPTY";
46 }
47 _handInfos.reserve(units.size());
48 for (const auto& name : units)
49 {
50 _handInfos.emplace_back();
51 _handInfos.back().proxyName = name;
52 usingProxy(name);
53 }
54 }
55
56 void
58 {
59 for (auto& info : _handInfos)
60 {
61 getProxy(info.proxy, info.proxyName);
62 info.handName = info.proxy->getHandName();
63 _hands[info.handName] = info.proxy;
64 }
65 }
66
67 void
69 {
70 _hands.clear();
71 }
72
73 void
77
84
85 HandInfoSeq
86 MultiHandUnit::getHandInfos(const Ice::Current&)
87 {
88 return _handInfos;
89 }
90
91 void
92 MultiHandUnit::setJointValues(const std::string& handName,
93 const NameValueMap& jointValues,
94 const Ice::Current&)
95 {
96 _hands.at(handName)->setJointAngles(jointValues);
97 }
98
99 NameValueMap
100 MultiHandUnit::getJointValues(const std::string& handName, const Ice::Current&)
101 {
102 return _hands.at(handName)->getCurrentJointValues();
103 }
104} // namespace armarx
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)
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.