34 using namespace PlatformGroup;
41 return std::copysign(std::min<float>(fabs(newValue), minAbsValue), newValue);
57 setTimeoutEvent(in.getTimeout(), createEventTimeout());
59 if (in.getUsePlatformNativeController())
68 float checkAngleValueOffset;
70 if (currentTarget->z >
M_PI)
72 checkAngleValueOffset = - 2 *
M_PI;
76 checkAngleValueOffset = 2 *
M_PI;
79 Literal checkAngle2(context->
platformUnitObserverName +
".platformPose.rotation", checks::approx, { (float)(currentTarget->z + checkAngleValueOffset), in.getOrientationalAccuracy()});
81 installConditionForPoseReached(checkX && checkY && (checkAngle || checkAngle2));
82 ARMARX_INFO <<
"Moving to " << in.getTargetPose()->x <<
", " <<
83 in.getTargetPose()->y <<
", " <<
84 in.getTargetPose()->z <<
", ";
86 in.getTargetPose()->y,
87 in.getTargetPose()->z, in.getPositionalAccuracy(), in.getOrientationalAccuracy());
90 in.getTargetPose()->y,
91 in.getTargetPose()->z, in.getPositionalAccuracy(), in.getOrientationalAccuracy());
93 this->setUseRunFunction(
false);
97 this->setUseRunFunction(
true);
107 PIDController pidRot(in.getPOrientation(), in.getIOrientation(), in.getDOrientation());
118 float maxTransVel = in.getMaxTranslationVelocity();
119 ARMARX_INFO <<
"orientation accuracy: " << in.getOrientationalAccuracy();
120 ARMARX_INFO <<
"translational accuracy: " << in.getPositionalAccuracy();
123 float targetX = in.getTargetPose()->x;
124 float targetY = in.getTargetPose()->y;
125 Eigen::Vector3f
target {targetX, targetY, 0};
126 float targetOri = in.getTargetPose()->z;
141 float startOri = oriRef->getDataField()->getFloat();
145 ARMARX_INFO <<
"Platform current pose: " << posXRef->getDataField()->getFloat() <<
", " << posYRef->getDataField()->getFloat() <<
", " << oriRef->getDataField()->getFloat();;
146 ARMARX_INFO <<
"Platform target pose: " << *in.getTargetPose();
147 ARMARX_INFO <<
"AdjustPlatform target angle: " << targetOri;
150 if (targetOri >
M_PI)
152 targetOri = - 2 *
M_PI + targetOri;
157 startOri = - 2 *
M_PI + startOri;
160 float angleAbsDelta = targetOri - startOri;
163 while (angleAbsDelta < -
M_PI)
165 angleAbsDelta += 2 *
M_PI;
168 while (angleAbsDelta >=
M_PI)
170 angleAbsDelta -= 2 *
M_PI;
174 Eigen::Vector2f targetOriVec(sin(targetOri), cos(targetOri));
175 bool verify = in.getVerifyTargetPose();
177 float cycleTime = in.getCycleTime();
179 while (!isRunningTaskStopped())
182 float posx = posXRef->getDataField()->getFloat();
183 float posy = posYRef->getDataField()->getFloat();
184 float ori = oriRef->getDataField()->getFloat();
191 Eigen::Vector3f pos {posx, posy, 0.0f};
195 ori = - 2 *
M_PI + ori;
201 float angleDelta = targetOri - ori;
207 while (angleDelta < -
M_PI)
209 angleDelta += 2 *
M_PI;
212 while (angleDelta >=
M_PI)
214 angleDelta -= 2 *
M_PI;
220 pidRot.
update(angleDelta, 0);
226 Eigen::Vector3f globalVel {newVel[0], newVel[1], 0};
228 m = Eigen::AngleAxisf(ori, Eigen::Vector3f::UnitZ());
229 Eigen::Vector3f localVel = m.inverse() * globalVel;
230 if (localVel.head(2).norm() > maxTransVel)
232 localVel.head(2) *= maxTransVel / localVel.head(2).norm();
238 if (std::isnan(localVel[0]) || std::isnan(localVel[1]) || std::isnan(newVelocityRot))
240 throw LocalException(
"A target velocity is NaN!");
247 c->platformUnitPrx->move(localVel[0],
260 if (targetReachedTime.toSeconds() == 0)
281 usleep(cycleTime * 1000);
431 float posX = posXRef->getDataField()->getFloat();
432 float posY = posYRef->getDataField()->getFloat();
433 float ori = oriRef->getDataField()->getFloat();
435 fabs(in.getTargetPose()->x - posX),
436 fabs(in.getTargetPose()->y - posY),
437 fabs(in.getTargetPose()->z - ori)
439 ARMARX_INFO <<
"Remaining platform error: " << *error;
440 out.setRemainingError(error);
445 while (!isRunningTaskFinished())
453 if (in.getStopPlatformOnBreak())
455 c->platformUnitPrx->stopPlatform();
464 while (!isRunningTaskFinished())
473 if (in.getStopPlatformOnExit())
475 c->platformUnitPrx->stopPlatform();