NJointKinematicUnitPassThroughController.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotAPI::ArmarXObjects::NJointKinematicUnitPassThroughController
17 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <atomic>
26
27#include <VirtualRobot/VirtualRobot.h>
28
30
34
35namespace armarx
36{
38
39 class NJointKinematicUnitPassThroughControllerConfig : virtual public NJointControllerConfig
40 {
41 public:
42 std::string deviceName;
43 std::string controlMode;
44 };
45
47
48 /**
49 * @brief The NJointKinematicUnitPassThroughController class
50 * @ingroup Library-RobotUnit-NJointControllers
51 */
53 {
54 public:
55 using ConfigPtrT = NJointKinematicUnitPassThroughControllerConfigPtr;
56
58 RobotUnit* prov,
59 const NJointKinematicUnitPassThroughControllerConfigPtr& cfg,
61
62 inline void
63 rtRun(const IceUtil::Time&, const IceUtil::Time&) override
64 {
65 target.setValue(control);
66 }
67
68 inline void
70 {
71 }
72
73 void
75 {
77 if (std::abs(control) < resetZeroThreshold)
78 {
79 control = 0;
80 }
81 }
82
83 //ice interface
84 inline std::string
85 getClassName(const Ice::Current& = Ice::emptyCurrent) const override
86 {
87 return "NJointKinematicUnitPassThroughController";
88 }
89
90 void
91 set(float val)
92 {
93 control = val;
94 }
95
96 protected:
97 std::atomic<float> control{0};
98
99 template <bool ConstPtr>
101 {
102 float
103 getValue() const
104 {
105 if (_float)
106 {
107 return *_float;
108 }
109 return *_int16;
110 }
111
112 template <bool constPtr = ConstPtr, std::enable_if_t<!constPtr, int> = 0>
113 void
114 setValue(float val)
115 {
116 if (_float)
117 {
118 *_float = val;
119 }
120 else
121 {
122 *_int16 = static_cast<std::int16_t>(val);
123 }
124 }
125 template <class T>
126 using maybe_const_ptr = std::conditional_t<ConstPtr, const T*, T*>;
129 };
130
135 };
136} // namespace armarx
#define TYPEDEF_PTRS_HANDLE(T)
The NJointKinematicUnitPassThroughController class.
std::string getClassName(const Ice::Current &=Ice::emptyCurrent) const override
void rtRun(const IceUtil::Time &, const IceUtil::Time &) override
TODO make protected and use attorneys.
NJointKinematicUnitPassThroughController(RobotUnit *prov, const NJointKinematicUnitPassThroughControllerConfigPtr &cfg, const VirtualRobot::RobotPtr &)
void rtPreActivateController() override
This function is called before the controller is activated.
NJointKinematicUnitPassThroughControllerConfigPtr ConfigPtrT
The RobotUnit class manages a robot and its controllers.
Definition RobotUnit.h:192
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
SynchronousNJointController NJointController
This file is part of ArmarX.