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
31
32using namespace armarx;
33
34std::string
36{
37 return "FakeWorkingMemoryObjectLocalizer";
38}
39
40std::string
45
46void
51
52void
57
58void
62
63void
67
74
76computePositionNoise(const Eigen::Vector3f& pos)
77{
78 memoryx::FloatVector mean;
79 mean.push_back(pos(0));
80 mean.push_back(pos(1));
81 mean.push_back(pos(2));
82
83 // assuming 2 mm noise
86 posDist->setMean(mean);
87 posDist->setCovariance(0, 0, 2.0f);
88 posDist->setCovariance(1, 1, 2.0f);
89 posDist->setCovariance(2, 2, 2.0f);
90 return posDist;
91}
92
93memoryx::ObjectLocalizationResultList
95 const memoryx::ObjectClassNameList& objectClassNames,
96 const Ice::Current&)
97{
98 memoryx::ObjectLocalizationResultList results;
99 auto objInstSeg = wm->getObjectInstancesSegment();
100 for (auto& className : objectClassNames)
101 {
102 ARMARX_DEBUG << deactivateSpam(5, className);
103
104 auto objInstances = objInstSeg->getObjectInstancesByClass(className);
105 for (memoryx::ObjectInstanceBasePtr obj : objInstances)
106 {
107 if (obj)
108 {
109 memoryx::ObjectLocalizationResult result;
110 result.objectClassName = className;
111 result.orientation = obj->getOrientationBase();
112 result.position = obj->getPositionBase();
113 result.positionNoise = computePositionNoise(
114 armarx::FramedPositionPtr::dynamicCast(result.position)->toEigen());
115 result.recognitionCertainty = 0.95;
116 result.timeStamp = TimestampVariant::nowPtr();
117 ARMARX_INFO << "Returning instance at pose " << obj->getPositionBase()->output();
118 results.push_back(result);
119 }
120 }
121 }
122 return results;
123}
124
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Definition Decoupled.h:29
::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)
Brief description of class FakeWorkingMemoryObjectLocalizer.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
std::string getDefaultName() const override
Retrieve default name of component.
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