27#include <VirtualRobot/Nodes/RobotNode.h>
28#include <VirtualRobot/Robot.h>
29#include <VirtualRobot/VirtualRobot.h>
32#include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
48 "ControlDevices_HardwareControlModeGroups",
50 "Groups of control devices for which the same hardware control mode has to be set. "
51 "For a control mode, the JointControllers of all devices in a group must have the "
52 "identical hardware control mode. "
53 "The kinematic unit will change the control mode of all joints in a group,"
54 " if their current hw control mode does not match the new hw control mode. "
55 "This can be used if the robot has a multi DOF joint which is represented by "
56 "multiple 1DOF control devices "
57 "(in such a case all of these 1DOF joints should have the same hw control mode, "
58 "except he multi DOF joint can handle different control modes at once). "
59 "Syntax: semicolon separated groups , each group is CSV of joints "
60 "e.g. j1,j2;j3,j4,j5 -> Group 1 = j1+j2 Group 2 = j3+j4+j5; No joint may be in two "
64 "Whether to enable or disable the global pose correction "
65 "and localization sensors.");
97 void _preOnInitRobotUnit();
99 void _preFinishDeviceInitialization();
101 void _postFinishDeviceInitialization();
103 void _postFinishRunning();
122 ControlDeviceDescription
124 const Ice::Current& = Ice::emptyCurrent)
const override;
131 ControlDeviceDescriptionSeq
143 const Ice::Current& = Ice::emptyCurrent)
const override;
150 ControlDeviceStatusSeq
166 SensorDeviceDescription
168 const Ice::Current& = Ice::emptyCurrent)
const override;
175 SensorDeviceDescriptionSeq
187 const Ice::Current& = Ice::emptyCurrent)
const override;
194 SensorDeviceStatusSeq
254 template <
class PtrT>
257 const std::vector<PtrT>& sensors)
const
272 template <
class PtrT>
275 const std::vector<VirtualRobot::RobotNodePtr>& nodes,
276 const std::vector<PtrT>& sensors)
const
280 for (
const SimoxRobotSensorValueMapping& m : simoxRobotSensorValueMapping)
284 const SensorValue1DoFActuatorPosition* svPos =
285 sv->
asA<SensorValue1DoFActuatorPosition>();
287 nodes.at(m.idxRobot)->setJointValueNoUpdate(svPos->position);
291 if (globalRobotLocalizationSensorDevice !=
nullptr)
293 const auto sensorValue =
294 globalRobotLocalizationSensorDevice->getSensorValue()
296 const auto global_T_root = sensorValue->global_T_root;
297 robot->setGlobalPose(global_T_root,
false);
300 robot->applyJointValues();
309 const ControlDeviceHardwareControlModeGroups&
312 return ctrlModeGroups;
334 const std::string& deviceName)
const;
341 const std::string& deviceName)
const;
350 return sensorDevices;
360 return controlDevices;
367 const std::map<std::string, ConstSensorDevicePtr>&
370 return sensorDevicesConstPtr;
377 const std::map<std::string, ConstControlDevicePtr>&
380 return controlDevicesConstPtr;
413 return *rtThreadTimingsSensorDevice;
425 std::vector<JointController*> getStopMovementJointControllers()
const;
431 std::vector<JointController*> getEmergencyStopJointControllers()
const;
437 struct SimoxRobotSensorValueMapping
440 std::size_t idxRobot;
446 std::vector<SimoxRobotSensorValueMapping> simoxRobotSensorValueMapping;
448 std::vector<const SensorValueBase*> sensorValues;
450 std::vector<std::vector<PropagateConst<ControlTargetBase*>>> controlTargets;
458 std::vector<std::set<std::string>>
groups;
473 std::map<std::string, ConstControlDevicePtr> controlDevicesConstPtr;
484 std::map<std::string, ConstSensorDevicePtr> sensorDevicesConstPtr;
489 RTThreadTimingsSensorDevicePtr rtThreadTimingsSensorDevice;
494 static const std::string rtThreadTimingsSensorDeviceName;
SensorValueGlobalRobotPose SensorValueType
This class is pretty much similar to a map.
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)
DevicesPropertyDefinitions(std::string prefix)
This Module manages sensor and control devices for a RobotUnit and only allows save and sane access.
Ice::StringSeq getSensorDeviceNames(const Ice::Current &=Ice::emptyCurrent) const override
Returns the names of all SensorDevices for the robot.
void updateVirtualRobotFromSensorValues(const VirtualRobot::RobotPtr &robot, const std::vector< PtrT > &sensors) const
Updates the given VirtualRobot with the given SensorValues.
const KeyValueVector< std::string, ControlDevicePtr > & getControlDevices() const
Returns all ControlDevices.
Ice::StringSeq getControlDeviceNames(const Ice::Current &=Ice::emptyCurrent) const override
Returns the names of all ControlDevices for the robot.
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.
ControlDeviceDescription getControlDeviceDescription(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceDescription for the given ControlDevice.
friend class DevicesAttorneyForNJointController
This class allows minimal access to private members of Devices in a sane fashion for NJointController...
SensorDeviceDescription getSensorDeviceDescription(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceDescription for the given SensorDevice.
void addSensorDevice(const SensorDevicePtr &sd)
Adds a SensorDevice to the robot.
friend class DevicesAttorneyForPublisher
This class allows minimal access to private members of Devices in a sane fashion for Publisher.
void addControlDevice(const ControlDevicePtr &cd)
Adds a ControlDevice to the robot.
const ControlDeviceHardwareControlModeGroups & getControlModeGroups() const
Returns the groups of ControlDevices required to be in the same hardware control mode.
friend class DevicesAttorneyForControlThreadDataBuffer
This class allows minimal access to private members of Devices in a sane fashion for ControlThreadDat...
static Devices & Instance()
Returns the singleton instance of this class.
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.
std::size_t getNumberOfControlDevices() const
Returns the number of ControlDevices.
friend class DevicesAttorneyForControlThread
This class allows minimal access to private members of Devices in a sane fashion for ControlThread.
SensorDeviceDescriptionSeq getSensorDeviceDescriptions(const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceDescriptions for all SensorDevices.
ControlDeviceStatusSeq getControlDeviceStatuses(const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceStatuses for all ControlDevices.
std::size_t getSensorDeviceIndex(const std::string &deviceName) const
Returns the SensorDevice's index.
SensorDeviceStatusSeq getSensorDeviceStatuses(const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceStatuses for all SensorDevices.
ConstSensorDevicePtr getSensorDevice(const std::string &deviceName) const
TODO move to attorney for NJointControllerBase.
const std::map< std::string, ConstSensorDevicePtr > & getSensorDevicesConstPtr() const
Returns const pointers to all SensorDevices.
ConstControlDevicePtr getControlDevice(const std::string &deviceName) const
Returns the ControlDevice.
virtual RTThreadTimingsSensorDevicePtr createRTThreadTimingSensorDevice() const
Creates the SensorDevice used to log timings in the ControlThread (This function is supposed to be us...
std::size_t getControlDeviceIndex(const std::string &deviceName) const
Returns the ControlDevice's index.
ControlDeviceStatus getControlDeviceStatus(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceStatus for the given ControlDevice.
const KeyValueVector< std::string, SensorDevicePtr > & getSensorDevices() const
TODO move to attorney for NJointControllerBase.
ControlDeviceDescriptionSeq getControlDeviceDescriptions(const Ice::Current &=Ice::emptyCurrent) const override
Return the ControlDeviceDescriptions for all ControlDevices.
SensorDeviceStatus getSensorDeviceStatus(const std::string &name, const Ice::Current &=Ice::emptyCurrent) const override
Return the SensorDeviceStatus for the given SensorDevice.
std::size_t getNumberOfSensorDevices() const
Returns the number of SensorDevices.
ModuleBasePropertyDefinitions(std::string prefix)
static ModuleBase & Instance()
Returns the singleton instance of this class.
std::recursive_timed_mutex MutexType
The type of recursive_mutex used in this class.
The SensorValueBase class.
#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...
std::shared_ptr< class Robot > RobotPtr
std::shared_ptr< const class ControlDevice > ConstControlDevicePtr
std::shared_ptr< const class SensorDevice > ConstSensorDevicePtr
Holds data about a device group requiring the same hardware control mode. (explained here)
std::set< std::string > groupsMerged
contains the names of all devices in any group
std::vector< std::vector< std::size_t > > deviceIndices
contains a vector per group.
std::vector< std::set< std::string > > groups
contains a vector per group.
std::vector< std::size_t > groupIndices
contains the group index for each device (or the sentinel)