OrientedTactileSensorUnitObserver.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  */
25 
26 
31 
33 
35 
36 
37 
38 namespace armarx
39 {
41  {
42  usingTopic(getProperty<std::string>("SensorTopicName").getValue());
43  offeringTopic(getProperty<std::string>("DebugDrawerTopic").getValue());
44  }
45 
46 
47 
49  {
50  debugDrawerPrx = getTopic<DebugDrawerInterfacePrx>(getProperty<std::string>("DebugDrawerTopic").getValue());
51  }
52 
53 
55  {
56  //debugDrawerPrx->removePoseVisu("IMU", "orientation");
57  //debugDrawerPrx->removeLineVisu("IMU", "acceleration");
58  }
59 
60  void OrientedTactileSensorUnitObserver::reportSensorValues(int id, float pressure, float qw, float qx, float qy, float qz, float pressureRate, float rotationRate, float accelerationRate, float accelx, float accely, float accelz, const TimestampBasePtr& timestamp, const Ice::Current&)
61  {
62  std::unique_lock lock(dataMutex);
63  TimestampVariantPtr timestampPtr = TimestampVariantPtr::dynamicCast(timestamp);
64 
65  std::stringstream ss;
66  ss << "sensor" << id;
67  std::string channelName = ss.str();
68 
69  if (!existsChannel(channelName))
70  {
71  offerChannel(channelName, "Sensor Data");
72  }
73 
74  offerOrUpdateDataField(channelName, "pressure", Variant(pressure), "current pressure");
75  QuaternionPtr orientationQuaternion = new Quaternion(qw, qx, qy, qz);
76  offerOrUpdateDataField(channelName, "orientation", orientationQuaternion, "current orientation");
77  offerOrUpdateDataField(channelName, "rotationRate", Variant(rotationRate), "current rotationRate");
78  offerOrUpdateDataField(channelName, "pressureRate", Variant(pressureRate), "current pressureRate");
79  offerOrUpdateDataField(channelName, "accelerationRate", Variant(accelerationRate), "current accelerationRate");
80  offerOrUpdateDataField(channelName, "linear acceleration", Variant(new Vector3(accelx, accely, accelz)), "current linear acceleration");
81  }
82  /* TODO: for integration with debug drawer
83  updateChannel(device);
84 
85  Eigen::Vector3f zero;
86  zero.setZero();
87 
88  DrawColor color;
89  color.r = 1;
90  color.g = 1;
91  color.b = 0;
92  color.a = 0.5;
93 
94  Eigen::Vector3f ac = acceleration->toEigen();
95  ac *= 10;
96 
97  debugDrawerPrx->setLineVisu("IMU", "acceleration", new Vector3(), new Vector3(ac), 2.0f, color);
98 
99  PosePtr posePtr = new Pose(orientationQuaternion->toEigen(), zero);
100  debugDrawerPrx->setPoseVisu("IMU", "orientation", posePtr);
101  debugDrawerPrx->setBoxDebugLayerVisu("floor", new Pose(), new Vector3(5000, 5000, 1), DrawColor {0.7f, 0.7f, 0.7f, 1.0f});
102  */
103 
104 
106  {
108  }
109 }
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
armarx::OrientedTactileSensorUnitObserverPropertyDefinitions
Definition: OrientedTactileSensorUnitObserver.h:40
armarx::OrientedTactileSensorUnitObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: OrientedTactileSensorUnitObserver.cpp:105
ConditionCheckEquals.h
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::Observer::existsChannel
bool existsChannel(const std::string &channelName) const
Definition: Observer.cpp:1433
armarx::VariantType::Quaternion
const VariantTypeId Quaternion
Definition: Pose.h:39
armarx::OrientedTactileSensorUnitObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:48
IceInternal::Handle< TimestampVariant >
OrientedTactileSensorUnitObserver.h
TimestampVariant.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::OrientedTactileSensorUnitObserver::onExitObserver
void onExitObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:54
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
ConditionCheckLarger.h
armarx::OrientedTactileSensorUnitObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:40
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx::OrientedTactileSensorUnitObserver::reportSensorValues
void reportSensorValues(int id, float pressure, float qw, float qx, float qy, float qz, float pressureRate, float rotationRate, float accelerationRate, float accelx, float accely, float accelz, const TimestampBasePtr &timestamp, const Ice::Current &) override
Definition: OrientedTactileSensorUnitObserver.cpp:60
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ConditionCheckUpdated.h
armarx::Observer::offerChannel
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition: Observer.cpp:126