ObjectLocalizationSaliency.h
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 RobotComponents::ArmarXObjects::ObjectLocalizationSaliency
17 * @author David Schiebener (schiebener at kit dot edu)
18 * @author Markus Grotz ( markus dot grotz at kit dot edu )
19 * @date 2016
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26
27#include <condition_variable>
28#include <mutex>
29
32
36#include <RobotAPI/interface/components/ViewSelectionInterface.h>
37
39#include <MemoryX/interface/components/WorkingMemoryInterface.h>
40#include <MemoryX/interface/memorytypes/MemorySegments.h>
41#include <MemoryX/interface/workingmemory/AbstractWorkingMemoryInterface.h>
48
49namespace armarx
50{
51 /**
52 * @class ObjectLocalizationSaliencyPropertyDefinitions
53 * @brief
54 */
57 {
58 public:
61 {
63 "RobotStateComponentName",
64 "RobotStateComponent",
65 "Name of the robot state component that should be used");
67 "HeadIKUnitName",
68 "HeadIKUnit",
69 "Name of the head IK unit component that should be used");
71 "WorkingMemoryName",
72 "WorkingMemory",
73 "Name of the WorkingMemory component that should be used");
75 "PriorKnowledgeName",
76 "PriorKnowledge",
77 "Name of the PriorKnowledge component that should be used");
79 "ViewSelectionName",
80 "ViewSelection",
81 "Name of the ViewSelection component that should be used");
83 "CameraFrameName",
84 "VirtualCentralGaze",
85 "Name of the frame of the head base in the robot model");
86
88 "HeadFrameName",
89 "Head Base",
90 "Name of the frame of the head base in the robot model");
92 "RandomNoiseLevel",
93 1.0f,
94 "Maximum for the random noise that will be added to the localization necessities");
95 defineOptionalProperty<float>("HalfCameraOpeningAngle",
96 12.0 * M_PI / 180.0,
97 "0.5 * minimal opening angles of the used cameras");
99 "MaxObjectDistance",
100 1500.f,
101 "Maximum distance of objects the head to be considered for observation");
103 "CentralHeadTiltAngle",
104 110.0f,
105 "Defines the height direction that will be considered 'central' in the reachable "
106 "area of the head (in degrees). Default is looking 20 degrees downwards");
108 "ProbabilityToLookForALostObject",
109 0.03f,
110 "Probability that one of the objects that have been seen but could later not been "
111 "localized again will be included in the view selection");
113 "UpdateFrequency", 10.0f, "Frequency of the saliency update");
114 }
115 };
116
117 /**
118 * @defgroup Component-ObjectLocalizationSaliency ObjectLocalizationSaliency
119 * @ingroup RobotComponents-Components
120 * A description of the component ObjectLocalizationSaliency.
121 *
122 * @class ObjectLocalizationSaliency
123 * @ingroup Component-ObjectLocalizationSaliency
124 * @brief Brief description of class ObjectLocalizationSaliency.
125 *
126 * Detailed description of class ObjectLocalizationSaliency.
127 */
129 virtual public armarx::Component,
130 virtual public armarx::ViewSelectionObserver
131 {
132 public:
133 /**
134 * @see armarx::ManagedIceObject::getDefaultName()
135 */
136 std::string
137 getDefaultName() const override
138 {
139 return "ObjectLocalizationSaliency";
140 }
141
142 void
143 onActivateAutomaticViewSelection(const Ice::Current& c = Ice::emptyCurrent) override
144 {
145 ARMARX_LOG << "enabling object saliency computation";
146
147 next = IceUtil::Time::seconds(0);
148
149 if (!(processorTask && processorTask->isRunning()))
150 {
151 processorTask->start();
152 }
153 else
154 {
155 ARMARX_INFO << "view selection already active";
156 }
157 }
158
159 void
160 onDeactivateAutomaticViewSelection(const Ice::Current& c = Ice::emptyCurrent) override
161 {
162
163 ARMARX_LOG << "disabling object saliency computation";
164 if (processorTask && processorTask->isRunning())
165 {
166 processorTask->stop();
167 }
168 }
169
170 void nextViewTarget(Ice::Long timestamp,
171 const Ice::Current& c = Ice::emptyCurrent) override;
172
173
174 protected:
175 /**
176 * @see armarx::ManagedIceObject::onInitComponent()
177 */
178 void onInitComponent() override;
179
180 /**
181 * @see armarx::ManagedIceObject::onConnectComponent()
182 */
183 void onConnectComponent() override;
184
185 /**
186 * @see armarx::ManagedIceObject::onDisconnectComponent()
187 */
188 void onDisconnectComponent() override;
189
190 /**
191 * @see armarx::ManagedIceObject::onExitComponent()
192 */
193 void onExitComponent() override;
194
195 /**
196 * @see PropertyUser::createPropertyDefinitions()
197 */
199
200
201 private:
202 void process();
203
204 void generateObjectLocalizationSaliency();
205
206 void addSaliencyRecursive(const int currentNodeIndex,
207 const float saliency,
208 const TSphereCoord objectSphereCoord,
209 const int objectIndex,
210 const float maxDistanceOnArc);
211
212 void setRandomNoise(const float centralAngleForVerticalDirection,
213 const float directionVariabilityFactor = 1.0f);
214 void generateRandomNoise(std::vector<memoryx::ObjectInstancePtr>& localizableObjects,
215 memoryx::EntityBaseList& objectInstances);
216
217
218 std::mutex mutex;
219 IceUtil::Time next;
220 IceUtil::Time lastDiff;
221
222 RobotStateComponentInterfacePrx robotStateComponent;
223
224 memoryx::WorkingMemoryInterfacePrx memoryProxy;
225 memoryx::PriorKnowledgeInterfacePrx priorKnowledge;
226 memoryx::ObjectInstanceMemorySegmentBasePrx objectInstancesProxy;
227 memoryx::ObjectClassMemorySegmentBasePrx objectClassesProxy;
229
230
231 ViewSelectionInterfacePrx viewSelection;
232
234
235
236 std::map<std::string, memoryx::ObjectClassPtr> recognizableObjClasses;
237
238 CIntensityGraph* saliencyEgosphereGraph;
239 CIntensityGraph* randomNoiseGraph;
240 CGraphPyramidLookupTable* graphLookupTable;
241
242 std::vector<int> nodeVisitedForObject;
243
244
245 Eigen::Vector3f offsetToHeadCenter;
246
247 float centralHeadTiltAngle;
248
249 float halfCameraOpeningAngle;
250 float deviationFromCameraCenterFactor;
251 float randomNoiseLevel;
252
253 std::string headFrameName, cameraFrameName;
254 };
255} // namespace armarx
std::string timestamp()
#define M_PI
Definition MathTools.h:17
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
Brief description of class ObjectLocalizationSaliency.
void onDeactivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onActivateAutomaticViewSelection(const Ice::Current &c=Ice::emptyCurrent) override
void nextViewTarget(Ice::Long timestamp, const Ice::Current &c=Ice::emptyCurrent) override
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_LOG
Definition Logging.h:165
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx