31 using namespace CoupledInteractionGroup;
34 CheckForcesChanged::SubClassRegistry
48 float forceThreshhold,
49 float torqueThreshhold)
52 getContext<CoupledInteractionGroupStatechartContext>();
64 float deviationForce = (curForce->
toEigen() - refForces->toEigen()).
norm();
65 float deviationTorque = (curTorque->
toEigen() - refTorques->toEigen()).
norm();
67 if (deviationForce > forceThreshhold && deviationTorque > torqueThreshhold)
79 getContext<CoupledInteractionGroupStatechartContext>();
83 std::string leftTcpName = in.getLeftHandName();
84 std::string rightTcpName = in.getRightHandName();
93 float maxDisplacement = in.getMaxDisplacement();
94 bool maxDisplacementReached =
false;
96 context->
getRobot()->getRobotNode(in.getLeftHandName())->getPoseInRootFrame();
98 context->
getRobot()->getRobotNode(in.getRightHandName())->getPoseInRootFrame();
99 float leftDisplacement =
100 (leftTcpPoseBase(0, 3) - leftInitPos->x) * (leftTcpPoseBase(0, 3) - leftInitPos->x);
102 (leftTcpPoseBase(1, 3) - leftInitPos->y) * (leftTcpPoseBase(1, 3) - leftInitPos->y);
104 (leftTcpPoseBase(2, 3) - leftInitPos->z) * (leftTcpPoseBase(2, 3) - leftInitPos->z);
105 leftDisplacement = fabs(leftTcpPoseBase(2, 3) - leftInitPos->z);
106 float rightDisplacement =
107 (rightTcpPoseBase(0, 3) - rightInitPos->x) * (rightTcpPoseBase(0, 3) - rightInitPos->x);
109 (rightTcpPoseBase(1, 3) - rightInitPos->y) * (rightTcpPoseBase(1, 3) - rightInitPos->y);
111 (rightTcpPoseBase(2, 3) - rightInitPos->z) * (rightTcpPoseBase(2, 3) - rightInitPos->z);
112 rightDisplacement = fabs(rightTcpPoseBase(2, 3) - rightInitPos->z);
114 if (leftDisplacement > maxDisplacement || rightDisplacement > maxDisplacement)
116 maxDisplacementReached =
true;
119 ARMARX_INFO <<
"Place Table displacements " << leftDisplacement <<
" " << maxDisplacement <<
" "
120 << rightDisplacement <<
" " << maxDisplacement;
121 float minForceThreshold = in.getMinForceThreshhold();
122 float velocityInmms = in.getVelocityInMillimetersSecond();
124 if (maxDisplacementReached)
126 out.setRightHandStopped(in.getRightHandStopped());
127 out.setLeftHandStopped(in.getLeftHandStopped());
128 out.setLeftHandChecked(
true);
129 out.setRightHandChecked(
true);
130 Eigen::Vector3f handPositionVelocity;
131 handPositionVelocity << 0, 0, 0;
132 Eigen::Vector3f handOrientationVelocity;
133 handOrientationVelocity << 0, 0, 0;
135 out.setNewHandPositionVelocity(
137 out.setNewHandOrientationVelocity(
144 if (in.getLeftHandChecked())
149 if (in.getRightHandChecked())
154 if (in.getLeftHandStopped())
159 if (in.getLeftHandStopped())
164 if (!in.getLeftHandStopped() && !in.getLeftHandChecked())
166 out.setRightHandStopped(in.getRightHandStopped());
168 if (in.getRightHandStopped())
170 out.setLeftHandChecked(
false);
174 out.setLeftHandChecked(
true);
177 out.setRightHandChecked(
false);
180 leftTcpName, leftRefForce, leftRefTorque, minForceThreshold, 0.0))
182 Eigen::Vector3f handPositionVelocity;
183 handPositionVelocity << 0, 0, 0;
184 Eigen::Vector3f handOrientationVelocity;
185 handOrientationVelocity << 0, 0, 0;
187 out.setNewHandPositionVelocity(
189 out.setNewHandOrientationVelocity(
191 out.setLeftHandStopped(
true);
193 emitEvForcesLeftHandChanged();
197 Eigen::Vector3f handPositionVelocity;
198 handPositionVelocity << 0, 0, -velocityInmms;
199 Eigen::Vector3f handOrientationVelocity;
200 handOrientationVelocity << 0, 0, 0;
201 out.setNewHandPositionVelocity(
203 out.setNewHandOrientationVelocity(
205 out.setLeftHandStopped(in.getLeftHandStopped());
206 emitEvForcesLeftHandNotChanged();
209 else if (!in.getRightHandStopped() && !in.getRightHandChecked())
211 out.setLeftHandStopped(in.getLeftHandStopped());
213 if (in.getLeftHandStopped())
215 out.setRightHandChecked(
false);
219 out.setRightHandChecked(
true);
222 out.setLeftHandChecked(
false);
225 rightTcpName, rightRefForce, rightRefTorque, minForceThreshold, 0.0))
227 Eigen::Vector3f handPositionVelocity;
228 handPositionVelocity << 0, 0, 0;
229 Eigen::Vector3f handOrientationVelocity;
230 handOrientationVelocity << 0, 0, 0;
232 out.setNewHandPositionVelocity(
234 out.setNewHandOrientationVelocity(
236 out.setRightHandStopped(
true);
237 emitEvForcesRightHandChanged();
241 Eigen::Vector3f handPositionVelocity;
242 handPositionVelocity << 0, 0, -velocityInmms;
243 Eigen::Vector3f handOrientationVelocity;
244 handOrientationVelocity << 0, 0, 0;
245 out.setNewHandPositionVelocity(
247 out.setNewHandOrientationVelocity(
249 out.setRightHandStopped(in.getRightHandStopped());
250 emitEvForcesRightHandNotChanged();
253 else if ((in.getRightHandStopped() && in.getLeftHandStopped()))
255 out.setRightHandStopped(in.getRightHandStopped());
256 out.setLeftHandStopped(in.getLeftHandStopped());
257 out.setLeftHandChecked(
true);
258 out.setRightHandChecked(
true);
259 Eigen::Vector3f handPositionVelocity;
260 handPositionVelocity << 0, 0, 0;
261 Eigen::Vector3f handOrientationVelocity;
262 handOrientationVelocity << 0, 0, 0;
264 out.setNewHandPositionVelocity(
266 out.setNewHandOrientationVelocity(
301 return "CheckForcesChanged";