status_reporting.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <cstdint>
5#include <mutex>
6#include <string>
7
9
10#include <armarx/view_selection/gaze_controller/ice/GazeControllerStatus.h>
12
14{
15
16 /**
17 * @brief Collects the gaze residual on the control side and reports it on a topic.
18 *
19 * Shared by both controller variants, which differ only in where they can compute the residual:
20 * `atan2` does it in rtRun, `gaze_ik` in its non-RT IK task. Both hand it over through atomics.
21 *
22 * The controller deliberately does not decide whether the gaze counts as fixed on the target --
23 * it only says how far off it is. The gaze scheduler applies the thresholds, since it is the
24 * part that knows which target is active and who asked for it. That is also why nothing here
25 * touches the memory: this runs inside the RobotUnit.
26 */
28 {
29 public:
30 /// Called from the control side, at whatever rate it computes the residual.
31 void update(std::int64_t targetId, const GazeResidual& residual, bool targetReachable);
32
33 /// Called from updateConfig(), so a report can name the target it is about.
34 void setTarget(std::int64_t targetId, const std::string& targetName);
35
36 /**
37 * @brief Publishes the current residual, rate limited. Call from onPublish().
38 *
39 * @param topic May be null before the controller is connected; then nothing is sent.
40 */
41 void report(const GazeControllerStatusListenerPrx& topic);
42
43 private:
44 std::atomic<std::int64_t> targetId = -1;
45
46 std::atomic<float> angularError = 0.F;
47
48 std::atomic<float> lateralError = 0.F;
49
50 std::atomic<bool> targetReachable = true;
51
52 std::mutex targetNameMutex;
53
54 std::int64_t targetNameId = -1;
55
56 std::string targetName;
57
59 };
60
61} // namespace armarx::view_selection::gaze_controller
static DateTime Invalid()
Definition DateTime.cpp:57
Represents a point in time.
Definition DateTime.h:25
Collects the gaze residual on the control side and reports it on a topic.
void report(const GazeControllerStatusListenerPrx &topic)
Publishes the current residual, rate limited.
void update(std::int64_t targetId, const GazeResidual &residual, bool targetReachable)
Called from the control side, at whatever rate it computes the residual.
void setTarget(std::int64_t targetId, const std::string &targetName)
Called from updateConfig(), so a report can name the target it is about.
How far the gaze currently is from a target.