27 #include <VirtualRobot/IK/DifferentialIK.h>
28 #include <VirtualRobot/MathTools.h>
29 #include <VirtualRobot/Nodes/RobotNode.h>
30 #include <VirtualRobot/math/Helpers.h>
40 const VirtualRobot::RobotNodeSetPtr& rns,
41 const VirtualRobot::RobotNodePtr& elbow,
42 float maxPositionAcceleration,
43 float maxOrientationAcceleration,
44 float maxNullspaceAcceleration,
45 const VirtualRobot::RobotNodePtr& tcp) :
47 Eigen::VectorXf::Constant(rns->getSize(), 0.f),
49 maxPositionAcceleration,
50 maxOrientationAcceleration,
51 maxNullspaceAcceleration,
52 tcp ? tcp : rns->getTCP()),
53 pcTcp(tcp ? tcp : rns->getTCP()),
56 lastJointVelocity(
Eigen::VectorXf::Constant(rns->getSize(), 0.f)),
65 const std::vector<float>& maxValue)
67 if (maxValue.size() == 0)
71 if (maxValue.size() != 1 && (
int)maxValue.size() != vec.rows())
73 throw std::invalid_argument(
"maxValue.size != 1 and != maxValue.size");
76 for (
int i = 0; i < vec.rows(); i++)
78 int j = maxValue.size() == 1 ? 0 : i;
79 if (
std::abs(vec(i)) > maxValue.at(j) && maxValue.at(j) >= 0)
90 Eigen::VectorXf jvNT = Eigen::VectorXf(rns->getSize());
91 for (
size_t i = 0; i < rns->getSize(); i++)
100 if (rns->getNode(i)->isLimitless())
102 diff = ::math::Helpers::AngleModPI(diff);
110 const Eigen::VectorXf
136 Eigen::VectorXf jnvClamped = Eigen::VectorXf::Zero(rns->getSize());
139 Eigen::VectorXf jnv = Eigen::VectorXf::Zero(rns->getSize());
140 Eigen::VectorXf jvElb =
143 Eigen::VectorXf jvLA =
149 jnv = jvElb + jvLA + jvNT;
175 const Eigen::Vector3f& elbowTarget)
190 const Eigen::Vector3f& feedForwardVelocityPos,
191 const Eigen::Vector3f& feedForwardVelocityOri)
205 const std::vector<float>& nullspaceTarget)
208 for (
size_t i = 0; i < rns->getSize(); i++)
217 this->
nullspaceTarget = Eigen::VectorXf::Constant(rns->getSize(), std::nanf(
""));
258 const Eigen::Vector3f
261 return ::math::Helpers::GetPosition(
tcpTarget);
264 const Eigen::Vector3f&
270 const Eigen::VectorXf&
298 std::stringstream ss;
307 const CartesianNaturalPositionControllerConfig& cfg)
329 cfg.maxOrientationAcceleration,
330 cfg.maxNullspaceAcceleration);
331 if (cfg.jointCosts.size() > 0)
340 return (
vcTcp.
controller.
ik->getJacobianMatrix(VirtualRobot::IKSolver::All) * jointVel);