4 #include <VirtualRobot/Nodes/RobotNode.h>
5 #include <VirtualRobot/Robot.h>
6 #include <VirtualRobot/RobotNodeSet.h>
8 #include <simox/control/environment/CollisionRobot.h>
9 #include <simox/control/impl/simox/robot/Robot.h>
29 std::vector<std::string> tcpNodeNames;
30 for (
const auto& pair : rtCfg.ctrlCfg)
32 const auto nodeset = rtRobot->getRobotNodeSet(pair.first);
33 const std::string tcpName = nodeset->getTCP()->getName();
34 tcpNodeNames.push_back(tcpName);
35 if (pair.second.distanceThreshold > preFilterDistance)
37 preFilterDistance = pair.second.distanceThreshold;
45 rtRobot->getRobotNodeSet(rtCfg.actuatedRobotNodeSetName)->getNodeNames();
48 scRobot = std::make_unique<simox::control::simox::robot::Robot>(
52 ARMARX_INFO <<
"Creating robot model for collision computation using default primitive models and models with id " << rtCfg.primitiveModelParts;
54 collisionRobot = std::make_unique<simox::control::environment::CollisionRobot<hpp::fcl::OBBRSS>>(
56 simox::control::environment::CollisionRobotParams {
57 .loadDefaultPrimitiveModel =
true,
58 .primitiveModelIDs = rtCfg.primitiveModelParts,
70 const auto node = rtRobot->getRobotNode(nodeName);
71 if (node->isTranslationalJoint())
80 for (
const auto& pair : rtCfg.ctrlCfg)
86 ARMARX_INFO <<
"Creating index to node mapping for collision robot:";
87 std::unordered_set<unsigned int> consideredIndices;
91 for (
const auto& [
index, node] :
data.collisionRobotIndices)
94 <<
" for limb " << name;
95 consideredIndices.insert(
index);
99 ARMARX_INFO <<
"Initial computation of all self collision pairs";
101 selfColAvoidanceArgs = simox::control::environment::CompDistArgs{
103 .nearestPoints =
true,
104 .individualColObjects =
true,
105 .allowIndices = consideredIndices};
111 collisionRobot->computeMinimumSelfCollisionDistance(selfColAvoidanceArgs);
112 const int nElements = distanceResults.size();
114 for (
const auto& distanceResult : distanceResults)
117 <<
"Considering distance between "
118 <<
collisionRobot->getNodes().at(distanceResult.node1).getName() <<
" and "
120 <<
". Initial distance: " << distanceResult.minDistance <<
"m";
123 ARMARX_INFO <<
"Reserving space for " << nElements <<
" collision pairs";
135 const std::string& robotNodeSetName,
139 nodeSetName(robotNodeSetName),
140 rtRNS(rtRobot->getRobotNodeSet(robotNodeSetName)),
141 controller(scRobot.getSubNodeSet(robotNodeSetName)),
142 collisionPairs(collisionPairs)
158 c.ctrlCfg.at(rtRNS->getName()),
controller.numNodes(),
c.maxCollisionPairs, rtRNS);
166 pair.second.rts.rtPreActivate();
175 pair.second.reset(rtCfg);
192 ->getJointValuesEigen()
212 const auto time = IceUtil::Time::now();
215 const double collisionPairTime = (IceUtil::Time::now() - time).toMicroSecondsDouble();
219 pair.second.rts.collisionPairTime = collisionPairTime;
226 const Eigen::VectorXf& qpos,
227 const Eigen::VectorXf& qvelFiltered,
229 const Eigen::VectorXf& impedanceJointTorque)
231 auto& arm =
collLimb.at(robotNodeSetName);
234 arm.rts.impedanceJointTorque = impedanceJointTorque;
235 arm.controller.run(rtCfg.ctrlCfg.at(robotNodeSetName),
238 arm.collisionRobotIndices,
243 arm.bufferRTtoPublish.getWriteBuffer() = arm.rts;
244 arm.bufferRTtoPublish.commitWrite();
253 for (
auto& pair : cfg.ctrlCfg)