WeissHapticSensorTest.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-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 RobotAPI::WeissHapticGroup
19 * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
20 * @date 2015
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
26
28
31
32using namespace armarx;
33using namespace WeissHapticGroup;
34
35//// DO NOT EDIT NEXT LINE
36WeissHapticSensorTest::SubClassRegistry
37 WeissHapticSensorTest::Registry(WeissHapticSensorTest::GetName(),
39
42 WeissHapticSensorTestGeneratedBase<WeissHapticSensorTest>(stateData)
43{
44}
45
46void
48{
49 HapticUnitObserverInterfacePrx hapticObserver = getHapticObserver();
50 ChannelRegistry channels = hapticObserver->getAvailableChannels(false);
51 std::map<std::string, DatafieldRefPtr> tactileDatafields_MaximumValueMap;
52
53 if (channels.size() == 0)
54 {
55 ARMARX_WARNING << "No tactile pads found";
56 }
57 else
58 {
59 ARMARX_INFO << "Creating tactile channels";
60
61 for (std::pair<std::string, ChannelRegistryEntry> pair : channels)
62 {
63 std::string tactilePad = pair.first;
64 DatafieldRefBasePtr matrixDatafield =
65 new DatafieldRef(hapticObserver, tactilePad, "matrix");
66 DatafieldRefBasePtr matrixNulled = hapticObserver->createFilteredDatafield(
67 DatafieldFilterBasePtr(new filters::OffsetFilter()), matrixDatafield);
68 DatafieldRefBasePtr matrixMax = hapticObserver->createFilteredDatafield(
69 DatafieldFilterBasePtr(new filters::MatrixMaxFilter()), matrixNulled);
70 tactileDatafields_MaximumValueMap.insert(
71 std::make_pair(tactilePad, DatafieldRefPtr::dynamicCast(matrixMax)));
72 }
73 }
74
75 local.setTactileDatafields_MaximumValue(tactileDatafields_MaximumValueMap);
76}
77
78void
80{
81 std::map<std::string, DatafieldRefPtr> tactileDatafields_MaximumValueMap =
82 local.getTactileDatafields_MaximumValue();
83
84 while (!isRunningTaskStopped()) // stop run function if returning true
85 {
86 std::stringstream ss;
87 std::stringstream ssNames;
88 int max = 0;
89
90 for (std::pair<std::string, DatafieldRefPtr> pair : tactileDatafields_MaximumValueMap)
91 {
92 std::string tactilePad = pair.first;
93 DatafieldRefPtr matrixMax = pair.second;
94 int padMax = (int)matrixMax->getDataField()->getFloat();
95 ss << padMax << "; ";
96 ssNames << tactilePad << "; ";
97 max = std::max(max, padMax);
98 }
99
100 ARMARX_IMPORTANT << "tactile max value: " << max << "; \n\n"
101 << ss.str() << "\n"
102 << ssNames.str();
103
104 usleep(10000); // 100ms
105 }
106}
107
108void
110{
111 // put your user code for the breaking point here
112 // execution time should be short (<100ms)
113}
114
115void
117{
118 // put your user code for the exit point here
119 // execution time should be short (<100ms)
120}
121
122// DO NOT EDIT NEXT FUNCTION
The DatafieldRef class is similar to the ChannelRef, but points to a specific Datafield instead of to...
WeissHapticSensorTest(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
The OffsetFilter class returns values relative to value from the first call of the filter.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DatafieldRef > DatafieldRefPtr
Definition Observer.h:43
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64