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
27
28namespace armarx
29{
30 void
32 {
33 usingTopic(getProperty<std::string>("CyberGloveTopicName").getValue());
34 }
35
36 void
41
42 //void CyberGloveObserver::onDisconnectComponent()
43 //{
44
45 //}
46
47
48 void
52
59
60 void
61 CyberGloveObserver::reportGloveValues(const CyberGloveValues& gloveValues, const Ice::Current&)
62 {
63 std::unique_lock lock(dataMutex);
64
65 IceUtil::Time now = TimeUtil::GetTime();
66
67 long deltaUS = (now - lastUpdate).toMicroSeconds();
68
69 ARMARX_IMPORTANT << deltaUS << " " << gloveValues.time << " " << gloveValues.indexDIP;
70 lastUpdate = now;
71
72 latestValues = gloveValues;
73
74
75 std::string name = gloveValues.name;
76 if (!existsChannel(name))
77 {
78 offerChannel(name, "CyberGlove motor data");
79 }
80
81 offerOrUpdateDataField(name, "name", Variant(name), "Name of the prostesis");
82
84 name, "thumbCMC", Variant(gloveValues.thumbCMC), "Value of thumbCMC");
86 name, "thumbMCP", Variant(gloveValues.thumbMCP), "Value of thumbMCP");
87 offerOrUpdateDataField(name, "thumbIP", Variant(gloveValues.thumbIP), "Value of thumbIP");
89 name, "thumbAbd", Variant(gloveValues.thumbAbd), "Value of thumbAbd");
91 name, "indexMCP", Variant(gloveValues.indexMCP), "Value of indexMCP");
93 name, "indexPIP", Variant(gloveValues.indexPIP), "Value of indexPIP");
95 name, "indexDIP", Variant(gloveValues.indexDIP), "Value of indexDIP");
97 name, "middleMCP", Variant(gloveValues.middleMCP), "Value of middleMCP");
99 name, "middlePIP", Variant(gloveValues.middlePIP), "Value of middlePIP");
101 name, "middleDIP", Variant(gloveValues.middleDIP), "Value of middleDIP");
103 name, "middleAbd", Variant(gloveValues.middleAbd), "Value of middleAbd");
104 offerOrUpdateDataField(name, "ringMCP", Variant(gloveValues.ringMCP), "Value of ringMCP");
105 offerOrUpdateDataField(name, "ringPIP", Variant(gloveValues.ringPIP), "Value of ringPIP");
106 offerOrUpdateDataField(name, "ringDIP", Variant(gloveValues.ringDIP), "Value of ringDIP");
107 offerOrUpdateDataField(name, "ringAbd", Variant(gloveValues.ringAbd), "Value of ringAbd");
109 name, "littleMCP", Variant(gloveValues.littleMCP), "Value of littleMCP");
111 name, "littlePIP", Variant(gloveValues.littlePIP), "Value of littlePIP");
113 name, "littleDIP", Variant(gloveValues.littleDIP), "Value of littleDIP");
115 name, "littleAbd", Variant(gloveValues.littleAbd), "Value of littleAbd");
117 name, "palmArch", Variant(gloveValues.palmArch), "Value of palmArch");
119 name, "wristFlex", Variant(gloveValues.wristFlex), "Value of wristFlex");
121 name, "wristAbd", Variant(gloveValues.wristAbd), "Value of wristAbd");
122
123
124 updateChannel(name);
125 }
126
129 {
130 std::unique_lock lock(dataMutex);
131 return latestValues;
132 }
133
135} // namespace armarx
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Definition Decoupled.h:29
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
Brief description of class CyberGloveObserver.
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.