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
26
29
30using namespace armarx;
31
32std::string
34{
35 return "FakeWorkingMemoryObjectLocalizer";
36}
37
38void
43
44void
49
50void
54
55void
59
66
68computePositionNoise(const Eigen::Vector3f& pos)
69{
70 memoryx::FloatVector mean;
71 mean.push_back(pos(0));
72 mean.push_back(pos(1));
73 mean.push_back(pos(2));
74
75 // assuming 2 mm noise
78 posDist->setMean(mean);
79 posDist->setCovariance(0, 0, 2.0f);
80 posDist->setCovariance(1, 1, 2.0f);
81 posDist->setCovariance(2, 2, 2.0f);
82 return posDist;
83}
84
85memoryx::ObjectLocalizationResultList
87 const memoryx::ObjectClassNameList& objectClassNames,
88 const Ice::Current&)
89{
90 memoryx::ObjectLocalizationResultList results;
91 auto objInstSeg = wm->getObjectInstancesSegment();
92 for (auto& className : objectClassNames)
93 {
94 ARMARX_DEBUG << deactivateSpam(5, className);
95
96 auto objInstances = objInstSeg->getObjectInstancesByClass(className);
97 for (memoryx::ObjectInstanceBasePtr obj : objInstances)
98 {
99 if (obj)
100 {
101 memoryx::ObjectLocalizationResult result;
102 result.objectClassName = className;
103 result.orientation = obj->getOrientationBase();
104 result.position = obj->getPositionBase();
105 result.positionNoise = computePositionNoise(
106 armarx::FramedPositionPtr::dynamicCast(result.position)->toEigen());
107 result.recognitionCertainty = 0.95;
108 result.timeStamp = TimestampVariant::nowPtr();
109 ARMARX_INFO << "Returning instance at pose " << obj->getPositionBase()->output();
110 results.push_back(result);
111 }
112 }
113 }
114 return results;
115}
::memoryx::MultivariateNormalDistributionPtr computePositionNoise(const Eigen::Vector3f &pos)
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:242
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList &objectClassNames, const Ice::Current &) override
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:99
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
static TimestampVariantPtr nowPtr()
The MultivariateNormalDistribution class.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::optional< float > mean(const boost::circular_buffer< NameValueMap > &buffer, const std::string &key)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< MultivariateNormalDistribution > MultivariateNormalDistributionPtr