3 import static com.kuka.roboticsAPI.motionModel.BasicMotions.positionHold;
4 import static com.kuka.roboticsAPI.motionModel.BasicMotions.ptp;
5 import static com.kuka.roboticsAPI.motionModel.MMCMotions.handGuiding;
14 import java.nio.ByteBuffer;
15 import java.util.concurrent.TimeUnit;
16 import java.util.concurrent.TimeoutException;
18 import org.zeromq.ZMQ;
20 import com.google.flatbuffers.Table;
21 import com.kuka.connectivity.fastRobotInterface.FRIConfiguration;
22 import com.kuka.connectivity.fastRobotInterface.FRIJointOverlay;
23 import com.kuka.connectivity.fastRobotInterface.FRISession;
24 import com.kuka.connectivity.motionModel.smartServo.ISmartServoRuntime;
25 import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
26 import com.kuka.roboticsAPI.controllerModel.Controller;
27 import com.kuka.roboticsAPI.controllerModel.recovery.IRecovery;
28 import com.kuka.roboticsAPI.deviceModel.JointLimits;
29 import com.kuka.roboticsAPI.deviceModel.JointPosition;
30 import com.kuka.roboticsAPI.deviceModel.LBR;
31 import com.kuka.roboticsAPI.geometricModel.CartDOF;
32 import com.kuka.roboticsAPI.geometricModel.LoadData;
33 import com.kuka.roboticsAPI.geometricModel.PhysicalObject;
34 import com.kuka.roboticsAPI.geometricModel.Tool;
35 import com.kuka.roboticsAPI.motionModel.HandGuidingMotion;
36 import com.kuka.roboticsAPI.motionModel.IMotionContainer;
37 import com.kuka.roboticsAPI.motionModel.MotionBatch;
38 import com.kuka.roboticsAPI.motionModel.controlModeModel.AbstractMotionControlMode;
39 import com.kuka.roboticsAPI.motionModel.controlModeModel.CartesianImpedanceControlMode;
40 import com.kuka.roboticsAPI.motionModel.controlModeModel.JointImpedanceControlMode;
41 import com.kuka.roboticsAPI.motionModel.controlModeModel.PositionControlMode;
49 private Controller _lbrController;
52 private ISmartServoRuntime theSmartServoRuntime = null;
53 private AbstractMotionControlMode _activeMotionControlMode;
55 private IRecovery _pausedApplicationRecovery = null;
56 private PhysicalObject _toolAttachedToLBR;
57 private HandGuidingMotion _handGuidingMotion;
64 private Tool _flangeAttachment;
65 private JointLimits _jointLimits;
66 private double[] _maxAllowedJointLimits;
67 private double[] _minAllowedJointLimits;
74 _lbrController = (Controller) getContext().getControllers().toArray()[0];
75 _lbr = (LBR) _lbrController.getDevices().toArray()[0];
78 _flangeAttachment = getApplicationData().createFromTemplate(
"FlangeAttachment");
80 _pausedApplicationRecovery = getRecovery();
82 LoadData _loadData =
new LoadData();
87 _toolAttachedToLBR =
new Tool(
"Tool", _loadData);
88 _toolAttachedToLBR.attachTo(_lbr.getFlange());
92 _jointLimits = _lbr.getJointLimits();
96 _maxAllowedJointLimits = _jointLimits.getMaxJointPosition().get();
97 _minAllowedJointLimits = _jointLimits.getMinJointPosition().get();
98 for (
int i = 0; i < _lbr.getJointCount(); i++) {
99 _maxAllowedJointLimits[i] -= 0.1;
100 _minAllowedJointLimits[i] += 0.1;
110 int statesLength = 0;
112 ByteBuffer bb = null;
114 getLogger().info(
"States initialized...");
115 JointPosition destination =
new JointPosition(
116 _lbr.getJointCount());
119 IMotionContainer currentMotion = null;
121 boolean stop =
false;
122 boolean newConfig =
false;
128 getLogger().warn(
"Enabling Teach Mode (grav comp)");
130 JointImpedanceControlMode controlMode2 =
new JointImpedanceControlMode(7);
131 controlMode2.setStiffnessForAllJoints(0.1);
132 controlMode2.setDampingForAllJoints(0.7);
140 _handGuidingMotion = handGuiding()
141 .setAxisLimitsMax(_maxAllowedJointLimits)
142 .setAxisLimitsMin(_minAllowedJointLimits)
143 .setAxisLimitsEnabled(
true,
true,
true,
true,
true,
true,
true)
144 .setAxisLimitViolationFreezesAll(
false).setPermanentPullOnViolationAtStart(
true);
145 currentMotion = _toolAttachedToLBR.move(_handGuidingMotion);
146 getLogger().info(
"Done hand guiding");
160 public static void main(
final String[] args)
163 app.runApplication();
static void main(final String[] args)
double getEndEffectorWeight()