42 VirtualRobot::RobotNodeSetPtr rnsBodies,
47 for (
size_t i = 0; i < rnsJoints->getSize(); i++)
55 ARMARX_DEBUG <<
"will calculate inverse dynamics for robot node "
56 << rnsJoints->getNode(i)->getName();
57 data.nodeSensorVec.push_back(std::make_pair(rnsJoints->getNode(i), sensorValue));
61 ARMARX_INFO <<
"Joint " << rnsJoints->getNode(i)->getName() <<
" not found";
62 data.nodeSensorVec.push_back(std::make_pair(rnsJoints->getNode(i),
nullptr));
66 data.velocityFilter.push_back(velocityFilter->clone());
68 if (accelerationFilter)
70 data.accelerationFilter.push_back(accelerationFilter->clone());
83 auto&
data = pair.second;
84 auto& dynamics =
data.dynamics;
87 for (
auto& node :
data.nodeSensorVec)
90 data.q(i) = node.second->position;
91 if (i <
data.velocityFilter.size() &&
data.velocityFilter.at(i) &&
92 !std::isnan(node.second->velocity))
94 data.qDot(i) =
data.velocityFilter.at(i)->update(sensorValuesTimestamp,
95 node.second->velocity);
99 data.qDot(i) = node.second->velocity;
101 if (i <
data.accelerationFilter.size() &&
data.accelerationFilter.at(i) &&
102 !std::isnan(node.second->acceleration))
104 data.qDDot(i) =
data.accelerationFilter.at(i)->update(
105 sensorValuesTimestamp, node.second->acceleration);
109 data.qDDot(i) = node.second->acceleration;
115 dynamics.getGravityMatrix(
data.q,
data.tauGravity);
119 for (
auto& node :
data.nodeSensorVec)
121 auto torque =
data.tau(i);
122 auto gravityTorque =
data.tauGravity(i);
125 node.second->inverseDynamicsTorque = -torque;
126 node.second->gravityTorque = -gravityTorque;
127 node.second->inertiaTorque = -(torque - gravityTorque);