3 import static com.kuka.roboticsAPI.motionModel.BasicMotions.positionHold;
4 import static com.kuka.roboticsAPI.motionModel.MMCMotions.handGuiding;
6 import java.util.concurrent.TimeUnit;
8 import com.kuka.roboticsAPI.deviceModel.LBR;
9 import com.kuka.roboticsAPI.executionModel.CommandInvalidException;
10 import com.kuka.roboticsAPI.geometricModel.Tool;
11 import com.kuka.roboticsAPI.motionModel.HandGuidingMotion;
12 import com.kuka.roboticsAPI.motionModel.IMotionContainer;
13 import com.kuka.roboticsAPI.motionModel.controlModeModel.JointImpedanceControlMode;
14 import com.kuka.task.ITaskLogger;
34 IMotionContainer _handGuidingMotionContainer = null;
35 HandGuidingMotion _handGuidingMotion;
36 private double[] _maxAllowedJointLimits;
37 private double[] _minAllowedJointLimits;
38 Tool _flangeAttachment;
39 JointImpedanceControlMode _teachControlMode;
40 private static volatile boolean useHandGuidingMotion;
42 private static volatile boolean stop =
false;
43 ITaskLogger _logger = null;
52 public TeachMode(Tool flangeAttachment,
double[] maxAllowedJoints,
double[] minAllowedJoints) {
53 _handGuidingMotion = handGuiding();
54 _maxAllowedJointLimits = maxAllowedJoints;
55 _minAllowedJointLimits = minAllowedJoints;
56 _flangeAttachment = flangeAttachment;
57 useHandGuidingMotion =
false;
69 _teachControlMode = teachModeControlMode;
75 useHandGuidingMotion =
true;
85 public synchronized boolean stop(){
86 if(!isEnableEnded)
return false;
100 useHandGuidingMotion =
false;
132 private void warn(String str) {
133 if (_logger != null) {
144 useHandGuidingMotion =
false;
146 _handGuidingMotionContainer = null;
156 if (!useHandGuidingMotion) {
159 if(!isEnableEnded && _logger!=null)
161 _logger.info(
"Teach Mode and HandGuidingMotion Complete!");
163 isEnableEnded =
true;
165 }
catch (InterruptedException e) {
166 warn(
"Interruption in TeachMode: " + e.toString());
171 warn(
"creating hand guiding motion " + useHandGuidingMotion);
172 isEnableEnded =
false;
173 _handGuidingMotion = handGuiding()
174 .setAxisLimitsMax(_maxAllowedJointLimits)
175 .setAxisLimitsMin(_minAllowedJointLimits)
176 .setAxisLimitsEnabled(
true,
true,
true,
true,
true,
true,
true)
177 .setAxisLimitViolationFreezesAll(
false).setPermanentPullOnViolationAtStart(
true);
178 isEnableEnded =
false;
182 _handGuidingMotionContainer = _flangeAttachment.move(_handGuidingMotion);
186 }
catch (CommandInvalidException e) {
187 _handGuidingMotionContainer = null;
189 }
catch (IllegalStateException e) {
190 _handGuidingMotionContainer = null;
195 warn(
"Teach Mode Thread Exiting");
void setLogger(ITaskLogger logger)
synchronized boolean isEnableEnded()
true there are no outstanding calls made to enable() and you can switch modes
TeachMode(Tool flangeAttachment, double[] maxAllowedJoints, double[] minAllowedJoints)
synchronized boolean stop()
void setTeachModeControlMode(JointImpedanceControlMode teachModeControlMode)