27 #include "VisualServoGroupStatechartContext.generated.h"
29 #include <VirtualRobot/RobotNodeSet.h>
33 using namespace VisualServoGroup;
50 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
52 PosePtr desiredTcpOffsetToObject = in.getDesiredTcpOffsetToObject();
54 Eigen::Matrix4f tcpTargetPoseEigen = objectPose->toEigen() * desiredTcpOffsetToObject->toEigen();
55 FramedPose tcpTargetPose(tcpTargetPoseEigen, objectPose->frame, objectPose->agent);
56 auto nodeset = context->getRobotStateComponent()->getSynchronizedRobot()->getRobotNodeSet(in.getKinematicChainName());
57 auto tcpTargetPoseChainRoot =
FramedPose(tcpTargetPose.
toEigen(), tcpTargetPose.frame, tcpTargetPose.agent);
58 tcpTargetPoseChainRoot.changeFrame(context->getRobot(), nodeset->names.at(0));
59 float distance = tcpTargetPoseChainRoot.toEigen().block<3, 1>(0, 3).
norm();
63 out.setTcpTargetPose(tcpTargetPose);
65 if (in.getUseReachabilityMaps() && context->getRobotIK()->hasReachabilitySpace(in.getKinematicChainName()))
67 if (!context->getRobotIK()->hasReachabilitySpace(in.getKinematicChainName()))
69 ARMARX_ERROR <<
"No loaded reachability space available for kinematic chain '" << in.getKinematicChainName() <<
"'. Falling back to distance-based reachability check";
73 FramedPoseBasePtr p(
new FramedPose(tcpTargetPose));
75 if (context->getRobotIK()->isFramedPoseReachable(in.getKinematicChainName(), p))
77 ARMARX_INFO <<
"Reachability check for target pose: Succeeded";
78 emitTcpTargetCalculated();
89 if (
distance > in.getMaxTCPExtension())
91 ARMARX_WARNING <<
"Object is too far away (distance: " <<
distance <<
", max: " << in.getMaxTCPExtension();
96 emitTcpTargetCalculated();
126 return "CalculateTcpTarget";