3 #include <VirtualRobot/Robot.h>
4 #include <VirtualRobot/RobotNodeSet.h>
11 auto humanMapping = robot->getHumanMapping();
12 ARMARX_CHECK(humanMapping) <<
"Robot '" << robot->getName() <<
"' has no human mapping";
14 auto armDescription = (side ==
LEFT) ? humanMapping->leftArm : humanMapping->rightArm;
15 auto elbow = armDescription.segments.elbow.nodeName;
16 auto wrist = armDescription.segments.wrist.nodeName;
17 auto palm = armDescription.segments.palm.nodeName;
20 auto nodeSetArm = robot->getRobotNodeSet(armDescription.nodeSet);
21 auto actuatedJoints = nodeSetArm->getNodeNames();
22 actuatedJoints.resize(nodeSetArm->getRobotNodeIndex(wrist));
25 reducedRobot_ = std::make_unique<simox::control::simox::robot::Robot>(
26 robot, actuatedJoints, std::vector({wrist, palm}),
true);
28 ik_ = std::make_unique<simox::control::method::example::PointingIK>(
30 *reducedRobot_->getNode(wrist),
31 *reducedRobot_->getNode(elbow),
32 side ==
LEFT ? reducedRobot_->humanMapping()->leftArm
33 : reducedRobot_->humanMapping()->rightArm);
35 ik_->setPointingTarget(
target.cast<
double>() / 1000);
37 trajData.assign(ik_->getNodeNames().size(), std::vector<double>());
38 appendTrajData(ik_->getJointValues());
44 return ik_->isTargetReached();
50 Eigen::VectorXd prevJointValues = ik_->getJointValues();
52 appendTrajData(ik_->getJointValues());
53 return (ik_->getJointValues() - prevJointValues).norm();
59 return new Trajectory(trajData, Ice::DoubleSeq(), ik_->getNodeNames());
63 PointingIK::appendTrajData(
const Eigen::VectorXd& jointValues)
65 for (
size_t i = 0; i < trajData.size(); i++)
67 trajData[i].push_back(jointValues[i]);