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
34namespace armarx
35{
36 void
38 {
39 usingTopic(getProperty<std::string>("SensorTopicName").getValue());
40 offeringTopic(getProperty<std::string>("DebugDrawerTopic").getValue());
41 }
42
43 void
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
130} // namespace armarx
std::string timestamp()
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
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
bool offerOrUpdateDataField(std::string channelName, std::string datafieldName, const Variant &value, const std::string &description)
Definition Observer.cpp:242
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
The Quaternion class.
Definition Pose.h:174
The Variant class is described here: Variants.
Definition Variant.h:224
The Vector3 class.
Definition Pose.h:113
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< Quaternion > QuaternionPtr
Definition Pose.h:234
IceInternal::Handle< TimestampVariant > TimestampVariantPtr