27 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
29 #include "../Devices/ControlDevice.h"
30 #include "../Devices/SensorDevice.h"
36 class RTThreadTimingsSensorDevice;
46 defineOptionalProperty<std::size_t>(
47 "NjointController_AllowedExecutionTimePerControlDeviceUntilWarning",
49 "A Warning will be printed, If the execution time in micro seconds of a "
50 "NJointControllerBase "
51 "exceeds this parameter times the number of ControlDevices.");
52 defineOptionalProperty<std::size_t>(
53 "NjointController_AllowedExecutionTimePerControlDeviceUntilError",
55 "An Error will be printed, If the execution time in micro seconds of a "
56 "NJointControllerBase "
57 "exceeds this parameter times the number of ControlDevices.");
58 defineOptionalProperty<bool>(
59 "EnableInverseDynamics",
61 "If true, inverse dynamics are calculated for all joints given in the "
62 "InverseDynamicsRobotJointSets property during each loop of "
63 "the rt control thread.");
64 defineOptionalProperty<std::string>(
"InverseDynamicsRobotJointSets",
66 "Comma separated list of robot nodesets for which "
67 "the inverse dynamics should be calculcated.");
68 defineOptionalProperty<std::string>(
69 "InverseDynamicsRobotBodySet",
71 "Robot nodeset of which the masses should be used for the inverse dynamics");
86 enum class EmergencyStopStateRequest
112 return ModuleBase::Instance<ControlThread>();
120 void _preFinishControlThreadInitialization();
122 void _preOnInitRobotUnit();
156 return controlThreadId;
165 void setEmergencyStopStateNoReportToTopic(EmergencyStopState state);
170 void processEmergencyStopRequest();
284 return rtIsInEmergencyStop_;
294 return rtIsInEmergencyStop_ ? EmergencyStopState::eEmergencyStopActive
295 : EmergencyStopState::eEmergencyStopInactive;
317 std::vector<JointController*>& rtGetActivatedJointControllers();
318 const std::vector<JointController*>& rtGetActivatedJointControllers()
const;
323 std::vector<NJointControllerBase*>& rtGetActivatedNJointControllers();
324 const std::vector<NJointControllerBase*>& rtGetActivatedNJointControllers()
const;
332 std::vector<std::size_t>& rtGetActivatedJointToNJointControllerAssignement();
333 const std::vector<std::size_t>& rtGetActivatedJointToNJointControllerAssignement()
const;
340 const std::vector<JointController*>& rtGetRequestedJointControllers()
const;
345 const std::vector<NJointControllerBase*>& rtGetRequestedNJointControllers()
const;
353 const std::vector<std::size_t>& rtGetRequestedJointToNJointControllerAssignement()
const;
357 void dumpRtControllerSetup(std::ostream& out,
358 const std::string& indent,
359 const std::vector<JointController*>& activeCdevs,
360 const std::vector<std::size_t>& activeJCtrls,
361 const std::vector<NJointControllerBase*>& assignement)
const;
362 std::string dumpRtState()
const;
368 std::atomic_bool rtIsInEmergencyStop_{
false};
370 std::atomic_bool emergencyStop{
false};
375 std::vector<VirtualRobot::RobotNodePtr> rtRobotNodes;
378 std::atomic<std::thread::id> controlThreadId;
381 std::size_t usPerDevUntilWarn;
383 std::size_t usPerDevUntilError;
385 bool rtSwitchControllerSetupChangedControllers{
false};
386 std::size_t numberOfInvalidTargetsInThisIteration{0};
388 std::vector<JointController*> preSwitchSetup_ActivatedJointControllers;
389 std::vector<std::size_t> preSwitchSetup_ActivatedJointToNJointControllerAssignement;
390 std::vector<NJointControllerBase*> preSwitchSetup_ActivatedNJointControllers;
392 std::vector<JointController*> postSwitchSetup_ActivatedJointControllers;
393 std::vector<std::size_t> postSwitchSetup_ActivatedJointToNJointControllerAssignement;
394 std::vector<NJointControllerBase*> postSwitchSetup_ActivatedNJointControllers;
396 std::vector<std::size_t> _activatedSynchronousNJointControllersIdx;
397 std::vector<std::size_t> _activatedAsynchronousNJointControllersIdx;
399 std::atomic<EmergencyStopStateRequest> emergencyStopStateRequest{
400 EmergencyStopStateRequest::RequestNone};
402 std::shared_ptr<DynamicsHelper> dynamicsHelpers;
404 std::size_t _maxControllerCount = 0;