29 #include "VisualServoGroupStatechartContext.generated.h"
32 using namespace VisualServoGroup;
47 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
48 bool handLocalized =
false;
49 bool handPoseUncertain =
false;
53 context->getRobot()->getRobotNode(in.getTcpNameInRobotModel())->getPoseInRootFrame(),
54 context->getRobot()->getRootNode()->getName(),
55 context->getRobot()->getName());
57 ARMARX_VERBOSE <<
"Hand pose from kinematic model: " << *handPoseFromKinematicModel;
60 FramedPosePtr handPoseFromMemoryX = handPoseFromKinematicModel;
62 memoryx::ChannelRefBaseSequence instances =
63 context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
65 if (instances.size() == 0)
68 << handMemoryChannel->get<std::string>(
"className");
69 auto list = context->getObjectMemoryObserver()->getObjectInstancesByClass(
70 handMemoryChannel->get<std::string>(
"className"));
72 for (
auto& entry :
list)
76 << ChannelRefPtr::dynamicCast(entry)->getDataField(
"className")->getString();
85 ChannelRefPtr::dynamicCast(instances.front())->get<
FramedPosition>(
"position");
87 ChannelRefPtr::dynamicCast(instances.front())->get<
FramedOrientation>(
"orientation");
89 orientation->toEigen(), position->toEigen(), position->getFrame(), position->agent);
91 handPoseFromMemoryX->
changeFrame(context->getRobot(),
92 context->getRobot()->getRootNode()->getName());
94 context->getDebugDrawerTopic()->setPoseVisu(
96 in.getTcpNameInRobotModel(),
97 handPoseFromMemoryX->
toGlobal(context->getRobot()));
100 ChannelRefPtr::dynamicCast(instances.front())->get<
float>(
"uncertaintyOfPosition");
101 ARMARX_VERBOSE <<
"Uncertainty of hand position: " << uncertainty;
103 if (uncertainty > 100.0f)
105 handPoseUncertain =
true;
109 setOutput(
"HandPose", handPoseFromMemoryX);
110 setOutput(
"HandPoseFromKinematicModel", handPoseFromKinematicModel);
114 if (handPoseUncertain)
117 sendEvent<HandPoseUncertain>();
121 sendEvent<HandPoseAvailable>();
127 sendEvent<HandNotYetLocalized>();
149 return "GetHandPose";