Skip to content
Snippets Groups Projects

Implement 'PointAt'-skill

Merged Patrick Dormanns requested to merge feat/pointing-skill into main
2 files
+ 29
5
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -30,7 +30,7 @@ namespace armarx::control::pointing::core
VirtualRobot::RobotPtr robot = getRobot();
Eigen::Vector3f target = params.target.toGlobalEigen(robot);
Eigen::Vector3f target = toGlobal(params.target, robot);
visualizeTarget(target);
armarx::TrajectoryPtr traj = computeArmTrajectory(robot, params.side, target);
@@ -70,6 +70,18 @@ namespace armarx::control::pointing::core
return robot;
}
Eigen::Vector3f
Pointing::toGlobal(const FramedPosition& framedPosition, VirtualRobot::RobotPtr robot)
{
if (not(framedPosition.frame == armarx::GlobalFrame ||
robot->hasRobotNode(framedPosition.frame)))
{
ARMARX_ERROR << "'" << framedPosition.frame << "' is not a valid frame name";
throw armarx::exceptions::local::PointingFailedException();
}
return framedPosition.toGlobalEigen(robot);
}
void
Pointing::visualizeTarget(const Eigen::Vector3f& target)
{
@@ -137,13 +149,23 @@ namespace armarx::control::pointing::core
Side side,
const std::string& shapeName)
{
auto eefName = std::string("Hand_") + (side == Side::LEFT ? "L" : "R") + "_EEF"; // TODO
auto eef = robot->getEndEffector(eefName);
auto humanMapping = robot->getHumanMapping();
ARMARX_CHECK(humanMapping) << "Robot '" << robot->getName() << "' has no human mapping";
auto armDescription = (side == LEFT) ? humanMapping->leftArm : humanMapping->rightArm;
auto tcp = armDescription.segments.tcp.nodeName;
// get endeffector whichs tcp-name matches the tcp-name of the according hand
auto eefs = robot->getEndEffectors();
auto eef = std::find_if(eefs.begin(),
eefs.end(),
[&tcp](VirtualRobot::EndEffectorPtr eef)
{ return eef->getTcpName() == tcp; });
ARMARX_CHECK(eef != eefs.end());
auto shape = eef->getPreshape(shapeName);
auto shape = (*eef)->getPreshape(shapeName);
if (not shape)
{
ARMARX_ERROR << "Hand '" << eefName << "' has no shape '" << shape << "'";
ARMARX_ERROR << "Hand '" << (*eef)->getName() << "' has no shape '" << shapeName << "'";
throw armarx::exceptions::local::PointingFailedException();
}
return shape->getRobotNodeJointValueMap();
Loading