GazeController.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <mutex>
5#include <optional>
6#include <string>
7
8#include <Ice/Current.h>
9#include <Ice/Object.h>
10#include <IceUtil/Time.h>
11
12#include <VirtualRobot/VirtualRobot.h>
13
16
19#include <RobotAPI/interface/aron/Aron.h>
20#include <RobotAPI/interface/units/RobotUnit/NJointController.h>
21
22#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
25
26namespace armarx
27{
28 class ControlTarget1DoFActuatorPosition;
29}
30
32{
34
35 struct Params
36 {
37 std::string yawNodeName;
38 std::string pitchNodeName;
39 std::string cameraNodeName;
40 std::string gazeRootNodeName;
41 };
42
48
49 /**
50 * @defgroup Component-GazeControl GazeControl
51 * @ingroup ActiveVision-Components
52 * A description of the component GazeControl.
53 *
54 * @class GazeControl
55 * @ingroup Component-GazeControl
56 * @brief Brief description of class GazeControl.
57 *
58 * Detailed description of class GazeControl.
59 */
61 virtual public NJointControllerWithTripleBuffer<Config>,
62 virtual public armarx::control::ConfigurableNJointControllerInterface
63 {
64 public:
65 using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
66
68 const NJointControllerConfigPtr& config,
69 const VirtualRobot::RobotPtr& robot);
70
71 ~GazeController() override;
72
73 void updateConfig(const ::armarx::aron::data::dto::DictPtr& dto,
74 const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
75
77 getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override;
78
79 protected:
80 // NJointControllerInterface interface
81 void onInitNJointController() override;
82
83 // NJointControllerInterface interface
84 void onConnectNJointController() override;
85
86 // NJointControllerInterface interface
87 std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
88
89 // NJointController interface
90 void rtRun(const IceUtil::Time& sensorValuesTimestamp,
91 const IceUtil::Time& timeSinceLastIteration) override;
92
93 // NJointController interface
94 void onPublish(const SensorAndControl&,
96 const DebugObserverInterfacePrx&) override;
97
98 void rtPreActivateController() override;
99 void rtPostDeactivateController() override;
100
101 private:
102 // void publishTarget(const armarx::view_selection::gaze_targets::GazeTarget& target);
103 void removeTarget();
104
105 // rt variables
106 VirtualRobot::RobotPtr _rtRobot;
107 std::string _rtGazeNodeName;
108 VirtualRobot::RobotNodePtr _rtYawNode;
109 VirtualRobot::RobotNodePtr _rtPitchNode;
110 VirtualRobot::RobotNodePtr _rtCameraNode;
111 // VirtualRobot::RobotNodePtr _rtTorsoNode;
112
113 armarx::ControlTarget1DoFActuatorPosition* _rtPitchCtrlTarget;
114 armarx::ControlTarget1DoFActuatorPosition* _rtYawCtrlTarget;
115 float* _rtPitchCtrlPos;
116 float* _rtYawCtrlPos;
117
118 // publishing
119 mutable std::recursive_mutex _tripRt2NonRtMutex;
121
122 std::atomic<float> _publishCurrentPitchAngle = 0.0;
123 std::atomic<float> _publishCurrentYawAngle = 0.0;
124 std::atomic<float> _publishTargetPitchAngle = 0.0;
125 std::atomic<float> _publishTargetYawAngle = 0.0;
126 };
127} // namespace armarx::view_selection::gaze_controller::atan2
#define TYPEDEF_PTRS_HANDLE(T)
NJointControllerWithTripleBuffer(const Config &initialCommands=Config())
A simple triple buffer for lockfree comunication between a single writer and a single reader.
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current &=::Ice::emptyCurrent) override
GazeController(RobotUnitPtr robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &robot)
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
void rtPreActivateController() override
This function is called before the controller is activated.
control::ConfigurableNJointControllerConfigPtr ConfigPtrT
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::Handle< Dict > DictPtr
::armarx::view_selection::gaze_targets::GazeTarget Target
Definition types.h:8
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl
armarx::view_selection::gaze_controller::Target target