26 #include "GraspObjectGroupStatechartContext.generated.h"
29 using namespace GraspObjectGroup;
43 GraspObjectGroupStatechartContext* context = getContext<GraspObjectGroupStatechartContext>();
44 float maxForceMagnitude = 10.0;
45 Eigen::Matrix4f leftTcpPoseBase = context->getRobot()->getRobotNode(in.getLeftHandName())->getPoseInRootFrame();
46 Eigen::Matrix4f rightTcpPoseBase = context->getRobot()->getRobotNode(in.getRightHandName())->getPoseInRootFrame();
48 if (!in.getLeftHandForceChecked() && !in.getLeftHandClosed())
51 DatafieldRefPtr forceRefLeft = DatafieldRefPtr::dynamicCast(context->getForceTorqueObserver()->getForceDatafield(in.getLeftHandName()));
55 Eigen::Vector3f leftHandForces = curForceLeft->toEigen();
58 if (leftHandForces.norm() > maxForceMagnitude && in.getRightHandClosed())
60 out.setLeftTcpTargetPoseUpdated(
FramedPose(leftTcpPoseBase,
"Armar3_Base",
"Armar3"));
61 out.setRightTcpTargetPoseUpdated(
FramedPose(rightTcpPoseBase,
"Armar3_Base",
"Armar3"));
62 emitBothHandForceDetected();
64 else if (leftHandForces.norm() > maxForceMagnitude)
66 out.setLeftTcpTargetPoseUpdated(
FramedPose(leftTcpPoseBase,
"Armar3_Base",
"Armar3"));
67 out.setRightTcpTargetPoseUpdated(in.getRightTcpTargetPose());
68 emitLeftHandForceDetected();
72 out.setLeftTcpTargetPoseUpdated(in.getLeftTcpTargetPose());
73 out.setRightTcpTargetPoseUpdated(in.getRightTcpTargetPose());
74 emitNoHandForcesDetected();
77 out.setLeftHandForceChecked(
true);
78 out.setRightHandForceChecked(
false);
81 else if (!in.getRightHandForceChecked() && !in.getRightHandClosed())
84 DatafieldRefPtr forceRefRight = DatafieldRefPtr::dynamicCast(context->getForceTorqueObserver()->getForceDatafield(in.getRightHandName()));
89 Eigen::Vector3f rightHandForces = curForceRight->toEigen();
92 if (rightHandForces.norm() > maxForceMagnitude && in.getLeftHandClosed())
94 out.setRightTcpTargetPoseUpdated(
FramedPose(rightTcpPoseBase,
"Armar3_Base",
"Armar3"));
95 out.setLeftTcpTargetPoseUpdated(
FramedPose(leftTcpPoseBase,
"Armar3_Base",
"Armar3"));
96 emitBothHandForceDetected();
98 else if (rightHandForces.norm() > maxForceMagnitude)
100 out.setRightTcpTargetPoseUpdated(
FramedPose(rightTcpPoseBase,
"Armar3_Base",
"Armar3"));
101 out.setLeftTcpTargetPoseUpdated(in.getLeftTcpTargetPose());
102 emitRightHandForceDetected();
106 out.setRightTcpTargetPoseUpdated(in.getRightTcpTargetPose());
107 out.setLeftTcpTargetPoseUpdated(in.getLeftTcpTargetPose());
108 emitNoHandForcesDetected();
111 out.setLeftHandForceChecked(
false);
112 out.setRightHandForceChecked(
true);
117 out.setLeftHandForceChecked(
false);
118 out.setRightHandForceChecked(
false);