ObjectLearningByPushingObserver.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
27
29
30namespace visionx
31{
32 void
34 {
35 usingTopic("ObjectLearningByPushing");
36 }
37
38 void
40 {
41 offerChannel("objectHypotheses",
42 "Gives information about having initial or validated hypotheses.");
43 armarx::Variant defaultValue(0);
44 offerDataFieldWithDefault("objectHypotheses",
45 "initialHypothesesCreated",
46 defaultValue,
47 "Is 1 when initial object hypotheses are available, 0 if not, -1 "
48 "if the creation failed.");
50 "objectHypotheses",
51 "hypothesesValidated",
52 defaultValue,
53 "Is 1 when object hypotheses were validated, 0 if not, -1 if the validation failed.");
54
55 offerChannel("objectHypothesisPosition",
56 "Gives information about position and extent of the object hypothesis for "
57 "pushing or grasping.");
58 offerDataField("objectHypothesisPosition",
59 "objectPosition",
61 "Position of the center of the object hypothesis");
62 offerDataField("objectHypothesisPosition",
63 "objectExtent",
65 "Estimated maximal extent of the object from its center");
66 offerDataField("objectHypothesisPosition",
67 "principalAxis1",
69 "First (i.e. longest) principal axis of the object hypothesis point cloud");
70 offerDataField("objectHypothesisPosition",
71 "principalAxis2",
73 "Second principal axis of the object hypothesis point cloud");
74 offerDataField("objectHypothesisPosition",
75 "principalAxis3",
77 "Third principal axis of the object hypothesis point cloud");
78 offerDataField("objectHypothesisPosition",
79 "eigenValues",
81 "Eigenvalues of the object hypothesis point cloud, i.e. variance (or std. "
82 "dev.?) along the principal axes");
83
85 }
86
87 void
89 const Ice::Current&)
90 {
91 if (hypothesesCreated)
92 {
93 setDataField("objectHypotheses", "initialHypothesesCreated", 1);
94 ARMARX_IMPORTANT << "Initial hypotheses created";
95 }
96 else
97 {
98 setDataField("objectHypotheses", "initialHypothesesCreated", -1);
99 ARMARX_VERBOSE << "No initial object hypotheses available";
100 }
101
102 updateChannel("objectHypotheses");
103 }
104
105 void
107 const Ice::Current&)
108 {
109 if (hypothesesValidated)
110 {
111 setDataField("objectHypotheses", "hypothesesValidated", 1);
112 ARMARX_IMPORTANT << "Hypotheses were validated";
113 }
114 else
115 {
116 setDataField("objectHypotheses", "hypothesesValidated", -1);
117 ARMARX_VERBOSE << "No confirmed object hypotheses available";
118 }
119
120 updateChannel("objectHypotheses");
121 }
122
123 void
125 {
126 setDataField("objectHypotheses", "initialHypothesesCreated", 0);
127 setDataField("objectHypotheses", "hypothesesValidated", 0);
128
129 updateChannel("objectHypotheses");
130 }
131
132 void
134 const ::armarx::FramedPositionBasePtr& objectPosition,
135 Ice::Float objectExtent,
136 const ::armarx::Vector3BasePtr& principalAxis1,
137 const ::armarx::Vector3BasePtr& principalAxis2,
138 const ::armarx::Vector3BasePtr& principalAxis3,
139 const ::armarx::Vector3BasePtr& eigenValues,
140 const Ice::Current&)
141 {
142 setDataField("objectHypothesisPosition", "objectPosition", armarx::Variant(objectPosition));
143 setDataField("objectHypothesisPosition", "objectExtent", armarx::Variant(objectExtent));
144 setDataField("objectHypothesisPosition", "principalAxis1", armarx::Variant(principalAxis1));
145 setDataField("objectHypothesisPosition", "principalAxis2", armarx::Variant(principalAxis2));
146 setDataField("objectHypothesisPosition", "principalAxis3", armarx::Variant(principalAxis3));
147 setDataField("objectHypothesisPosition", "eigenValues", armarx::Variant(eigenValues));
148
149 updateChannel("objectHypothesisPosition");
150
151 ARMARX_VERBOSE << "Object hypothesis position updated";
152 }
153
154} // namespace visionx
Checks if the numbers published in the relevant data fields equal a reference value.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition Observer.cpp:131
void offerDataField(std::string channelName, std::string datafieldName, VariantTypeId type, std::string description)
Offer a datafield without default value.
Definition Observer.cpp:201
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition Observer.cpp:301
void updateChannel(const std::string &channelName, const std::set< std::string > &updatedDatafields=std::set< std::string >())
Update all conditions for a channel.
Definition Observer.cpp:788
void offerDataFieldWithDefault(std::string channelName, std::string datafieldName, const Variant &defaultValue, std::string description)
Offer a datafield with default value.
Definition Observer.cpp:160
void setDataField(const std::string &channelName, const std::string &datafieldName, const Variant &value, bool triggerFilterUpdate=true)
set datafield with datafieldName and in channel channelName
Definition Observer.cpp:508
The Variant class is described here: Variants.
Definition Variant.h:224
void reportInitialObjectHypothesesCreated(bool hypothesesCreated, const Ice::Current &) override
void reportObjectHypothesesValidated(bool hypothesesValidated, const Ice::Current &) override
void reportObjectHypothesisPosition(const ::armarx::FramedPositionBasePtr &objectPosition, ::Ice::Float objectExtent, const ::armarx::Vector3BasePtr &principalAxis1, const ::armarx::Vector3BasePtr &principalAxis2, const ::armarx::Vector3BasePtr &principalAxis3, const ::armarx::Vector3BasePtr &eigenValues, const Ice::Current &) override
void resetHypothesesStatus(const Ice::Current &) override
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
const VariantTypeId FramedPosition
Definition FramedPose.h:38
const VariantTypeId Vector3
Definition Pose.h:38
const VariantTypeId Float
Definition Variant.h:919
ArmarX headers.