28 #include <RobotAPI/interface/units/RobotUnit/NJointCartesianVelocityControllerWithRamp.h>
51 coordinateTransformationRobot = robot;
62 <<
"Setting cycle time in RT-Controller does not have an effect";
67 const std::string& tcpName,
68 const FramedDirectionBasePtr& translationVelocity,
69 const FramedDirectionBasePtr& orientationVelocityRPY,
70 const Ice::Current&
c)
72 std::unique_lock lock(dataMutex);
74 <<
"The robot does not have the node set: " + nodeSetName;
78 tcp = coordinateTransformationRobot->getRobotNodeSet(nodeSetName)->getTCP()->getName();
83 <<
"The robot does not have the node: " + tcpName;
97 FramedDirectionPtr globalTransVel = FramedDirectionPtr::dynamicCast(translationVelocity);
100 globalTransVel->changeFrame(coordinateTransformationRobot,
101 coordinateTransformationRobot->getRootNode()->getName());
102 xVel = globalTransVel->x;
103 yVel = globalTransVel->y;
104 zVel = globalTransVel->z;
107 FramedDirectionPtr globalOriVel = FramedDirectionPtr::dynamicCast(orientationVelocityRPY);
110 globalOriVel->changeFrame(coordinateTransformationRobot,
111 coordinateTransformationRobot->getRootNode()->getName());
112 rollVel = globalOriVel->x;
113 pitchVel = globalOriVel->y;
114 yawVel = globalOriVel->z;
119 if (globalTransVel && globalOriVel)
123 else if (globalTransVel && !globalOriVel)
127 else if (!globalTransVel && globalOriVel)
135 ARMARX_DEBUG <<
"CartesianSelection-Mode: " << (int)mode;
136 auto controllerName =
139 NJointCartesianVelocityControllerWithRampPtr tcpController;
140 bool nodeSetAlreadyControlled =
false;
141 for (
auto& name : NJointControllers)
153 tcpController = NJointCartesianVelocityControllerWithRampPtr::dynamicCast(
controller);
158 if (tcpController->getNodeSetName() == nodeSetName &&
159 tcpController->getInstanceName() == controllerName)
161 nodeSetAlreadyControlled =
true;
166 if (!nodeSetAlreadyControlled)
168 NJointCartesianVelocityControllerWithRampConfigPtr config =
169 new NJointCartesianVelocityControllerWithRampConfig(
170 nodeSetName, tcp, mode, 500, 1, 2, 0.3f, 2);
172 NJointCartesianVelocityControllerWithRampPtr ctrl =
173 NJointCartesianVelocityControllerWithRampPtr::dynamicCast(
180 tcpController = ctrl;
181 tcpControllerNameMap[nodeSetName] = controllerName;
182 tcpController->setKpJointLimitAvoidance(getProperty<float>(
"AvoidJointLimitsKp").getValue(),
192 tcpController->setTargetVelocity(xVel, yVel, zVel, rollVel, pitchVel, yawVel,
c);
198 if (!tcpController->isControllerActive())
200 tcpController->activateController();
208 std::unique_lock lock(dataMutex);
209 for (
auto& pair : tcpControllerNameMap)
212 if (ctrl && ctrl->isControllerActive())
222 const std::set<std::string>& changedProperties)
224 if (changedProperties.count(
"AvoidJointLimitsKp") && robotUnit)
226 float avoidJointLimitsKp = getProperty<float>(
"AvoidJointLimitsKp").getValue();
227 auto activeNJointControllers =
228 robotUnit->getNJointControllersNotNull(robotUnit->getNJointControllerNames());
229 for (NJointControllerBasePtr
controller : activeNJointControllers)
232 NJointCartesianVelocityControllerWithRampPtr::dynamicCast(
controller);
235 tcpController->setKpJointLimitAvoidance(avoidJointLimitsKp, Ice::emptyCurrent);