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;
87 robotUnit->updateVirtualRobot(coordinateTransformationRobot);
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;
117 CartesianSelectionMode::CartesianSelection mode = CartesianSelectionMode::eAll;
119 if (globalTransVel && globalOriVel)
121 mode = CartesianSelectionMode::eAll;
123 else if (globalTransVel && !globalOriVel)
125 mode = CartesianSelectionMode::ePosition;
127 else if (!globalTransVel && globalOriVel)
129 mode = CartesianSelectionMode::eOrientation;
135 ARMARX_DEBUG <<
"CartesianSelection-Mode: " << (int)mode;
136 auto controllerName =
137 this->
getName() +
"_" + tcp +
"_" + nodeSetName +
"_mode_" + std::to_string((
int)mode);
138 auto NJointControllers = robotUnit->getNJointControllerNames();
139 NJointCartesianVelocityControllerWithRampPtr tcpController;
140 bool nodeSetAlreadyControlled =
false;
141 for (
auto& name : NJointControllers)
146 controller = robotUnit->getNJointControllerNotNull(name);
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(
174 robotUnit->createNJointController(
"NJointCartesianVelocityControllerWithRamp",
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();