35 #include <RobotAPI/interface/core/RobotState.h>
37 #include <RobotAPI/interface/components/ViewSelectionInterface.h>
46 #include <Eigen/Geometry>
49 #include <condition_variable>
58 bool operator()(ViewTargetBasePtr
const& t1, ViewTargetBasePtr
const& t2)
60 if (t1->priority == t2->priority)
62 return t1->timeAdded->timestamp < t2->timeAdded->timestamp;
65 return t1->priority < t2->priority;
81 defineOptionalProperty<std::string>(
"RobotStateComponentName",
"RobotStateComponent",
"Name of the robot state component that should be used");
82 defineOptionalProperty<std::string>(
"HeadIKUnitName",
"HeadIKUnit",
"Name of the head IK unit component that should be used");
83 defineOptionalProperty<std::string>(
"HeadIKKinematicChainName",
"IKVirtualGaze",
"Name of the kinematic chain for the head IK");
84 defineOptionalProperty<std::string>(
"HeadFrameName",
"Head Base",
"Name of the frame of the head base in the robot model");
85 defineOptionalProperty<std::string>(
"CameraFrameName",
"VirtualCentralGaze",
"Name of the frame of the head base in the robot model");
86 defineOptionalProperty<int>(
"SleepingTimeBetweenViewDirectionChanges", 2500,
"Time between two view changes, to keep the head looking into one direction for a while (in ms)");
87 defineOptionalProperty<bool>(
"ActiveAtStartup",
true,
"Decide whether the automatic view selection will be activated (can be changed via the proxy during runtime)");
88 defineOptionalProperty<bool>(
"VisualizeViewDirection",
true,
"Draw view ray on DebugLayer.");
89 defineOptionalProperty<float>(
"MaxOverallHeadTiltAngle", 55.0f,
"Maximal angle the head and eyes can look down (in degrees)");
90 defineOptionalProperty<float>(
"CentralHeadTiltAngle", 110.0f,
"Defines the height direction that will be considered 'central' in the reachable area of the head (in degrees). Default is looking 20 degrees downwards");
91 defineOptionalProperty<float>(
"ProbabilityToLookForALostObject", 0.03f,
"Probability that one of the objects that have been seen but could later not been localized again will be included in the view selection");
92 defineOptionalProperty<float>(
"VisuSaliencyThreshold", 0.0f,
"If greater than zero the saliency map is drawn into the debug drawer on each iteration. The value is used as minimum saliency threshold for a point to be shown in debug visu");
111 virtual public ViewSelectionInterface
119 return "ViewSelection";
156 std::unique_lock lock(manualViewTargetsMutex);
158 ARMARX_INFO <<
"activating automatic view selection";
160 doAutomaticViewSelection =
true;
161 viewSelectionObserver->onActivateAutomaticViewSelection();
166 std::unique_lock lock(manualViewTargetsMutex);
168 ARMARX_INFO <<
"deactivating automatic view selection";
170 doAutomaticViewSelection =
false;
171 viewSelectionObserver->onDeactivateAutomaticViewSelection();
176 std::unique_lock lock(manualViewTargetsMutex);
178 return doAutomaticViewSelection;
181 void updateSaliencyMap(
const SaliencyMapBasePtr& map,
const Ice::Current&
c = Ice::emptyCurrent)
override;
183 void removeSaliencyMap(
const std::string& name,
const Ice::Current&
c = Ice::emptyCurrent)
override;
196 ViewTargetBasePtr nextAutomaticViewTarget();
198 void getActiveSaliencyMaps(std::vector<std::string>& activeSaliencyMaps);
203 HeadIKUnitInterfacePrx headIKUnitProxy;
206 ViewSelectionObserverPrx viewSelectionObserver;
208 std::string headIKKinematicChainName;
209 std::string headFrameName;
210 std::string cameraFrameName;
214 float sleepingTimeBetweenViewDirectionChanges;
217 bool drawViewDirection;
219 std::mutex manualViewTargetsMutex;
220 std::priority_queue<ViewTargetBasePtr, std::vector<ViewTargetBasePtr>,
CompareViewTargets> manualViewTargets;
222 bool doAutomaticViewSelection;
224 Eigen::Vector3f offsetToHeadCenter;
226 std::condition_variable condition;
227 bool hasNewSaliencyMap;
228 std::mutex syncMutex;
230 std::map<std::string, SaliencyMapBasePtr> saliencyMaps;
232 float visuSaliencyThreshold;