CyberGloveObserver.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::CyberGloveObserver
17 * @author JuliaStarke ( julia dot starke at kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "CyberGloveObserver.h"
24
26
27namespace armarx
28{
29 void
31 {
32 usingTopic(getProperty<std::string>("CyberGloveTopicName").getValue());
33 }
34
35 void
40
41 //void CyberGloveObserver::onDisconnectComponent()
42 //{
43
44 //}
45
46
47 void
51
58
59 void
60 CyberGloveObserver::reportGloveValues(const CyberGloveValues& gloveValues, const Ice::Current&)
61 {
62 std::unique_lock lock(dataMutex);
63
64 IceUtil::Time now = TimeUtil::GetTime();
65
66 long deltaUS = (now - lastUpdate).toMicroSeconds();
67
68 ARMARX_IMPORTANT << deltaUS << " " << gloveValues.time << " " << gloveValues.indexDIP;
69 lastUpdate = now;
70
71 latestValues = gloveValues;
72
73
74 std::string name = gloveValues.name;
75 if (!existsChannel(name))
76 {
77 offerChannel(name, "CyberGlove motor data");
78 }
79
80 offerOrUpdateDataField(name, "name", Variant(name), "Name of the prostesis");
81
83 name, "thumbCMC", Variant(gloveValues.thumbCMC), "Value of thumbCMC");
85 name, "thumbMCP", Variant(gloveValues.thumbMCP), "Value of thumbMCP");
86 offerOrUpdateDataField(name, "thumbIP", Variant(gloveValues.thumbIP), "Value of thumbIP");
88 name, "thumbAbd", Variant(gloveValues.thumbAbd), "Value of thumbAbd");
90 name, "indexMCP", Variant(gloveValues.indexMCP), "Value of indexMCP");
92 name, "indexPIP", Variant(gloveValues.indexPIP), "Value of indexPIP");
94 name, "indexDIP", Variant(gloveValues.indexDIP), "Value of indexDIP");
96 name, "middleMCP", Variant(gloveValues.middleMCP), "Value of middleMCP");
98 name, "middlePIP", Variant(gloveValues.middlePIP), "Value of middlePIP");
100 name, "middleDIP", Variant(gloveValues.middleDIP), "Value of middleDIP");
102 name, "middleAbd", Variant(gloveValues.middleAbd), "Value of middleAbd");
103 offerOrUpdateDataField(name, "ringMCP", Variant(gloveValues.ringMCP), "Value of ringMCP");
104 offerOrUpdateDataField(name, "ringPIP", Variant(gloveValues.ringPIP), "Value of ringPIP");
105 offerOrUpdateDataField(name, "ringDIP", Variant(gloveValues.ringDIP), "Value of ringDIP");
106 offerOrUpdateDataField(name, "ringAbd", Variant(gloveValues.ringAbd), "Value of ringAbd");
108 name, "littleMCP", Variant(gloveValues.littleMCP), "Value of littleMCP");
110 name, "littlePIP", Variant(gloveValues.littlePIP), "Value of littlePIP");
112 name, "littleDIP", Variant(gloveValues.littleDIP), "Value of littleDIP");
114 name, "littleAbd", Variant(gloveValues.littleAbd), "Value of littleAbd");
116 name, "palmArch", Variant(gloveValues.palmArch), "Value of palmArch");
118 name, "wristFlex", Variant(gloveValues.wristFlex), "Value of wristFlex");
120 name, "wristAbd", Variant(gloveValues.wristAbd), "Value of wristAbd");
121
122
123 updateChannel(name);
124 }
125
128 {
129 std::unique_lock lock(dataMutex);
130 return latestValues;
131 }
132} // namespace armarx
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
CyberGloveValues getLatestValues(const Ice::Current &) override
void reportGloveValues(const CyberGloveValues &gloveValues, const Ice::Current &) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
bool existsChannel(const std::string &channelName) const
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition Observer.cpp:131
void updateChannel(const std::string &channelName, const std::set< std::string > &updatedDatafields=std::set< std::string >())
Update all conditions for a channel.
Definition Observer.cpp:788
bool offerOrUpdateDataField(std::string channelName, std::string datafieldName, const Variant &value, const std::string &description)
Definition Observer.cpp:242
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
Definition TimeUtil.cpp:42
The Variant class is described here: Variants.
Definition Variant.h:224
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.