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 
31 
33 
34 namespace armarx
35 {
36  void
38  {
39  usingTopic(getProperty<std::string>("SensorTopicName").getValue());
40  offeringTopic(getProperty<std::string>("DebugDrawerTopic").getValue());
41  }
42 
43  void
45  {
46  debugDrawerPrx = getTopic<DebugDrawerInterfacePrx>(
47  getProperty<std::string>("DebugDrawerTopic").getValue());
48  }
49 
50  void
52  {
53  //debugDrawerPrx->removePoseVisu("IMU", "orientation");
54  //debugDrawerPrx->removeLineVisu("IMU", "acceleration");
55  }
56 
57  void
59  float pressure,
60  float qw,
61  float qx,
62  float qy,
63  float qz,
64  float pressureRate,
65  float rotationRate,
66  float accelerationRate,
67  float accelx,
68  float accely,
69  float accelz,
70  const TimestampBasePtr& timestamp,
71  const Ice::Current&)
72  {
73  std::unique_lock lock(dataMutex);
74  TimestampVariantPtr timestampPtr = TimestampVariantPtr::dynamicCast(timestamp);
75 
76  std::stringstream ss;
77  ss << "sensor" << id;
78  std::string channelName = ss.str();
79 
80  if (!existsChannel(channelName))
81  {
82  offerChannel(channelName, "Sensor Data");
83  }
84 
85  offerOrUpdateDataField(channelName, "pressure", Variant(pressure), "current pressure");
86  QuaternionPtr orientationQuaternion = new Quaternion(qw, qx, qy, qz);
88  channelName, "orientation", orientationQuaternion, "current orientation");
90  channelName, "rotationRate", Variant(rotationRate), "current rotationRate");
92  channelName, "pressureRate", Variant(pressureRate), "current pressureRate");
94  channelName, "accelerationRate", Variant(accelerationRate), "current accelerationRate");
95  offerOrUpdateDataField(channelName,
96  "linear acceleration",
97  Variant(new Vector3(accelx, accely, accelz)),
98  "current linear acceleration");
99  }
100 
101  /* TODO: for integration with debug drawer
102  updateChannel(device);
103 
104  Eigen::Vector3f zero;
105  zero.setZero();
106 
107  DrawColor color;
108  color.r = 1;
109  color.g = 1;
110  color.b = 0;
111  color.a = 0.5;
112 
113  Eigen::Vector3f ac = acceleration->toEigen();
114  ac *= 10;
115 
116  debugDrawerPrx->setLineVisu("IMU", "acceleration", new Vector3(), new Vector3(ac), 2.0f, color);
117 
118  PosePtr posePtr = new Pose(orientationQuaternion->toEigen(), zero);
119  debugDrawerPrx->setPoseVisu("IMU", "orientation", posePtr);
120  debugDrawerPrx->setBoxDebugLayerVisu("floor", new Pose(), new Vector3(5000, 5000, 1), DrawColor {0.7f, 0.7f, 0.7f, 1.0f});
121  */
122 
123 
126  {
127  return PropertyDefinitionsPtr(
129  }
130 } // namespace armarx
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:223
armarx::OrientedTactileSensorUnitObserverPropertyDefinitions
Definition: OrientedTactileSensorUnitObserver.h:41
armarx::OrientedTactileSensorUnitObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: OrientedTactileSensorUnitObserver.cpp:125
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:242
armarx::Observer::existsChannel
bool existsChannel(const std::string &channelName) const
Definition: Observer.cpp:1552
armarx::VariantType::Quaternion
const VariantTypeId Quaternion
Definition: Pose.h:39
armarx::OrientedTactileSensorUnitObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:44
IceInternal::Handle< TimestampVariant >
OrientedTactileSensorUnitObserver.h
TimestampVariant.h
timestamp
std::string timestamp()
Definition: CartographerAdapter.cpp:85
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:254
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::OrientedTactileSensorUnitObserver::onExitObserver
void onExitObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:51
ConditionCheckSmaller.h
armarx::ManagedIceObject::offeringTopic
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
Definition: ManagedIceObject.cpp:300
IceUtil::Handle
Definition: forward_declarations.h:30
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:43
ConditionCheckLarger.h
armarx::OrientedTactileSensorUnitObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: OrientedTactileSensorUnitObserver.cpp:37
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
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:58
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ConditionCheckUpdated.h
armarx::Observer::offerChannel
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition: Observer.cpp:131