Go to the documentation of this file.
28 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
30 #include "../Devices/ControlDevice.h"
31 #include "../Devices/RTThreadTimingsSensorDevice.h"
32 #include "../Devices/SensorDevice.h"
33 #include "../SensorValues/SensorValue1DoFActuator.h"
43 defineOptionalProperty<std::string>(
44 "ControlDevices_HardwareControlModeGroups",
46 "Groups of control devices for which the same hardware control mode has to be set. "
47 "For a control mode, the JointControllers of all devices in a group must have the "
48 "identical hardware control mode. "
49 "The kinematic unit will change the control mode of all joints in a group,"
50 " if their current hw control mode does not match the new hw control mode. "
51 "This can be used if the robot has a multi DOF joint which is represented by "
52 "multiple 1DOF control devices "
53 "(in such a case all of these 1DOF joints should have the same hw control mode, "
54 "except he multi DOF joint can handle different control modes at once). "
55 "Syntax: semicolon separated groups , each group is CSV of joints "
56 "e.g. j1,j2;j3,j4,j5 -> Group 1 = j1+j2 Group 2 = j3+j4+j5; No joint may be in two "
81 return ModuleBase::Instance<Devices>();
89 void _preOnInitRobotUnit();
91 void _preFinishDeviceInitialization();
93 void _postFinishDeviceInitialization();
95 void _postFinishRunning();
114 ControlDeviceDescription
116 const Ice::Current& = Ice::emptyCurrent)
const override;
123 ControlDeviceDescriptionSeq
135 const Ice::Current& = Ice::emptyCurrent)
const override;
142 ControlDeviceStatusSeq
158 SensorDeviceDescription
160 const Ice::Current& = Ice::emptyCurrent)
const override;
167 SensorDeviceDescriptionSeq
179 const Ice::Current& = Ice::emptyCurrent)
const override;
186 SensorDeviceStatusSeq
246 template <
class PtrT>
249 const std::vector<PtrT>& sensors)
const
262 template <
class PtrT>
265 const std::vector<VirtualRobot::RobotNodePtr>& nodes,
266 const std::vector<PtrT>& sensors)
const
270 for (
const SimoxRobotSensorValueMapping& m : simoxRobotSensorValueMapping)
274 const SensorValue1DoFActuatorPosition* svPos =
275 sv->
asA<SensorValue1DoFActuatorPosition>();
277 nodes.at(m.idxRobot)->setJointValueNoUpdate(svPos->position);
281 if (globalRobotLocalizationSensorDevice !=
nullptr)
283 const auto sensorValue =
284 globalRobotLocalizationSensorDevice->getSensorValue()
287 robot->setGlobalPose(global_T_root,
false);
290 robot->applyJointValues();
299 const ControlDeviceHardwareControlModeGroups&
302 return ctrlModeGroups;
324 const std::string& deviceName)
const;
331 const std::string& deviceName)
const;
340 return sensorDevices;
350 return controlDevices;
357 const std::map<std::string, ConstSensorDevicePtr>&
360 return sensorDevicesConstPtr;
367 const std::map<std::string, ConstControlDevicePtr>&
370 return controlDevicesConstPtr;
403 return *rtThreadTimingsSensorDevice;
415 std::vector<JointController*> getStopMovementJointControllers()
const;
421 std::vector<JointController*> getEmergencyStopJointControllers()
const;
427 struct SimoxRobotSensorValueMapping
430 std::size_t idxRobot;
436 std::vector<SimoxRobotSensorValueMapping> simoxRobotSensorValueMapping;
438 std::vector<const SensorValueBase*> sensorValues;
440 std::vector<std::vector<PropagateConst<ControlTargetBase*>>> controlTargets;
448 std::vector<std::set<std::string>>
groups;
463 std::map<std::string, ConstControlDevicePtr> controlDevicesConstPtr;
474 std::map<std::string, ConstSensorDevicePtr> sensorDevicesConstPtr;
479 RTThreadTimingsSensorDevicePtr rtThreadTimingsSensorDevice;
484 static const std::string rtThreadTimingsSensorDeviceName;
const KeyValueVector< std::string, SensorDevicePtr > & getSensorDevices() const
TODO move to attorney for NJointControllerBase.
std::recursive_timed_mutex MutexType
The type of recursive_mutex used in this class.
This class allows minimal access to private members of Devices in a sane fashion for Publisher.
ConstControlDevicePtr getControlDevice(const std::string &deviceName) const
Returns the ControlDevice.
The SensorValueBase class.
This class allows minimal access to private members of Devices in a sane fashion for ControlThread.
void updateVirtualRobotFromSensorValues(const VirtualRobot::RobotPtr &robot, const std::vector< VirtualRobot::RobotNodePtr > &nodes, const std::vector< PtrT > &sensors) const
Updates the given VirtualRobot with the given SensorValues.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
This class allows minimal access to private members of Devices in a sane fashion for ControlThreadDat...
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
const std::map< std::string, ConstControlDevicePtr > & getControlDevicesConstPtr() const
Returns const pointers to all ControlDevices.
RTThreadTimingsSensorDevice & rtGetRTThreadTimingsSensorDevice()
Returns the SensorDevice used to log timings in the ControlThread.
ControlDeviceStatusSeq getControlDeviceStatuses(const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceStatuses for all ControlDevices.
std::set< std::string > groupsMerged
contains the names of all devices in any group
Transformation global_T_root
SensorDeviceStatus getSensorDeviceStatus(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceStatus for the given SensorDevice.
Ice::StringSeq getSensorDeviceNames(const Ice::Current &=Ice::emptyCurrent) const override
Returns the names of all SensorDevices for the robot.
ConstSensorDevicePtr getSensorDevice(const std::string &deviceName) const
TODO move to attorney for NJointControllerBase.
std::vector< std::vector< std::size_t > > deviceIndices
contains a vector per group.
ControlDeviceDescriptionSeq getControlDeviceDescriptions(const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceDescriptions for all ControlDevices.
This class allows minimal access to private members of armarx::RobotUnitModule::Devices in a sane fas...
std::vector< std::size_t > groupIndices
contains the group index for each device (or the sentinel)
SensorDeviceDescription getSensorDeviceDescription(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceDescription for the given SensorDevice.
Holds data about a device group requiring the same hardware control mode. (explained here)
ControlDeviceDescription getControlDeviceDescription(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceDescription for the given ControlDevice.
SensorDeviceStatusSeq getSensorDeviceStatuses(const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceStatuses for all SensorDevices.
std::vector< std::set< std::string > > groups
contains a vector per group.
void addSensorDevice(const SensorDevicePtr &sd)
Adds a SensorDevice to the robot.
static Devices & Instance()
Returns the singleton instance of this class.
SensorDeviceDescriptionSeq getSensorDeviceDescriptions(const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceDescriptions for all SensorDevices.
std::size_t getControlDeviceIndex(const std::string &deviceName) const
Returns the ControlDevice's index.
This Module manages sensor and control devices for a RobotUnit and only allows save and sane access.
std::size_t getNumberOfSensorDevices() const
Returns the number of SensorDevices.
void addControlDevice(const ControlDevicePtr &cd)
Adds a ControlDevice to the robot.
ControlDeviceStatus getControlDeviceStatus(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceStatus for the given ControlDevice.
DevicesPropertyDefinitions(std::string prefix)
std::size_t getSensorDeviceIndex(const std::string &deviceName) const
Returns the SensorDevice's index.
const KeyValueVector< std::string, ControlDevicePtr > & getControlDevices() const
Returns all ControlDevices.
std::shared_ptr< const class SensorDevice > ConstSensorDevicePtr
const ControlDeviceHardwareControlModeGroups & getControlModeGroups() const
Returns the groups of ControlDevices required to be in the same hardware control mode.
const std::map< std::string, ConstSensorDevicePtr > & getSensorDevicesConstPtr() const
Returns const pointers to all SensorDevices.
Ice::StringSeq getControlDeviceNames(const Ice::Current &=Ice::emptyCurrent) const override
Returns the names of all ControlDevices for the robot.
std::shared_ptr< const class ControlDevice > ConstControlDevicePtr
Base class for all RobotUnitModules.
std::size_t getNumberOfControlDevices() const
Returns the number of ControlDevices.
std::shared_ptr< class Robot > RobotPtr
virtual RTThreadTimingsSensorDevicePtr createRTThreadTimingSensorDevice() const
Creates the SensorDevice used to log timings in the ControlThread (This function is supposed to be us...
void updateVirtualRobotFromSensorValues(const VirtualRobot::RobotPtr &robot, const std::vector< PtrT > &sensors) const
Updates the given VirtualRobot with the given SensorValues.