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 Config
48  {
50  std::optional<armarx::view_selection::gaze_controller::Target> target;
51  };
52 
53  /**
54  * @defgroup Component-GazeControl GazeControl
55  * @ingroup ActiveVision-Components
56  * A description of the component GazeControl.
57  *
58  * @class GazeControl
59  * @ingroup Component-GazeControl
60  * @brief Brief description of class GazeControl.
61  *
62  * Detailed description of class GazeControl.
63  */
65  virtual public NJointControllerWithTripleBuffer<Config>,
66  virtual public armarx::control::ConfigurableNJointControllerInterface
67  {
68  public:
69  using ConfigPtrT = control::ConfigurableNJointControllerConfigPtr;
70 
71  GazeController(RobotUnitPtr robotUnit,
72  const NJointControllerConfigPtr& config,
73  const VirtualRobot::RobotPtr& robot);
74 
75  ~GazeController() override;
76 
78  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
79 
81  getConfig(const ::Ice::Current& = ::Ice::emptyCurrent) override;
82 
83  protected:
84  // NJointControllerInterface interface
85  void onInitNJointController() override;
86 
87  // NJointControllerInterface interface
88  void onConnectNJointController() override;
89 
90  // NJointControllerInterface interface
91  std::string getClassName(const Ice::Current& = Ice::emptyCurrent) const override;
92 
93  // NJointController interface
94  void rtRun(const IceUtil::Time& sensorValuesTimestamp,
95  const IceUtil::Time& timeSinceLastIteration) override;
96 
97  // NJointController interface
98  void onPublish(const SensorAndControl&,
100  const DebugObserverInterfacePrx&) override;
101 
102  void rtPreActivateController() override;
103  void rtPostDeactivateController() override;
104 
105  private:
106  // void publishTarget(const armarx::view_selection::gaze_targets::GazeTarget& target);
107  void removeTarget();
108 
109  // rt variables
110  VirtualRobot::RobotPtr _rtRobot;
111  std::string _rtGazeNodeName;
112  VirtualRobot::RobotNodePtr _rtGazeNode;
113  VirtualRobot::RobotNodePtr _rtYawNode;
114  VirtualRobot::RobotNodePtr _rtHemiANode;
115  VirtualRobot::RobotNodePtr _rtHemiBNode;
116  VirtualRobot::RobotNodePtr _rtCameraNode;
117  // VirtualRobot::RobotNodePtr _rtTorsoNode;
118 
119  // armarx::ControlTarget1DoFActuatorPosition* _rtPitchCtrlTarget;
120  armarx::ControlTarget1DoFActuatorPosition* _rtYawCtrlTarget;
121  armarx::ControlTarget1DoFActuatorPosition* _rtHemiACtrlTarget;
122  armarx::ControlTarget1DoFActuatorPosition* _rtHemiBCtrlTarget;
123 
124 
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  std::atomic<float> _publishPlatformOrientation = 0.0;
137  };
138 } // namespace armarx::view_selection::gaze_controller::hemisphere
armarx::view_selection::gaze_controller::hemisphere::Config
Definition: GazeController.h:47
NJointControllerWithTripleBuffer.h
NJointControllerBase.h
armarx::view_selection::gaze_controller::hemisphere::GazeController::rtPreActivateController
void rtPreActivateController() override
This function is called before the controller is activated.
Definition: GazeController.cpp:205
armarx::NJointControllerWithTripleBuffer
Definition: NJointControllerWithTripleBuffer.h:10
armarx::view_selection::gaze_controller::hemisphere::GazeController::updateConfig
void updateConfig(const ::armarx::aron::data::dto::DictPtr &dto, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: GazeController.cpp:84
armarx::NJointControllerBase::ConfigPtrT
NJointControllerConfigPtr ConfigPtrT
Definition: NJointControllerBase.h:587
armarx::view_selection::gaze_controller::hemisphere::GazeController::~GazeController
~GazeController() override
httplib::Params
std::multimap< std::string, std::string > Params
Definition: httplib.h:510
armarx::view_selection::gaze_controller::hemisphere::Config::params
arondto::Params params
Definition: GazeController.h:49
types.h
armarx::view_selection::gaze_controller::hemisphere::GazeController::rtPostDeactivateController
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
Definition: GazeController.cpp:211
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:182
armarx::view_selection::gaze_controller::hemisphere::GazeController::onConnectNJointController
void onConnectNJointController() override
Definition: GazeController.cpp:104
armarx::view_selection::gaze_controller::hemisphere::GazeController::getConfig
::armarx::aron::data::dto::DictPtr getConfig(const ::Ice::Current &=::Ice::emptyCurrent) override
Definition: GazeController.cpp:242
armarx::view_selection::gaze_controller::hemisphere::GazeController::onPublish
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
Definition: GazeController.cpp:217
armarx::view_selection::gaze_controller::hemisphere::GazeController::rtRun
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
Definition: GazeController.cpp:117
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::view_selection::gaze_controller::hemisphere::GazeController::getClassName
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
Definition: GazeController.cpp:110
armarx::view_selection::gaze_controller::hemisphere::GazeController
Definition: GazeController.h:64
armarx::view_selection::gaze_controller::hemisphere::GazeController::onInitNJointController
void onInitNJointController() override
Definition: GazeController.cpp:98
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::view_selection::gaze_controller::hemisphere
This file is part of ArmarX.
Definition: aron_conversions.cpp:29
IceUtil::Handle< class RobotUnit >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::view_selection::gaze_controller::hemisphere::GazeController::GazeController
GazeController(RobotUnitPtr robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &robot)
Definition: GazeController.cpp:29
GazeTarget.h
armarx::view_selection::gaze_controller::hemisphere::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(GazeController)
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::view_selection::gaze_controller::hemisphere::Config::target
std::optional< armarx::view_selection::gaze_controller::Target > target
Definition: GazeController.h:50
armarx::TripleBuffer< armarx::view_selection::gaze_targets::GazeTarget >