31 #include <RobotAPI/interface/units/RobotUnit/NJointCartesianVelocityControllerWithRamp.h>
35 using namespace RTMotionControlGoup;
54 auto robot = getLocalRobot();
56 auto targetPosition = in.getTargetPosition();
57 auto targetOrientation = in.getTargetOrientation();
60 auto kinematicChainName = in.getKinematicChainName();
61 auto nodeset = robot->getRobotNodeSet(kinematicChainName);
62 auto tcp = nodeset->getTCP();
64 auto ctrlName =
"RTCartesianPositionControlTCPCtrl";
65 NJointCartesianVelocityControllerWithRampConfigPtr ctrlCfg =
new NJointCartesianVelocityControllerWithRampConfig();
66 ctrlCfg->KpJointLimitAvoidance = 0;
67 ctrlCfg->jointLimitAvoidanceScale = 1;
69 ctrlCfg->nodeSetName = kinematicChainName;
70 ctrlCfg->tcpName = tcp->getName();
71 ctrlCfg->maxNullspaceAcceleration = 2;
72 ctrlCfg->maxPositionAcceleration = in.getTCPAcceleration();
73 ctrlCfg->maxOrientationAcceleration = 1;
78 NJointCartesianVelocityControllerWithRampInterfacePrx ctrl = NJointCartesianVelocityControllerWithRampInterfacePrx::checkedCast(baseCtrl);
79 ctrl->activateController();
82 posController.
maxOriVel = in.getMaxOrientationVelocity();
83 posController.
maxPosVel = in.getMaxTCPVelocity();
84 posController.
KpOri = in.getKpOrientation();
85 posController.
KpPos = in.getKp();
89 targetPositioninRootFrame->changeFrame(robot, robot->getRootNode()->getName());
92 while (!isRunningTaskStopped())
95 auto targetPose =
Pose(targetOrientation->toRootEigen(robot), targetPosition->toRootEigen(robot)).toEigen();
96 float distanceToTarget = (tcp->getPositionInRootFrame() - targetPositioninRootFrame->toEigen()).
norm();
108 Eigen::VectorXf
cv = posController.
calculate(targetPose, VirtualRobot::IKSolver::All);
109 ctrl->setTargetVelocity(
cv(0),
cv(1),
cv(2),
cv(3),
cv(4),
cv(5));
113 ctrl->deactivateAndDeleteController();