FakeWorkingMemoryObjectLocalizer.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package ArmarXSimulation::ArmarXObjects::FakeWorkingMemoryObjectLocalizer
17  * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18  * @date 2016
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
24 
28 
29 using namespace armarx;
30 
31 
33 {
34  return "FakeWorkingMemoryObjectLocalizer";
35 }
36 
38 {
39  usingProxy(getProperty<std::string>("WorkingMemoryName").getValue());
40 }
41 
42 
44 {
45  getProxyFromProperty(wm, "WorkingMemoryName");
46 }
47 
48 
50 {
51 
52 }
53 
54 
56 {
57 
58 }
59 
61 {
64 }
65 
67 {
69  mean.push_back(pos(0));
70  mean.push_back(pos(1));
71  mean.push_back(pos(2));
72 
73  // assuming 2 mm noise
75  posDist->setMean(mean);
76  posDist->setCovariance(0, 0, 2.0f);
77  posDist->setCovariance(1, 1, 2.0f);
78  posDist->setCovariance(2, 2, 2.0f);
79  return posDist;
80 }
81 
82 memoryx::ObjectLocalizationResultList FakeWorkingMemoryObjectLocalizer::localizeObjectClasses(const memoryx::ObjectClassNameList& objectClassNames, const Ice::Current&)
83 {
84  memoryx::ObjectLocalizationResultList results;
85  auto objInstSeg = wm->getObjectInstancesSegment();
86  for (auto& className : objectClassNames)
87  {
88  ARMARX_DEBUG << deactivateSpam(5, className);
89 
90  auto objInstances = objInstSeg->getObjectInstancesByClass(className);
91  for (memoryx::ObjectInstanceBasePtr obj : objInstances)
92  {
93  if (obj)
94  {
95  memoryx::ObjectLocalizationResult result;
96  result.objectClassName = className;
97  result.orientation = obj->getOrientationBase();
98  result.position = obj->getPositionBase();
99  result.positionNoise = computePositionNoise(armarx::FramedPositionPtr::dynamicCast(result.position)->toEigen());
100  result.recognitionCertainty = 0.95;
101  result.timeStamp = TimestampVariant::nowPtr();
102  ARMARX_INFO << "Returning instance at pose " << obj->getPositionBase()->output();
103  results.push_back(result);
104  }
105  }
106  }
107  return results;
108 }
armarx::FakeWorkingMemoryObjectLocalizer::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:60
armarx::FakeWorkingMemoryObjectLocalizer::wm
memoryx::WorkingMemoryInterfacePrx wm
Definition: FakeWorkingMemoryObjectLocalizer.h:102
armarx::FakeWorkingMemoryObjectLocalizer::getDefaultName
std::string getDefaultName() const override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:32
armarx::FakeWorkingMemoryObjectLocalizerPropertyDefinitions
Definition: FakeWorkingMemoryObjectLocalizer.h:38
armarx::FakeWorkingMemoryObjectLocalizer::onConnectComponent
void onConnectComponent() override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:43
armarx::TimestampVariant::nowPtr
static TimestampVariantPtr nowPtr()
Definition: TimestampVariant.h:111
IceInternal::Handle
Definition: forward_declarations.h:8
FakeWorkingMemoryObjectLocalizer.h
armarx::Component::getProxyFromProperty
ProxyType getProxyFromProperty(const std::string &propertyName, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
Get a proxy whose name is specified by the given property.
Definition: Component.h:236
armarx::mean
std::optional< float > mean(const boost::circular_buffer< NameValueMap > &buffer, const std::string &key)
Definition: KinematicUnitGuiPlugin.cpp:1615
armarx::FloatVector
::std::vector< ::Ice::Float > FloatVector
Definition: KinematicUnitGuiPlugin.h:327
armarx::FakeWorkingMemoryObjectLocalizer::onExitComponent
void onExitComponent() override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:55
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
TimestampVariant.h
armarx::FakeWorkingMemoryObjectLocalizer::onInitComponent
void onInitComponent() override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:37
MemoryXCoreObjectFactories.h
computePositionNoise
::memoryx::MultivariateNormalDistributionPtr computePositionNoise(const Eigen::Vector3f &pos)
Definition: FakeWorkingMemoryObjectLocalizer.cpp:66
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
IceUtil::Handle< class PropertyDefinitionContainer >
MemoryXTypesObjectFactories.h
armarx::Logging::deactivateSpam
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition: Logging.cpp:92
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx::FakeWorkingMemoryObjectLocalizer::localizeObjectClasses
memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList &objectClassNames, const Ice::Current &) override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:82
armarx::ManagedIceObject::usingProxy
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Definition: ManagedIceObject.cpp:151
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::FakeWorkingMemoryObjectLocalizer::onDisconnectComponent
void onDisconnectComponent() override
Definition: FakeWorkingMemoryObjectLocalizer.cpp:49
armarx::VariantType::MultivariateNormalDistribution
const armarx::VariantTypeId MultivariateNormalDistribution
Definition: ProbabilityMeasures.h:36