24 #include <VirtualRobot/RobotNodeSet.h>
32 #include <RobotAPI/interface/units/RobotUnit/NJointCartesianVelocityControllerWithRamp.h>
37 using namespace RTMotionControlGoup;
40 RTCartesianPositionControl::SubClassRegistry
58 auto robot = getLocalRobot();
60 auto targetPosition = in.getTargetPosition();
61 auto targetOrientation = in.getTargetOrientation();
64 auto kinematicChainName = in.getKinematicChainName();
65 auto nodeset = robot->getRobotNodeSet(kinematicChainName);
66 auto tcp = nodeset->getTCP();
68 auto ctrlName =
"RTCartesianPositionControlTCPCtrl";
69 NJointCartesianVelocityControllerWithRampConfigPtr ctrlCfg =
70 new NJointCartesianVelocityControllerWithRampConfig();
71 ctrlCfg->KpJointLimitAvoidance = 0;
72 ctrlCfg->jointLimitAvoidanceScale = 1;
74 ctrlCfg->nodeSetName = kinematicChainName;
75 ctrlCfg->tcpName = tcp->getName();
76 ctrlCfg->maxNullspaceAcceleration = 2;
77 ctrlCfg->maxPositionAcceleration = in.getTCPAcceleration();
78 ctrlCfg->maxOrientationAcceleration = 1;
82 "NJointCartesianVelocityControllerWithRamp", ctrlName, ctrlCfg);
84 NJointCartesianVelocityControllerWithRampInterfacePrx ctrl =
85 NJointCartesianVelocityControllerWithRampInterfacePrx::checkedCast(baseCtrl);
86 ctrl->activateController();
89 posController.
maxOriVel = in.getMaxOrientationVelocity();
90 posController.
maxPosVel = in.getMaxTCPVelocity();
91 posController.
KpOri = in.getKpOrientation();
92 posController.
KpPos = in.getKp();
96 targetPositioninRootFrame->changeFrame(robot, robot->getRootNode()->getName());
99 while (!isRunningTaskStopped())
103 Pose(targetOrientation->toRootEigen(robot), targetPosition->toRootEigen(robot))
105 float distanceToTarget =
106 (tcp->getPositionInRootFrame() - targetPositioninRootFrame->toEigen()).
norm();
113 if (posController.
getPositionError(targetPose) < in.getAbsPositionDifference() &&
121 Eigen::VectorXf
cv = posController.
calculate(targetPose, VirtualRobot::IKSolver::All);
122 ctrl->setTargetVelocity(
cv(0),
cv(1),
cv(2),
cv(3),
cv(4),
cv(5));
126 ctrl->deactivateAndDeleteController();