27 #include "VisualServoGroupStatechartContextBase.generated.h"
29 #include <IceUtil/UUID.h>
32 using namespace VisualServoGroup;
49 if (!in.isTcpTargetPoseSet() && !in.isTcpTargetPositionSet())
51 ARMARX_ERROR <<
"Either TcpTargetPose or TcpTargetPosition has to be set for VisualServo, but none is set.";
58 VisualServoGroupStatechartContextBase* context = getContext<VisualServoGroupStatechartContextBase>();
60 std::string kinematicChainName = in.getKinematicChainName();
61 if (!in.isTCPNameInRobotModelSet())
63 std::string tcpName = context->getLocalRobot()->getRobotNodeSet(kinematicChainName)->getTCP()->getName();
64 local.setTcpNameInRobotModel(tcpName);
68 local.setTcpNameInRobotModel(in.getTCPNameInRobotModel());
71 local.setSpeedModificationFactorHandNotLocalized(0.3f);
72 local.setSpeedModificationFactorHandPoseUncertain(0.5f);
74 if (in.isStartTimeRefSet())
76 ARMARX_INFO <<
"Using existing StartTime for Visual Servo.";
77 local.setTimerCreated(
false);
81 ARMARX_INFO <<
"Creating new StartTime for Visual Servo.";
82 in.setStartTimeRef(getSystemObserver()->startTimer(
"VisualServoTimer_" + IceUtil::generateUUID()));
83 local.setTimerCreated(
true);
86 if (context->getTCPControlUnit()->isRequested())
88 ARMARX_INFO <<
"TCPControlUnit is already requested.";
89 local.setTCPControlUnitRequested(
false);
94 context->getTCPControlUnit()->request();
95 local.setTCPControlUnitRequested(
true);
99 std::string chainName = in.getKinematicChainName();
100 memoryx::PersistentObjectClassSegmentBasePrx classesSegmentPrx = context->getPriorKnowledge()->getObjectClassesSegment();
101 auto tcpObjectClass = classesSegmentPrx->getObjectClassByName(in.getHandMemoryChannel()->getDataField(
"className")->getString());
104 context->getEntityDrawerTopic()->setObjectVisu(
"VisualServoHandVisu",
"tcpTarget_" + chainName, tcpObjectClass,
new Pose());
105 context->getEntityDrawerTopic()->updateObjectTransparency(
"VisualServoHandVisu",
"tcpTarget_" + chainName, 0.3);
111 if (local.getTimerCreated())
114 getSystemObserver()->removeTimer(in.getStartTimeRef());
116 if (local.getTCPControlUnitRequested())
119 getTcpControlUnit()->release();
122 VisualServoGroupStatechartContextBase* context = getContext<VisualServoGroupStatechartContextBase>();
123 context->getDebugDrawerTopic()->removeLayer(
"VisualServo");
124 context->getEntityDrawerTopic()->removeLayer(
"VisualServoHandVisu");
133 return "VisualServoTowardsTargetPose";