25 #include "VisualServoGroupStatechartContext.generated.h"
29 using namespace VisualServoGroup;
47 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
49 std::string handName = in.getHandNameInMemory();
51 ChannelRefBasePtr handMemoryChannel = context->getObjectMemoryObserver()->requestObjectClassRepeated(handName, 150, armarx::DEFAULT_VIEWTARGET_PRIORITY);
53 if (handMemoryChannel)
55 handMemoryChannel->validate();
56 local.setHandMemoryChannel(ChannelRefPtr::dynamicCast(handMemoryChannel));
60 ARMARX_ERROR <<
"Could not find hand in prior memory. handMemoryChannel is null: handName = " << handName;
65 Eigen::Vector3f targetPosition1(300, 650, 1050);
66 Eigen::Vector3f targetPosition2(150, 800, 1050);
68 Eigen::Vector3f targetOrientationVector(0, 1, 0);
69 targetOrientationVector.normalize();
71 Eigen::Matrix3f targetOrientation = getOrientationFromApproachVector(targetOrientationVector);
72 FramedPosePtr targetPose1 =
new FramedPose(targetOrientation, targetPosition1, context->getRobot()->getRootNode()->getName(), context->getRobot()->getName());
73 FramedPosePtr targetPose2 =
new FramedPose(targetOrientation, targetPosition2, context->getRobot()->getRootNode()->getName(), context->getRobot()->getName());
75 local.setTcpTargetPose1(targetPose1);
76 local.setTcpTargetPose2(targetPose2);
80 context->getTCPControlUnit()->request();
86 Eigen::Matrix4f viewTargetEigen = context->getRobot()->getRobotNode(in.getHandNameInRobotModel())->getPoseInRootFrame();
87 viewTargetEigen(2, 3) += 50;
90 context->getViewSelection()->addManualViewTarget(viewTarget);
91 context->getViewSelection()->addManualViewTarget(viewTarget);
92 context->getViewSelection()->addManualViewTarget(viewTarget);
98 Eigen::Matrix3f VisualServoTowardsTargetPoseTest::getOrientationFromApproachVector(
const Eigen::Vector3f& approachVector)
100 Eigen::Vector3f z = approachVector;
101 Eigen::Vector3f y(0, 0, -1);
102 Eigen::Vector3f x = y.cross(z);
104 orientation.block<3, 1>(0, 0) = x;
105 orientation.block<3, 1>(0, 1) = y;
106 orientation.block<3, 1>(0, 2) = z;
112 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
114 ChannelRefPtr handMemoryChannel = local.getHandMemoryChannel();
120 while (!isRunningTaskStopped())
122 memoryx::ChannelRefBaseSequence instances = context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
124 if (instances.size() == 0)
130 FramedPose handPoseFromKinematicModel(context->getRobot()->getRobotNode(in.getHandNameInRobotModel())->getPoseInRootFrame(),
131 context->getRobot()->getRootNode()->getName(),
132 context->getRobot()->getName());
136 FramedPose handPoseFromMemoryX =
FramedPose(orientation->toEigen(), position->toEigen(), position->getFrame(), position->agent);
138 ARMARX_INFO <<
"handPoseFromKinematicModel: " << handPoseFromKinematicModel;
139 ARMARX_INFO <<
"handPoseFromMemoryX: " << handPoseFromMemoryX;
144 if (counter % 30 == 0)
146 Eigen::Matrix4f viewTargetEigen = context->getRobot()->getRobotNode(in.getHandNameInRobotModel())->getPoseInRootFrame();
150 context->getViewSelection()->addManualViewTarget(viewTarget);
166 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
168 context->getTCPControlUnit()->release();