TeachModeTest.java
Go to the documentation of this file.
1 package grl.driver;
2 
3 
4 
5 import grl.TeachMode;
6 
7 import java.util.concurrent.TimeUnit;
8 
9 import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
10 import static com.kuka.roboticsAPI.motionModel.BasicMotions.*;
11 
12 import com.kuka.roboticsAPI.controllerModel.Controller;
13 import com.kuka.roboticsAPI.controllerModel.recovery.IRecovery;
14 import com.kuka.roboticsAPI.deviceModel.LBR;
15 import com.kuka.roboticsAPI.geometricModel.CartDOF;
16 import com.kuka.roboticsAPI.geometricModel.Tool;
17 import com.kuka.roboticsAPI.motionModel.controlModeModel.CartesianImpedanceControlMode;
18 import com.kuka.roboticsAPI.motionModel.controlModeModel.JointImpedanceControlMode;
19 
20 /**
21  * Implementation of a robot application.
22  * <p>
23  * The application provides a {@link RoboticsAPITask#initialize()} and a
24  * {@link RoboticsAPITask#run()} method, which will be called successively in
25  * the application lifecycle. The application will terminate automatically after
26  * the {@link RoboticsAPITask#run()} method has finished or after stopping the
27  * task. The {@link RoboticsAPITask#dispose()} method will be called, even if an
28  * exception is thrown during initialization or run.
29  * <p>
30  * <b>It is imperative to call <code>super.dispose()</code> when overriding the
31  * {@link RoboticsAPITask#dispose()} method.</b>
32  *
33  * @see #initialize()
34  * @see #run()
35  * @see #dispose()
36  */
37 public class TeachModeTest extends RoboticsAPIApplication {
38  private Controller _lbrController;
39  private LBR _lbr;
40  private Tool gripper;
41  //private IRecovery _pausedApplicationRecovery = null;
42 
43  public void initialize() {
44  _lbrController = (Controller) getContext().getControllers().toArray()[0];
45  _lbr = (LBR) _lbrController.getDevices().toArray()[0];
46  gripper = getApplicationData().createFromTemplate("FlangeAttachment");
47  //_pausedApplicationRecovery = getRecovery();
48  }
49 
50  public void run() {
51  boolean useTeachModeObject = false;
52 
53  //boolean isRecoveryRequired = _pausedApplicationRecovery.isRecoveryRequired();
54  if(useTeachModeObject){
55  /// @todo This section isn't working... debug it to fix the object
56 
57  TeachMode tm = new TeachMode(_lbr);
58  Thread tmThread = new Thread(tm);
59 
60  // Receive Flat Buffer and Move to Position
61  // TODO: add a message that we send to the driver with data log strings
62  tm.setActive(true);
63  tmThread.start();
64  boolean stop = false;
65  while (!stop) {
66  //isRecoveryRequired = _pausedApplicationRecovery.isRecoveryRequired();
67  // how do we check if the user wants to stop the app?
68  }
69 
70  tm.setActive(false);
71 
72  }
73  else
74  {
75  JointImpedanceControlMode mode = new JointImpedanceControlMode(100,100,100,100,100,100,100);
76  mode.setDampingForAllJoints(0.5);
77  mode.setStiffnessForAllJoints(100);
78 
79  while(!useTeachModeObject) {
80 
81  _lbr.move(positionHold(mode, 10, TimeUnit.MILLISECONDS));
82 
83  }
84  }
85  }
86 
87  /**
88  * Auto-generated method stub. Do not modify the contents of this method.
89  */
90  public static void main(String[] args) {
91  TeachModeTest app = new TeachModeTest();
92  app.runApplication();
93  }
94 }
static void main(String[] args)