29 #include <condition_variable>
33 #include <Eigen/Geometry>
44 #include <RobotAPI/interface/components/ViewSelectionInterface.h>
45 #include <RobotAPI/interface/core/RobotState.h>
54 operator()(ViewTargetBasePtr
const& t1, ViewTargetBasePtr
const& t2)
56 if (t1->priority == t2->priority)
58 return t1->timeAdded->timestamp < t2->timeAdded->timestamp;
60 return t1->priority < t2->priority;
73 defineOptionalProperty<std::string>(
74 "RobotStateComponentName",
75 "RobotStateComponent",
76 "Name of the robot state component that should be used");
77 defineOptionalProperty<std::string>(
80 "Name of the head IK unit component that should be used");
81 defineOptionalProperty<std::string>(
"HeadIKKinematicChainName",
83 "Name of the kinematic chain for the head IK");
84 defineOptionalProperty<std::string>(
87 "Name of the frame of the head base in the robot model");
88 defineOptionalProperty<std::string>(
91 "Name of the frame of the head base in the robot model");
92 defineOptionalProperty<int>(
"SleepingTimeBetweenViewDirectionChanges",
94 "Time between two view changes, to keep the head looking "
95 "into one direction for a while (in ms)");
96 defineOptionalProperty<bool>(
"ActiveAtStartup",
98 "Decide whether the automatic view selection will be "
99 "activated (can be changed via the proxy during runtime)");
100 defineOptionalProperty<bool>(
101 "VisualizeViewDirection",
true,
"Draw view ray on DebugLayer.");
102 defineOptionalProperty<float>(
103 "MaxOverallHeadTiltAngle",
105 "Maximal angle the head and eyes can look down (in degrees)");
106 defineOptionalProperty<float>(
107 "CentralHeadTiltAngle",
109 "Defines the height direction that will be considered 'central' in the reachable "
110 "area of the head (in degrees). Default is looking 20 degrees downwards");
111 defineOptionalProperty<float>(
112 "ProbabilityToLookForALostObject",
114 "Probability that one of the objects that have been seen but could later not been "
115 "localized again will be included in the view selection");
116 defineOptionalProperty<float>(
117 "VisuSaliencyThreshold",
119 "If greater than zero the saliency map is drawn into the debug drawer on each "
120 "iteration. The value is used as minimum saliency threshold for a point to be "
121 "shown in debug visu");
147 return "ViewSelection";
177 const Ice::Current&
c = Ice::emptyCurrent)
override;
186 std::unique_lock lock(manualViewTargetsMutex);
188 ARMARX_INFO <<
"activating automatic view selection";
190 doAutomaticViewSelection =
true;
191 viewSelectionObserver->onActivateAutomaticViewSelection();
197 std::unique_lock lock(manualViewTargetsMutex);
199 ARMARX_INFO <<
"deactivating automatic view selection";
201 doAutomaticViewSelection =
false;
202 viewSelectionObserver->onDeactivateAutomaticViewSelection();
208 std::unique_lock lock(manualViewTargetsMutex);
210 return doAutomaticViewSelection;
214 const Ice::Current&
c = Ice::emptyCurrent)
override;
217 const Ice::Current&
c = Ice::emptyCurrent)
override;
222 const Ice::Current&
c = Ice::emptyCurrent)
override;
230 ViewTargetBasePtr nextAutomaticViewTarget();
232 void getActiveSaliencyMaps(std::vector<std::string>& activeSaliencyMaps);
237 HeadIKUnitInterfacePrx headIKUnitProxy;
240 ViewSelectionObserverPrx viewSelectionObserver;
242 std::string headIKKinematicChainName;
243 std::string headFrameName;
244 std::string cameraFrameName;
248 float sleepingTimeBetweenViewDirectionChanges;
251 bool drawViewDirection;
253 std::mutex manualViewTargetsMutex;
254 std::priority_queue<ViewTargetBasePtr, std::vector<ViewTargetBasePtr>,
CompareViewTargets>
257 bool doAutomaticViewSelection;
259 Eigen::Vector3f offsetToHeadCenter;
261 std::condition_variable condition;
262 bool hasNewSaliencyMap;
263 std::mutex syncMutex;
265 std::map<std::string, SaliencyMapBasePtr> saliencyMaps;
267 float visuSaliencyThreshold;