27 #include "VisualServoGroupStatechartContext.generated.h"
30 using namespace VisualServoGroup;
37 VisualServoTowardsTargetPoseTest::SubClassRegistry
51 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
53 std::string handName = in.getHandNameInMemory();
55 ChannelRefBasePtr handMemoryChannel =
56 context->getObjectMemoryObserver()->requestObjectClassRepeated(
57 handName, 150, armarx::DEFAULT_VIEWTARGET_PRIORITY);
59 if (handMemoryChannel)
61 handMemoryChannel->validate();
62 local.setHandMemoryChannel(ChannelRefPtr::dynamicCast(handMemoryChannel));
67 <<
"Could not find hand in prior memory. handMemoryChannel is null: handName = "
73 Eigen::Vector3f targetPosition1(300, 650, 1050);
74 Eigen::Vector3f targetPosition2(150, 800, 1050);
76 Eigen::Vector3f targetOrientationVector(0, 1, 0);
77 targetOrientationVector.normalize();
79 Eigen::Matrix3f targetOrientation = getOrientationFromApproachVector(targetOrientationVector);
82 context->getRobot()->getRootNode()->getName(),
83 context->getRobot()->getName());
86 context->getRobot()->getRootNode()->getName(),
87 context->getRobot()->getName());
89 local.setTcpTargetPose1(targetPose1);
90 local.setTcpTargetPose2(targetPose2);
94 context->getTCPControlUnit()->request();
101 context->getRobot()->getRobotNode(in.getHandNameInRobotModel())->getPoseInRootFrame();
102 viewTargetEigen(2, 3) += 50;
104 context->getRobot()->getRootNode()->getName(),
105 context->getRobot()->getName());
107 context->getViewSelection()->addManualViewTarget(viewTarget);
108 context->getViewSelection()->addManualViewTarget(viewTarget);
109 context->getViewSelection()->addManualViewTarget(viewTarget);
115 VisualServoTowardsTargetPoseTest::getOrientationFromApproachVector(
116 const Eigen::Vector3f& approachVector)
118 Eigen::Vector3f z = approachVector;
119 Eigen::Vector3f y(0, 0, -1);
120 Eigen::Vector3f x = y.cross(z);
122 orientation.block<3, 1>(0, 0) = x;
123 orientation.block<3, 1>(0, 1) = y;
124 orientation.block<3, 1>(0, 2) = z;
131 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
133 ChannelRefPtr handMemoryChannel = local.getHandMemoryChannel();
138 while (!isRunningTaskStopped())
140 memoryx::ChannelRefBaseSequence instances =
141 context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
143 if (instances.size() == 0)
149 FramedPose handPoseFromKinematicModel(context->getRobot()
150 ->getRobotNode(in.getHandNameInRobotModel())
151 ->getPoseInRootFrame(),
152 context->getRobot()->getRootNode()->getName(),
153 context->getRobot()->getName());
156 ChannelRefPtr::dynamicCast(instances.front())->get<
FramedPosition>(
"position");
160 orientation->toEigen(), position->toEigen(), position->getFrame(), position->agent);
162 ARMARX_INFO <<
"handPoseFromKinematicModel: " << handPoseFromKinematicModel;
163 ARMARX_INFO <<
"handPoseFromMemoryX: " << handPoseFromMemoryX;
168 if (counter % 30 == 0)
171 ->getRobotNode(in.getHandNameInRobotModel())
172 ->getPoseInRootFrame();
176 context->getRobot()->getRootNode()->getName(),
177 context->getRobot()->getName());
179 context->getViewSelection()->addManualViewTarget(viewTarget);
196 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
198 context->getTCPControlUnit()->release();