3 #include <SimoxUtility/math/convert/mat4f_to_quat.h>
4 #include <VirtualRobot/IK/DifferentialIK.h>
5 #include <VirtualRobot/IK/JacobiProvider.h>
6 #include <VirtualRobot/MathTools.h>
7 #include <VirtualRobot/Nodes/RobotNode.h>
8 #include <VirtualRobot/Robot.h>
9 #include <VirtualRobot/RobotNodeSet.h>
24 const VirtualRobot::RobotNodeSetPtr& rns,
25 const VirtualRobot::RobotNodeSetPtr& rtRns,
26 const std::vector<size_t>& torqueControlledIndex,
27 const std::vector<size_t>& velocityControlledIndex)
39 rtTCP = rtRns->getTCP();
41 ik.reset(
new VirtualRobot::DifferentialIK(
42 rtRns, rtRns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
49 const VirtualRobot::RobotNodeSetPtr& rns)
61 const std::vector<std::string>& nameList,
62 const std::map<std::string, std::string>& jointControlModeMap)
64 std::set<std::string> validModes = {
"velocity",
"torque"};
66 for (
const auto& pair : jointControlModeMap)
68 if (std::find(nameList.begin(), nameList.end(), pair.first) == nameList.end())
70 ARMARX_ERROR <<
"TaskspaceMixedImpedanceVelocityController: joint name '"
71 << pair.first <<
"' not found in robot node set.";
75 if (validModes.find(pair.second) == validModes.end())
78 <<
"TaskspaceMixedImpedanceVelocityController: Invalid control mode for joint '"
79 << pair.first <<
"': " << pair.second << std::endl;
119 c.desiredPose.block<3, 3>(0, 0) * rtStatus.
currentPose.block<3, 3>(0, 0).transpose();
129 else if ((
c.desiredPose.block<3, 1>(0, 3) - rtStatus.
currentPose.block<3, 1>(0, 3)).norm() >
130 c.safeDistanceMMToGoal or
133 VirtualRobot::MathTools::deg2rad(
c.safeRotAngleDegreeToGoal))
148 ik->getJacobianMatrix(
rtTCP, VirtualRobot::IKSolver::CartesianSelection::All);
153 rtStatus.
jpinv = ik->computePseudoInverseJacobianMatrix(
155 ik->getJacobiRegularization(VirtualRobot::IKSolver::CartesianSelection::All));
163 ik->computePseudoInverseJacobianMatrix(rtStatus.
jacobi.transpose(), lambda);
212 c.desiredNullspaceJointAngles.value() - rtStatus.
jointPos) -
213 c.kdNullspaceTorque.cwiseProduct(rtStatus.
jointVel);
215 c.kpNullspaceVel.cwiseProduct(
c.desiredNullspaceJointAngles.value() -
244 const size_t numDoFTorque,
245 const size_t numDoFVelocity)
290 jpinv.setZero(nDoF, 6);
301 currentPose = currentTCPPose;
302 desiredPose = currentTCPPose;
303 accumulateTime = 0.0;