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 
26 
29 
30 namespace visionx
31 {
33  {
34  usingTopic("ObjectLearningByPushing");
35  }
36 
38  {
39  offerChannel("objectHypotheses", "Gives information about having initial or validated hypotheses.");
40  armarx::Variant defaultValue(0);
41  offerDataFieldWithDefault("objectHypotheses", "initialHypothesesCreated", defaultValue, "Is 1 when initial object hypotheses are available, 0 if not, -1 if the creation failed.");
42  offerDataFieldWithDefault("objectHypotheses", "hypothesesValidated", defaultValue, "Is 1 when object hypotheses were validated, 0 if not, -1 if the validation failed.");
43 
44  offerChannel("objectHypothesisPosition", "Gives information about position and extent of the object hypothesis for pushing or grasping.");
45  offerDataField("objectHypothesisPosition", "objectPosition", armarx::VariantType::FramedPosition, "Position of the center of the object hypothesis");
46  offerDataField("objectHypothesisPosition", "objectExtent", armarx::VariantType::Float, "Estimated maximal extent of the object from its center");
47  offerDataField("objectHypothesisPosition", "principalAxis1", armarx::VariantType::Vector3, "First (i.e. longest) principal axis of the object hypothesis point cloud");
48  offerDataField("objectHypothesisPosition", "principalAxis2", armarx::VariantType::Vector3, "Second principal axis of the object hypothesis point cloud");
49  offerDataField("objectHypothesisPosition", "principalAxis3", armarx::VariantType::Vector3, "Third principal axis of the object hypothesis point cloud");
50  offerDataField("objectHypothesisPosition", "eigenValues", armarx::VariantType::Vector3, "Eigenvalues of the object hypothesis point cloud, i.e. variance (or std. dev.?) along the principal axes");
51 
53  }
54 
55 
56 
57  void ObjectLearningByPushingObserver::reportInitialObjectHypothesesCreated(bool hypothesesCreated, const Ice::Current&)
58  {
59  if (hypothesesCreated)
60  {
61  setDataField("objectHypotheses", "initialHypothesesCreated", 1);
62  ARMARX_IMPORTANT << "Initial hypotheses created";
63  }
64  else
65  {
66  setDataField("objectHypotheses", "initialHypothesesCreated", -1);
67  ARMARX_VERBOSE << "No initial object hypotheses available";
68  }
69 
70  updateChannel("objectHypotheses");
71  }
72 
73 
74 
75 
76  void ObjectLearningByPushingObserver::reportObjectHypothesesValidated(bool hypothesesValidated, const Ice::Current&)
77  {
78  if (hypothesesValidated)
79  {
80  setDataField("objectHypotheses", "hypothesesValidated", 1);
81  ARMARX_IMPORTANT << "Hypotheses were validated";
82  }
83  else
84  {
85  setDataField("objectHypotheses", "hypothesesValidated", -1);
86  ARMARX_VERBOSE << "No confirmed object hypotheses available";
87  }
88 
89  updateChannel("objectHypotheses");
90  }
91 
92 
93 
94 
96  {
97  setDataField("objectHypotheses", "initialHypothesesCreated", 0);
98  setDataField("objectHypotheses", "hypothesesValidated", 0);
99 
100  updateChannel("objectHypotheses");
101  }
102 
103 
104 
105 
106  void ObjectLearningByPushingObserver::reportObjectHypothesisPosition(const::armarx::FramedPositionBasePtr& objectPosition, Ice::Float objectExtent,
107  const::armarx::Vector3BasePtr& principalAxis1, const::armarx::Vector3BasePtr& principalAxis2,
108  const::armarx::Vector3BasePtr& principalAxis3, const::armarx::Vector3BasePtr& eigenValues, const Ice::Current&)
109  {
110  setDataField("objectHypothesisPosition", "objectPosition", armarx::Variant(objectPosition));
111  setDataField("objectHypothesisPosition", "objectExtent", armarx::Variant(objectExtent));
112  setDataField("objectHypothesisPosition", "principalAxis1", armarx::Variant(principalAxis1));
113  setDataField("objectHypothesisPosition", "principalAxis2", armarx::Variant(principalAxis2));
114  setDataField("objectHypothesisPosition", "principalAxis3", armarx::Variant(principalAxis3));
115  setDataField("objectHypothesisPosition", "eigenValues", armarx::Variant(eigenValues));
116 
117  updateChannel("objectHypothesisPosition");
118 
119  ARMARX_VERBOSE << "Object hypothesis position updated";
120  }
121 
122 }
armarx::Observer::updateChannel
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:715
visionx::ObjectLearningByPushingObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: ObjectLearningByPushingObserver.cpp:32
armarx::Variant
The Variant class is described here: Variants.
Definition: Variant.h:224
visionx::ObjectLearningByPushingObserver::reportObjectHypothesesValidated
void reportObjectHypothesesValidated(bool hypothesesValidated, const Ice::Current &) override
Definition: ObjectLearningByPushingObserver.cpp:76
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
ConditionCheckEquals.h
armarx::VariantType::Vector3
const VariantTypeId Vector3
Definition: Pose.h:38
visionx::ObjectLearningByPushingObserver::reportInitialObjectHypothesesCreated
void reportInitialObjectHypothesesCreated(bool hypothesesCreated, const Ice::Current &) override
Definition: ObjectLearningByPushingObserver.cpp:57
ObjectLearningByPushingObserver.h
FramedPose.h
armarx::Observer::setDataField
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:465
visionx::ObjectLearningByPushingObserver::reportObjectHypothesisPosition
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
Definition: ObjectLearningByPushingObserver.cpp:106
visionx::ObjectLearningByPushingObserver::resetHypothesesStatus
void resetHypothesesStatus(const Ice::Current &) override
Definition: ObjectLearningByPushingObserver.cpp:95
armarx::ManagedIceObject::usingTopic
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Definition: ManagedIceObject.cpp:248
armarx::ConditionCheckEquals
Definition: ConditionCheckEquals.h:46
visionx::ObjectLearningByPushingObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: ObjectLearningByPushingObserver.cpp:37
armarx::Observer::offerConditionCheck
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition: Observer.cpp:273
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition: FramedPose.h:39
armarx::Observer::offerDataFieldWithDefault
void offerDataFieldWithDefault(std::string channelName, std::string datafieldName, const Variant &defaultValue, std::string description)
Offer a datafield with default value.
Definition: Observer.cpp:152
armarx::Observer::offerDataField
void offerDataField(std::string channelName, std::string datafieldName, VariantTypeId type, std::string description)
Offer a datafield without default value.
Definition: Observer.cpp:187
armarx::Observer::offerChannel
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition: Observer.cpp:126