GazeTargetReachedMonitor.cpp
Go to the documentation of this file.
2
3#include <mutex>
4
6{
7
9 config(config)
10 {
11 }
12
13 void
14 GazeTargetReachedMonitor::reset(const std::int64_t targetId)
15 {
16 const std::scoped_lock lock(mutex);
17
18 activeTargetId = targetId;
19 reachedCount = 0;
20 unreachableCount = 0;
21 latestResidual = gaze_controller::GazeResidual{};
22 }
23
24 void
25 GazeTargetReachedMonitor::update(const std::int64_t targetId,
27 const bool targetReachable)
28 {
29 const std::scoped_lock lock(mutex);
30
31 // Stale report about a target we already moved on from.
32 if (targetId != activeTargetId)
33 {
34 return;
35 }
36
37 latestResidual = residual;
38
39 const bool onTarget =
40 residual.angularError <= config.angularTh and residual.lateralError <= config.lateralTh;
41
42 reachedCount = onTarget ? reachedCount + 1 : 0;
43 unreachableCount = targetReachable ? 0 : unreachableCount + 1;
44 }
45
46 bool
48 {
49 const std::scoped_lock lock(mutex);
50
51 return reachedCount >= config.filterCount;
52 }
53
54 bool
56 {
57 const std::scoped_lock lock(mutex);
58
59 return unreachableCount >= config.filterCount;
60 }
61
64 {
65 const std::scoped_lock lock(mutex);
66
67 return latestResidual;
68 }
69
70} // namespace armarx::view_selection::gaze_scheduler
bool unreachable() const
Whether the controller could not reach the target for filterCount consecutive reports.
bool reached() const
Whether the gaze has been on target for filterCount consecutive reports.
void update(std::int64_t targetId, const gaze_controller::GazeResidual &residual, bool targetReachable)
Feed one controller report. Reports about a different target are ignored.
void reset(std::int64_t targetId)
Begin monitoring another control target, dropping all state about the previous one.
gaze_controller::GazeResidual residual() const
Residual of the most recently accepted report.
How far the gaze currently is from a target.
Thresholds deciding when the gaze counts as fixed on the active target.