TCPControllerSubUnit.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::TCPControllerSubUnit
17  * @author Stefan Reither ( stef dot reither at web dot de )
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 <mutex>
26 
28 
29 #include <RobotAPI/interface/units/TCPControlUnit.h>
30 
31 #include "../NJointControllers/NJointTCPController.h"
32 #include "../util.h"
33 #include "RobotUnitSubUnit.h"
34 
35 namespace armarx
36 {
37  TYPEDEF_PTRS_HANDLE(RobotUnit);
38 
40  {
41  public:
44  {
45  defineOptionalProperty<float>(
46  "AvoidJointLimitsKp",
47  1.f,
48  "Proportional gain value of P-Controller for joint limit avoidance",
50  }
51  };
52 
53  TYPEDEF_PTRS_HANDLE(TCPControllerSubUnit);
54 
56  virtual public RobotUnitSubUnit,
57  virtual public TCPControlUnitInterface,
58  virtual public Component
59  {
60  public:
61  void setup(RobotUnit* rUnit, VirtualRobot::RobotPtr robot);
62 
63  // TCPControlUnitInterface interface
64  void setCycleTime(Ice::Int milliseconds,
65  const Ice::Current& c = Ice::emptyCurrent) override;
66  void setTCPVelocity(const std::string& nodeSetName,
67  const std::string& tcpName,
68  const ::armarx::FramedDirectionBasePtr& translationVelocity,
69  const ::armarx::FramedDirectionBasePtr& orientationVelocityRPY,
70  const Ice::Current& c = Ice::emptyCurrent) override;
71  bool isRequested(const Ice::Current& = Ice::emptyCurrent) override;
72 
73  // RobotUnitSubUnit interface
74  void update(const SensorAndControl& sc, const JointAndNJointControllers& c) override;
75 
76  private:
77  mutable std::mutex dataMutex;
78  RobotUnit* robotUnit = nullptr;
79  VirtualRobot::RobotPtr coordinateTransformationRobot;
80  std::map<std::string, std::string> tcpControllerNameMap;
81 
82  // ManagedIceObject interface
83  protected:
84  void
85  onInitComponent() override
86  {
87  }
88 
89  void
90  onConnectComponent() override
91  {
92  }
93 
94  std::string
95  getDefaultName() const override
96  {
97  return "TCPControlUnit";
98  }
99 
101 
102  // UnitResourceManagementInterface interface
103  public:
104  void
105  request(const Ice::Current&) override
106  {
107  }
108 
109  void
110  release(const Ice::Current&) override
111  {
112  }
113 
114  // UnitExecutionManagementInterface interface
115  public:
116  void
117  init(const Ice::Current&) override
118  {
119  }
120 
121  void
122  start(const Ice::Current&) override
123  {
124  }
125 
126  void
127  stop(const Ice::Current&) override
128  {
129  }
130 
131  UnitExecutionState
132  getExecutionState(const Ice::Current&) override
133  {
134  return UnitExecutionState::eUndefinedUnitExecutionState;
135  }
136 
137  // KinematicUnitListener interface
138  public:
139  void
140  reportControlModeChanged(const NameControlModeMap&,
141  Ice::Long,
142  bool,
143  const Ice::Current&) override
144  {
145  }
146 
147  void
148  reportJointAngles(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override
149  {
150  }
151 
152  void
153  reportJointVelocities(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override
154  {
155  }
156 
157  void
158  reportJointTorques(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override
159  {
160  }
161 
162  void
163  reportJointAccelerations(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override
164  {
165  }
166 
167  void
168  reportJointCurrents(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override
169  {
170  }
171 
172  void
174  Ice::Long,
175  bool,
176  const Ice::Current&) override
177  {
178  }
179 
180  void
181  reportJointStatuses(const NameStatusMap&, Ice::Long, bool, const Ice::Current&) override
182  {
183  }
184 
185  // PropertyUser interface
186  public:
187  void componentPropertiesUpdated(const std::set<std::string>& changedProperties) override;
188  };
189 } // namespace armarx
armarx::TCPControllerSubUnit::componentPropertiesUpdated
void componentPropertiesUpdated(const std::set< std::string > &changedProperties) override
Implement this function if you would like to react to changes in the properties.
Definition: TCPControllerSubUnit.cpp:221
armarx::JointAndNJointControllers
Structure used by the RobotUnit to swap lists of Joint and NJoint controllers.
Definition: JointAndNJointControllers.h:32
armarx::TYPEDEF_PTRS_HANDLE
TYPEDEF_PTRS_HANDLE(NJointCartesianNaturalPositionController)
armarx::TCPControllerSubUnit::init
void init(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:117
armarx::TCPControllerSubUnit::reportJointAccelerations
void reportJointAccelerations(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:163
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::RobotUnitSubUnit
Definition: RobotUnitSubUnit.h:35
armarx::TCPControllerSubUnit::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: TCPControllerSubUnit.h:90
armarx::TCPControllerSubUnit::setCycleTime
void setCycleTime(Ice::Int milliseconds, const Ice::Current &c=Ice::emptyCurrent) override
Definition: TCPControllerSubUnit.cpp:59
armarx::detail::ControlThreadOutputBufferEntry
Definition: ControlThreadOutputBuffer.h:177
armarx::TCPControllerSubUnitPropertyDefinitions::TCPControllerSubUnitPropertyDefinitions
TCPControllerSubUnitPropertyDefinitions(std::string prefix)
Definition: TCPControllerSubUnit.h:42
armarx::TCPControllerSubUnit::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: TCPControllerSubUnit.h:95
armarx::TCPControllerSubUnit::reportJointStatuses
void reportJointStatuses(const NameStatusMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:181
armarx::TCPControllerSubUnit::setup
void setup(RobotUnit *rUnit, VirtualRobot::RobotPtr robot)
Definition: TCPControllerSubUnit.cpp:47
armarx::TCPControllerSubUnit::setTCPVelocity
void setTCPVelocity(const std::string &nodeSetName, const std::string &tcpName, const ::armarx::FramedDirectionBasePtr &translationVelocity, const ::armarx::FramedDirectionBasePtr &orientationVelocityRPY, const Ice::Current &c=Ice::emptyCurrent) override
Definition: TCPControllerSubUnit.cpp:66
armarx::TCPControllerSubUnit::stop
void stop(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:127
armarx::TCPControllerSubUnit::reportJointMotorTemperatures
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:173
armarx::TCPControllerSubUnit::reportJointVelocities
void reportJointVelocities(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:153
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
RobotUnitSubUnit.h
armarx::TCPControllerSubUnit::reportJointCurrents
void reportJointCurrents(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:168
armarx::TCPControllerSubUnit::start
void start(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:122
Component.h
armarx::TCPControllerSubUnit::request
void request(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:105
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::TCPControllerSubUnit::reportJointTorques
void reportJointTorques(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:158
armarx::TCPControllerSubUnit::reportControlModeChanged
void reportControlModeChanged(const NameControlModeMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:140
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::TCPControllerSubUnit
Definition: TCPControllerSubUnit.h:55
armarx::TCPControllerSubUnit::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: TCPControllerSubUnit.h:85
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::TCPControllerSubUnit::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: TCPControllerSubUnit.cpp:40
armarx::TCPControllerSubUnitPropertyDefinitions
Definition: TCPControllerSubUnit.h:39
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::RobotUnit
The RobotUnit class manages a robot and its controllers.
Definition: RobotUnit.h:180
armarx::TCPControllerSubUnit::release
void release(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:110
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::TCPControllerSubUnit::update
void update(const SensorAndControl &sc, const JointAndNJointControllers &c) override
Definition: TCPControllerSubUnit.cpp:35
armarx::TCPControllerSubUnit::reportJointAngles
void reportJointAngles(const NameValueMap &, Ice::Long, bool, const Ice::Current &) override
Definition: TCPControllerSubUnit.h:148
armarx::PropertyDefinitionBase::eModifiable
@ eModifiable
Definition: PropertyDefinitionInterface.h:57
armarx::TCPControllerSubUnit::isRequested
bool isRequested(const Ice::Current &=Ice::emptyCurrent) override
Definition: TCPControllerSubUnit.cpp:206
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::TCPControllerSubUnit::getExecutionState
UnitExecutionState getExecutionState(const Ice::Current &) override
Definition: TCPControllerSubUnit.h:132