Go to the documentation of this file.
27 #include <VirtualRobot/Nodes/RobotNode.h>
28 #include <VirtualRobot/Robot.h>
29 #include <VirtualRobot/VirtualRobot.h>
32 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
34 #include "../Devices/ControlDevice.h"
35 #include "../Devices/RTThreadTimingsSensorDevice.h"
36 #include "../Devices/SensorDevice.h"
37 #include "../SensorValues/SensorValue1DoFActuator.h"
47 defineOptionalProperty<std::string>(
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 "
62 defineOptionalProperty<bool>(
"GlobalPoseCorrectionAndLocalizationSensorEnabled",
64 "Whether to enable or disable the global pose correction "
65 "and localization sensors.");
89 return ModuleBase::Instance<Devices>();
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()
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;
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.