35 <<
"ControlDevice::getJointEmergencyStopController called for a ControlDevice ('"
37 <<
"') without a JointController "
38 "with the ControlMode ControlModes::EmergencyStop"
39 " (add a JointController with this ControlMode)";
40 return jointEmergencyStopController;
47 <<
"ControlDevice::getJointStopMovementController called for a ControlDevice ('"
49 <<
"') without a JointController "
50 "with the ControlMode ControlModes::StopMovement"
51 " (add a JointController with this ControlMode)";
52 return jointStopMovementController;
59 <<
"Called ControlDevice::rtSetActiveJointController with a nullptr (Don't do this)";
60 if (activeJointController == jointCtrl)
64 if (jointCtrl->parent !=
this)
66 throw std::logic_error{
68 ")::rtSetActiveJointController: "
69 "tried to switch to a joint controller from a different ControlDevice "
70 "(You should only call ControlDevice::rtSetActiveJointController with "
71 "JointControllers added to the ControlDevice via "
72 "ControlDevice::addJointController)"};
74 if (activeJointController)
76 activeJointController->rtDeactivate();
78 jointCtrl->rtActivate();
79 activeJointController = jointCtrl;
84 const IceUtil::Time& timeSinceLastIteration)
88 activejointCtrl->rtRun(sensorValuesTimestamp, timeSinceLastIteration);
96 <<
"' was already added to a RobotUnit! Call "
97 "addJointController before calling addControlDevice.";
101 throw std::invalid_argument{
"ControlDevice(" +
getDeviceName() +
102 ")::addJointController: joint controller is nullptr (Don't "
103 "try nullptrs as JointController)"};
105 if (jointCtrl->parent)
107 throw std::logic_error{
109 ")::addJointController: tried to add a joint controller multiple times" +
110 "(Don't try to add a JointController multiple to a ControlDevice)"};
115 <<
"' with mode '" << mode <<
"'";
116 if (jointControllers.has(mode))
118 throw std::invalid_argument{
120 ")::addJointController: joint controller for mode " + mode +
" was already added" +
121 "(Don't try to add multiple JointController with the same ControlMode)"};
123 jointCtrl->parent =
this;
127 if (mode == ControlModes::EmergencyStop)
129 jointEmergencyStopController = jointCtrl;
131 if (mode == ControlModes::StopMovement)
133 jointStopMovementController = jointCtrl;
137 throw std::logic_error{
139 ")::addJointController: The JointController has no ControlTarget. (mode = " + mode +
140 ")" +
"(Don't try to add JointController without a ControlTarget)"};
142 const std::hash<std::string> hash{};
145 jointControllers.add(mode, std::move(jointCtrl));
146 ARMARX_DEBUG <<
"adding Controller " << jointCtrl <<
"...done";
156 std::map<std::string, std::string>
159 std::map<std::string, std::string> map;
160 for (
const auto& name : jointControllers.keys())
162 map[name] = jointControllers.at(name)->getControlTarget()->getControlTargetType();
virtual void rtSetActiveJointController(JointController *jointCtrl)
Activates the given JointController for this device.
JointController * getJointEmergencyStopController()
RobotUnitModule::Devices * getOwner() const
JointController * getJointStopMovementController()
std::map< std::string, std::string > getJointControllerToTargetTypeNameMap() const
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration)
runs the active Joint Controller and write the target values into the control device
void addJointController(JointController *jointCtrl)
adds the Joint controller to this ControlDevice
static const ControlDevicePtr NullPtr
A static const nullptr in case a const ref to a nullptr needs to be returned.
JointController * rtGetActiveJointController()
virtual void rtWriteTargetValues(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration)
This is a hook for implementations to write the setpoints to a bus.
const std::string & getDeviceName() const
The JointController class represents one joint in one control mode.
virtual ControlTargetBase * getControlTarget()=0
virtual std::string getHardwareControlMode() const
virtual const std::string & getControlMode() const
virtual void rtResetTarget()
This Module manages sensor and control devices for a RobotUnit and only allows save and sane access.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_CHECK_IS_NULL(ptr)
This macro evaluates whether ptr is null and if it turns out to be false it will throw an ExpressionE...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_VERBOSE
The logging level for verbose information.
This file offers overloads of toIce() and fromIce() functions for STL container types.