GazeController.h
Go to the documentation of this file.
1 
2 /*
3  * This file is part of ArmarX.
4  *
5  * ArmarX is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * ArmarX is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * @package view_selection
18  * @author Johann Mantel
19  * @date 2020
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <mutex>
27 
28 #include <VirtualRobot/VirtualRobot.h>
29 
32 
33 #include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
34 #include <armarx/view_selection/gaze_controller/hemisphere/aron/ControllerConfig.aron.generated.h>
37 
38 namespace armarx
39 {
40  class ControlTarget1DoFActuatorPosition;
41 }
42 
44 {
45  TYPEDEF_PTRS_HANDLE(GazeController);
46 
47  struct Params
48  {
49  std::string yawNodeName;
50  std::string pitchNodeName;
51  std::string cameraNodeName;
52  };
53 
54  struct Config
55  {
57  std::optional<armarx::view_selection::gaze_controller::Target> target;
58  };
59 
60  /**
61  * @defgroup Component-GazeControl GazeControl
62  * @ingroup ActiveVision-Components
63  * A description of the component GazeControl.
64  *
65  * @class GazeControl
66  * @ingroup Component-GazeControl
67  * @brief Brief description of class GazeControl.
68  *
69  * Detailed description of class GazeControl.
70  */
72  virtual public NJointControllerWithTripleBuffer<Config>,
73  virtual public armarx::control::ConfigurableNJointControllerInterface
74  {
75  public:
76  using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
77 
78  GazeController(RobotUnitPtr robotUnit,
79  const NJointControllerConfigPtr& config,
80  const VirtualRobot::RobotPtr& robot);
81 
82  ~GazeController() override;
83 
85  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
86 
88  getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override;
89 
90  protected:
91  // NJointControllerInterface interface
92  void onInitNJointController() override;
93 
94  // NJointControllerInterface interface
95  void onConnectNJointController() override;
96 
97  // NJointControllerInterface interface
98  std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
99 
100  // NJointController interface
101  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
102  const IceUtil::Time& timeSinceLastIteration) override;
103 
104  // NJointController interface
105  void onPublish(const SensorAndControl&,
107  const DebugObserverInterfacePrx&) override;
108 
109  void rtPreActivateController() override;
110  void rtPostDeactivateController() override;
111 
112  private:
113  // void publishTarget(const armarx::view_selection::gaze_targets::GazeTarget& target);
114  void removeTarget();
115 
116  // rt variables
117  VirtualRobot::RobotPtr _rtRobot;
118  VirtualRobot::RobotNodePtr _rtYawNode;
119  VirtualRobot::RobotNodePtr _rtPitchNode;
120  VirtualRobot::RobotNodePtr _rtCameraNode;
121  // VirtualRobot::RobotNodePtr _rtTorsoNode;
122 
123  armarx::ControlTarget1DoFActuatorPosition* _rtPitchCtrlTarget;
124  armarx::ControlTarget1DoFActuatorPosition* _rtYawCtrlTarget;
125  float* _rtPitchCtrlPos;
126  float* _rtYawCtrlPos;
127 
128  // publishing
129  mutable std::recursive_mutex _tripRt2NonRtMutex;
131 
132  std::atomic<float> _publishCurrentPitchAngle = 0.0;
133  std::atomic<float> _publishCurrentYawAngle = 0.0;
134  std::atomic<float> _publishTargetPitchAngle = 0.0;
135  std::atomic<float> _publishTargetYawAngle = 0.0;
136  };
137 } // namespace armarx::view_selection::gaze_controller::atan2
armarx::view_selection::gaze_controller::atan2::GazeController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: GazeController.cpp:170
NJointControllerWithTripleBuffer.h
armarx::view_selection::gaze_controller::atan2::GazeController
Definition: GazeController.h:71
NJointControllerBase.h
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::view_selection::gaze_controller::atan2::Params
Definition: GazeController.h:47
armarx::view_selection::gaze_controller::atan2::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(GazeController)
armarx::view_selection::gaze_controller::atan2::Config::params
Params params
Definition: GazeController.h:56
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::view_selection::gaze_controller::atan2::GazeController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: GazeController.cpp:100
types.h
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
armarx::view_selection::gaze_controller::atan2::GazeController::GazeController
GazeController(RobotUnitPtr robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &robot)
Definition: GazeController.cpp:29
armarx::view_selection::gaze_controller::atan2
This file is part of ArmarX.
Definition: aron_conversions.cpp:28
armarx::view_selection::gaze_controller::atan2::GazeController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: GazeController.cpp:165
armarx::view_selection::gaze_controller::atan2::GazeController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: GazeController.cpp:76
armarx::view_selection::gaze_controller::atan2::Config
Definition: GazeController.h:54
armarx::view_selection::gaze_controller::atan2::Params::pitchNodeName
std::string pitchNodeName
Definition: GazeController.h:50
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::view_selection::gaze_controller::atan2::GazeController::onConnectNJointController
void onConnectNJointController() override
Definition: GazeController.cpp:95
armarx::view_selection::gaze_controller::atan2::GazeController::~GazeController
~GazeController() override
armarx::view_selection::gaze_controller::atan2::Params::cameraNodeName
std::string cameraNodeName
Definition: GazeController.h:51
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
IceUtil::Handle< class RobotUnit >
armarx::view_selection::gaze_controller::atan2::GazeController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current &=::Ice::emptyCurrent) override
Definition: GazeController.cpp:199
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::view_selection::gaze_controller::atan2::Params::yawNodeName
std::string yawNodeName
Definition: GazeController.h:49
armarx::view_selection::gaze_controller::atan2::GazeController::onInitNJointController
void onInitNJointController() override
Definition: GazeController.cpp:90
armarx::view_selection::gaze_controller::atan2::GazeController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: GazeController.cpp:175
GazeTarget.h
armarx::view_selection::gaze_controller::atan2::GazeController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: GazeController.cpp:106
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::view_selection::gaze_controller::atan2::Config::target
std::optional< armarx::view_selection::gaze_controller::Target > target
Definition: GazeController.h:57
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::TripleBuffer< armarx::view_selection::gaze_targets::GazeTarget >