27 #include "VisualServoGroupStatechartContext.generated.h"
32 using namespace VisualServoGroup;
42 GetHandPoseGeneratedBase <
GetHandPose > (stateData)
50 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
51 bool handLocalized =
false;
52 bool handPoseUncertain =
false;
55 FramedPosePtr handPoseFromKinematicModel =
new FramedPose(context->getRobot()->getRobotNode(in.getTcpNameInRobotModel())->getPoseInRootFrame(),
56 context->getRobot()->getRootNode()->getName(),
57 context->getRobot()->getName());
59 ARMARX_VERBOSE <<
"Hand pose from kinematic model: " << *handPoseFromKinematicModel;
62 FramedPosePtr handPoseFromMemoryX = handPoseFromKinematicModel;
64 memoryx::ChannelRefBaseSequence instances = context->getObjectMemoryObserver()->getObjectInstances(handMemoryChannel);
66 if (instances.size() == 0)
68 ARMARX_WARNING <<
"No instances of the hand in the memory: " << handMemoryChannel->get<std::string>(
"className");
69 auto list = context->getObjectMemoryObserver()->getObjectInstancesByClass(handMemoryChannel->get<std::string>(
"className"));
71 for (
auto& entry :
list)
73 ARMARX_INFO <<
"obj: " << ChannelRefPtr::dynamicCast(entry)->getDataField(
"className")->getString();
83 handPoseFromMemoryX =
new FramedPose(orientation->toEigen(), position->toEigen(), position->getFrame(), position->agent);
85 handPoseFromMemoryX->
changeFrame(context->getRobot(), context->getRobot()->getRootNode()->getName());
87 context->getDebugDrawerTopic()->setPoseVisu(
"VisualServo", in.getTcpNameInRobotModel(), handPoseFromMemoryX->
toGlobal(context->getRobot()));
89 float uncertainty = ChannelRefPtr::dynamicCast(instances.front())->get<
float>(
"uncertaintyOfPosition");
92 if (uncertainty > 100.0f)
94 handPoseUncertain =
true;
98 setOutput(
"HandPose", handPoseFromMemoryX);
99 setOutput(
"HandPoseFromKinematicModel", handPoseFromKinematicModel);
103 if (handPoseUncertain)
106 sendEvent<HandPoseUncertain>();
110 sendEvent<HandPoseAvailable>();
116 sendEvent<HandNotYetLocalized>();
145 return "GetHandPose";