RobotUnitModuleUnits.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::RobotUnit
17 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
26#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
27
29#include "RobotUnitModuleBase.h"
30
32{
34 {
35 public:
37 {
39 "KinematicUnitName", "KinematicUnit", "The name of the created kinematic unit");
41 "KinematicUnitNameTopicPrefix", "", "Prefix for the kinematic sensor values topic");
42
44 "DiagnosticsUnitName", "DiagnosticsUnit", "Name of the diagnostics unit.");
45
47 "PlatformUnitName", "PlatformUnit", "The name of the created platform unit");
48
50 "PlatformUnitVelocityControllerType",
52 "Which controller to use for velocity control of the platform");
53 for (const auto& [type, name] :
55 {
56 types.map(name, type);
57 }
58
60 "PlatformUnitMaximumPositionAcceleration",
61 800,
62 "The maximum allowed acceleration for the position of the platform");
64 "PlatformUnitMaximumOrientationAcceleration",
65 80,
66 "The maximum allowed acceleration for the orientation of the platform");
67
69 "ForceTorqueUnitName",
70 "ForceTorqueUnit",
71 "The name of the created force troque unit (empty = default)");
73 "ForceTorqueTopicName",
74 "ForceTorqueValues",
75 "Name of the topic on which the force torque sensor values are provided");
76
78 "InertialMeasurementUnitName",
79 "InertialMeasurementUnit",
80 "The name of the created inertial measurement unit (empty = default)");
82 "IMUTopicName", "IMUValues", "Name of the IMU Topic.");
83
84 defineOptionalProperty<bool>("CreateTCPControlUnit",
85 false,
86 "If true the TCPControl SubUnit is created and added");
88 "TCPControlUnitName", "TCPControlUnit", "Name of the TCPControlUnit.");
89
91 "CreateTrajectoryPlayer",
92 true,
93 "If true the TrajectoryPlayer SubUnit is created and added");
95 "TrajectoryControllerUnitName",
96 "TrajectoryPlayer",
97 "Name of the TrajectoryControllerUnit. The respective component outside of the "
98 "RobotUnit is TrajectoryPlayer");
99
101 "EmergencyStopMasterName",
102 "EmergencyStopMaster",
103 "The name used to register as an EmergencyStopMaster");
105 "EmergencyStopTopic",
106 "EmergencyStop",
107 "The name of the topic over which changes of the emergencyStopState are sent.");
108 }
109 };
110
111 /**
112 * @ingroup Library-RobotUnit-Modules
113 * @brief This \ref ModuleBase "Module" manages all Units of a \ref RobotUnit
114 *
115 * These are the managed Units:
116 * - \ref getKinematicUnit "KinematicUnit"
117 * - \ref getForceTorqueUnit "ForceTorqueUnit"
118 * - \ref getInertialMeasurementUnit "InertialMeasurementUnit"
119 * - \ref getPlatformUnit "PlatformUnit"
120 * - \ref getTCPControlUnit "TCPControlUnit"
121 * - \ref getTrajectoryPlayer "TrajectoryPlayer"
122 *
123 * @see ModuleBase
124 */
125 class Units : virtual public ModuleBase, virtual public RobotUnitUnitInterface
126 {
127 friend class ModuleBase;
128
129 public:
130 /**
131 * @brief Returns the singleton instance of this class
132 * @return The singleton instance of this class
133 */
134 static Units& Instance();
135 // //////////////////////////////////////////////////////////////////////////////////////// //
136 // ///////////////////////////////// RobotUnitModule hooks //////////////////////////////// //
137 // //////////////////////////////////////////////////////////////////////////////////////// //
138 private:
139 /// @see ModuleBase::_preOnInitRobotUnit
140 void _preOnInitRobotUnit();
141 /// @see ModuleBase::_icePropertiesInitialized
142 void _icePropertiesInitialized();
143 /// @see ModuleBase::_preFinishRunning
144 void _preFinishRunning();
145 /// @see ModuleBase::_postOnExitRobotUnit
146 void _postOnExitRobotUnit();
147 // //////////////////////////////////////////////////////////////////////////////////////// //
148 // ///////////////////////////////////// ice interface //////////////////////////////////// //
149 // //////////////////////////////////////////////////////////////////////////////////////// //
150 public:
151 /**
152 * @brief Returns proxies to all units
153 * @return Proxies to all units
154 */
155 Ice::ObjectProxySeq getUnits(const Ice::Current&) const override;
156 /**
157 * @brief Returns a proxy to the Unit with the given ice id (or null if there is none)
158 * @param staticIceId The Unit's ice id
159 * @return A proxy to the Unit with the given ice id (or null if there is none)
160 */
161 Ice::ObjectPrx getUnit(const std::string& staticIceId, const Ice::Current&) const override;
162
163 /**
164 * @brief Returns a proxy to the KinematicUnit
165 * @return A proxy to the KinematicUnit
166 */
167 KinematicUnitInterfacePrx getKinematicUnit(const Ice::Current&) const override;
168 /**
169 * @brief Returns a proxy to the ForceTorqueUnit
170 * @return A proxy to the ForceTorqueUnit
171 */
172 ForceTorqueUnitInterfacePrx getForceTorqueUnit(const Ice::Current&) const override;
173 /**
174 * @brief Returns a proxy to the InertialMeasurementUnit
175 * @return A proxy to the InertialMeasurementUnit
176 */
177 InertialMeasurementUnitInterfacePrx
178 getInertialMeasurementUnit(const Ice::Current&) const override;
179 /**
180 * @brief Returns a proxy to the PlatformUnit
181 * @return A proxy to the PlatformUnit
182 */
183 PlatformUnitInterfacePrx getPlatformUnit(const Ice::Current&) const override;
184 /**
185 * @brief Returns a proxy to the TCPControlUnit
186 * @return A proxy to the TCPControlUnit
187 */
188 TCPControlUnitInterfacePrx getTCPControlUnit(const Ice::Current&) const override;
189 /**
190 * @brief Returns a proxy to the TrajectoryPlayer
191 * @return A proxy to the TrajectoryPlayer
192 */
193 TrajectoryPlayerInterfacePrx getTrajectoryPlayer(const Ice::Current&) const override;
194 // //////////////////////////////////////////////////////////////////////////////////////// //
195 // /////////////////////////////////// Module interface /////////////////////////////////// //
196 // //////////////////////////////////////////////////////////////////////////////////////// //
197 public:
198 //general getters
199 /**
200 * @brief Returns a pointer to the Unit with the given ice id (or null if there is none)
201 * @param staticIceId The Unit's ice id
202 * @return A pointer to the Unit with the given ice id (or null if there is none)
203 */
204 const ManagedIceObjectPtr& getUnit(const std::string& staticIceId) const;
205
206 /**
207 * @brief Returns a pointer to the Unit for the given type (or null if there is none)
208 * @return A pointer to the Unit for the given type (or null if there is none)
209 */
210 template <class T>
211 typename T::PointerType getUnit() const;
212 /**
213 * @brief Returns a proxy to the Unit for the given type (or null if there is none)
214 * @return A proxy to the Unit for the given type (or null if there is none)
215 */
216 template <class T>
217 typename T::ProxyType getUnitPrx() const;
218
219 //specific getters
220 /**
221 * @brief Returns a pointer to the KinematicUnit
222 * @return A pointer to the KinematicUnit
223 */
224 KinematicUnitInterfacePtr getKinematicUnit() const;
225 /**
226 * @brief Returns a pointer to the ForceTorqueUnit
227 * @return A pointer to the ForceTorqueUnit
228 */
229 ForceTorqueUnitInterfacePtr getForceTorqueUnit() const;
230 /**
231 * @brief Returns a pointer to the InertialMeasurementUnit
232 * @return A pointer to the InertialMeasurementUnit
233 */
234 InertialMeasurementUnitInterfacePtr getInertialMeasurementUnit() const;
235 /**
236 * @brief Returns a pointer to the PlatformUnit
237 * @return A pointer to the PlatformUnit
238 */
239 PlatformUnitInterfacePtr getPlatformUnit() const;
240 /**
241 * @brief Returns a pointer to the TCPControlUnit
242 * @return A pointer to the TCPControlUnit
243 */
244 TCPControlUnitInterfacePtr getTCPControlUnit() const;
245 /**
246 * @brief Returns a pointer to the TrajectoryPlayer
247 * @return A pointer to the TrajectoryPlayer
248 */
249 TrajectoryPlayerInterfacePtr getTrajectoryPlayer() const;
250 /**
251 * @brief Returns a pointer to the EmergencyStopMaster
252 * @return A pointer to the EmergencyStopMaster
253 */
254 const EmergencyStopMasterInterfacePtr& getEmergencyStopMaster() const;
255 // //////////////////////////////////////////////////////////////////////////////////////// //
256 // //////////////////////////////////// implementation //////////////////////////////////// //
257 // //////////////////////////////////////////////////////////////////////////////////////// //
258 protected:
259 /**
260 * @brief Calls all init hooks for all managed Units
261 *
262 * The called hooks are
263 * - \ref initializeKinematicUnit
264 * - \ref initializePlatformUnit
265 * - \ref initializeForceTorqueUnit
266 * - \ref initializeInertialMeasurementUnit
267 * - \ref initializeTrajectoryControllerUnit
268 * - \ref initializeTcpControllerUnit
269 */
270 virtual void initializeDefaultUnits();
271 /// @brief Initialize the diagnostics unit.
272 virtual void initializeDiagnosticsUnit();
273 /// @brief Initializes the KinematicUnit
274 virtual void initializeKinematicUnit();
275 /// @brief Initializes the PlatformUnit
276 virtual void initializePlatformUnit();
277 /// @brief Initializes the ForceTorqueUnit
278 virtual void initializeForceTorqueUnit();
279 /// @brief Initializes the InertialMeasurementUnit
281 /// @brief Initializes the TrajectoryControllerUnit
283 /// @brief Initializes the TcpControllerUnit
284 virtual void initializeTcpControllerUnit();
285 /// @brief Initializes the TcpControllerUnit
286 virtual void initializeLocalizationUnit();
287 /// @brief Create the \ref KinematicUnit (this function should be called in \ref initializeKinematicUnit)
290 const std::string& positionControlMode = ControlModes::Position1DoF,
291 const std::string& velocityControlMode = ControlModes::Velocity1DoF,
292 const std::string& torqueControlMode = ControlModes::Torque1DoF,
293 const std::string& pwmControlMode = ControlModes::PWM1DoF);
294 /**
295 * @brief Registers a unit for management (the Unit is added and removed to the \ref ArmarXManager
296 * and updated with new values.
297 * @param unit The Unit to add.
298 */
299 void addUnit(ManagedIceObjectPtr unit);
300 // //////////////////////////////////////////////////////////////////////////////////////// //
301 // ///////////////////////////////////////// Data ///////////////////////////////////////// //
302 // //////////////////////////////////////////////////////////////////////////////////////// //
303 private:
304 /// @brief holds all units managed by the RobotUnit
305 std::vector<ManagedIceObjectPtr> units;
306 /// @brief holds a copy of all units managed by the RobotUnit derived from RobotUnitSubUnit
307 /// this is done to prevent casting
308 std::vector<RobotUnitSubUnitPtr> subUnits;
309
310 /// @brief Pointer to the EmergencyStopMaster used by the \ref RobotUnit
311 EmergencyStopMasterInterfacePtr emergencyStopMaster;
312
313 /// @brief Temporary ptr to the TCPControlUnit
314 ManagedIceObjectPtr tcpControllerSubUnit;
315 /// @brief Temporary ptr to the TrajectoryPlayer
316 ManagedIceObjectPtr trajectoryControllerSubUnit;
317
318 /// @brief A copy of the VirtualRobot to be used inside of this Module
319 VirtualRobot::RobotPtr unitCreateRobot;
320 // //////////////////////////////////////////////////////////////////////////////////////// //
321 // /////////////////////////////////////// Attorneys ////////////////////////////////////// //
322 // //////////////////////////////////////////////////////////////////////////////////////// //
323 private:
324 /**
325 * \brief This class allows minimal access to private members of \ref Units in a sane fashion for \ref Publisher.
326 * \warning !! DO NOT ADD ADDITIONAL FRIENDS IF YOU DO NOT KNOW WAHT YOU ARE DOING! IF YOU DO SOMETHING WRONG YOU WILL CAUSE UNDEFINED BEHAVIOUR !!
327 */
329 };
330} // namespace armarx::RobotUnitModule
331
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This Module manages all Units of a RobotUnit.
virtual void initializeForceTorqueUnit()
Initializes the ForceTorqueUnit.
TCPControlUnitInterfacePtr getTCPControlUnit() const
Returns a pointer to the TCPControlUnit.
T::PointerType getUnit() const
Returns a pointer to the Unit for the given type (or null if there is none)
InertialMeasurementUnitInterfacePtr getInertialMeasurementUnit() const
Returns a pointer to the InertialMeasurementUnit.
virtual void initializeTrajectoryControllerUnit()
Initializes the TrajectoryControllerUnit.
void addUnit(ManagedIceObjectPtr unit)
Registers a unit for management (the Unit is added and removed to the ArmarXManager and updated with ...
virtual void initializeDiagnosticsUnit()
Initialize the diagnostics unit.
virtual void initializeTcpControllerUnit()
Initializes the TcpControllerUnit.
virtual void initializeInertialMeasurementUnit()
Initializes the InertialMeasurementUnit.
friend class UnitsAttorneyForPublisher
This class allows minimal access to private members of Units in a sane fashion for Publisher.
ForceTorqueUnitInterfacePtr getForceTorqueUnit() const
Returns a pointer to the ForceTorqueUnit.
virtual void initializePlatformUnit()
Initializes the PlatformUnit.
virtual void initializeLocalizationUnit()
Initializes the TcpControllerUnit.
virtual void initializeDefaultUnits()
Calls all init hooks for all managed Units.
T::ProxyType getUnitPrx() const
Returns a proxy to the Unit for the given type (or null if there is none)
TrajectoryPlayerInterfacePtr getTrajectoryPlayer() const
Returns a pointer to the TrajectoryPlayer.
static Units & Instance()
Returns the singleton instance of this class.
ManagedIceObjectPtr createKinematicSubUnit(const Ice::PropertiesPtr &properties, const std::string &positionControlMode=ControlModes::Position1DoF, const std::string &velocityControlMode=ControlModes::Velocity1DoF, const std::string &torqueControlMode=ControlModes::Torque1DoF, const std::string &pwmControlMode=ControlModes::PWM1DoF)
Create the KinematicUnit (this function should be called in initializeKinematicUnit)
KinematicUnitInterfacePtr getKinematicUnit() const
Returns a pointer to the KinematicUnit.
Ice::ObjectProxySeq getUnits(const Ice::Current &) const override
Returns proxies to all units.
PlatformUnitInterfacePtr getPlatformUnit() const
Returns a pointer to the PlatformUnit.
virtual void initializeKinematicUnit()
Initializes the KinematicUnit.
const EmergencyStopMasterInterfacePtr & getEmergencyStopMaster() const
Returns a pointer to the EmergencyStopMaster.
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
const simox::meta::EnumNames< NJointHolonomicPlatformVelocityControllerTypes > NJointHolonomicPlatformVelocityControllerTypesNames
IceInternal::Handle< ManagedIceObject > ManagedIceObjectPtr
Definition ArmarXFwd.h:42