MetaWearIMUObserver.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-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
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #include "MetaWearIMUObserver.h"
25 
26 
31 
33 
35 
36 
37 
38 namespace armarx
39 {
41  {
42  usingTopic(getProperty<std::string>("MetaWearTopicName").getValue());
43 
48 
49  offeringTopic(getProperty<std::string>("DebugDrawerTopic").getValue());
50  }
51 
52 
53 
55  {
56  debugDrawerPrx = getTopic<DebugDrawerInterfacePrx>(getProperty<std::string>("DebugDrawerTopic").getValue());
57  }
58 
59 
61  {
62 
63  }
64 
65  void armarx::MetaWearIMUObserver::reportIMUValues(const std::string& name, const MetaWearIMUData& data, const TimestampBasePtr& timestamp, const Ice::Current&)
66  {
67  std::unique_lock lock(dataMutex);
68 
69  if (!existsChannel(name))
70  {
71  offerChannel(name, "MetaWear IMU data");
72  }
73  offerVector3(name, "acceleration", data.acceleration);
74  offerVector3(name, "gyro", data.gyro);
75  offerVector3(name, "magnetic", data.magnetic);
76  offerQuaternion(name, "orientationQuaternion", data.orientationQuaternion);
77 
78  updateChannel(name);
79 
80  }
81 
83  {
85  }
86 
87  void MetaWearIMUObserver::offerVector3(const std::string& channelName, const std::string& dfName, const std::vector<float>& data)
88  {
89  if (data.size() == 3)
90  {
91  Vector3Ptr vec3 = new Vector3(data.at(0), data.at(1), data.at(2));
92  offerOrUpdateDataField(channelName, dfName, vec3, dfName);
93  }
94  else if (data.size() != 0)
95  {
96  ARMARX_WARNING << "data." << dfName << ".size() != 3 && data." << dfName << ".size() != 0";
97  }
98  }
99 
100  void MetaWearIMUObserver::offerQuaternion(const std::string& channelName, const std::string& dfName, const std::vector<float>& data)
101  {
102  if (data.size() == 4)
103  {
104  QuaternionPtr quat = new Quaternion(data.at(0), data.at(1), data.at(2), data.at(3));
105  offerOrUpdateDataField(channelName, dfName, quat, dfName);
106  }
107  else if (data.size() != 0)
108  {
109  ARMARX_WARNING << "data." << dfName << ".size() != 4 && data." << dfName << ".size() != 0";
110  }
111  }
112 }
armarx::MetaWearIMUObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: MetaWearIMUObserver.cpp:82
armarx::MetaWearIMUObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: MetaWearIMUObserver.cpp:54
ConditionCheckEquals.h
GfxTL::vec3
VectorXD< 3, float > vec3
Definition: VectorXD.h:683
Pose.h
armarx::Observer::offerOrUpdateDataField
bool offerOrUpdateDataField(std::string channelName, std::string datafieldName, const Variant &value, const std::string &description)
Definition: Observer.cpp:222
armarx::ConditionCheckSmaller
Definition: ConditionCheckSmaller.h:40
armarx::VariantType::Quaternion
const VariantTypeId Quaternion
Definition: Pose.h:39
IceInternal::Handle< Vector3 >
armarx::MetaWearIMUObserver::onExitObserver
void onExitObserver() override
Framework hook.
Definition: MetaWearIMUObserver.cpp:60
armarx::ConditionCheckUpdated
Definition: ConditionCheckUpdated.h:41
armarx::MetaWearIMUObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: MetaWearIMUObserver.cpp:40
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::QuaternionPtr
IceInternal::Handle< Quaternion > QuaternionPtr
Definition: Pose.h:234
TimestampVariant.h
armarx::MetaWearIMUObserverPropertyDefinitions
Definition: MetaWearIMUObserver.h:40
MetaWearIMUObserver.h
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:248
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
armarx::MetaWearIMUObserver::reportIMUValues
void reportIMUValues(const std::string &name, const MetaWearIMUData &data, const TimestampBasePtr &timestamp, const Ice::Current &) override
Definition: MetaWearIMUObserver.cpp:65
ConditionCheckSmaller.h
armarx::ManagedIceObject::offeringTopic
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
Definition: ManagedIceObject.cpp:290
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::ConditionCheckEquals
Definition: ConditionCheckEquals.h:46
armarx::Observer::offerConditionCheck
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition: Observer.cpp:273
ConditionCheckLarger.h
armarx::ConditionCheckLarger
Definition: ConditionCheckLarger.h:40
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ConditionCheckUpdated.h