FRIHoldsPosition_Command.java
Go to the documentation of this file.
1 package grl.driver;
2 
3 import static com.kuka.roboticsAPI.motionModel.BasicMotions.positionHold;
4 import static com.kuka.roboticsAPI.motionModel.BasicMotions.ptp;
5 
6 import java.util.concurrent.TimeUnit;
7 import java.util.concurrent.TimeoutException;
8 
9 import com.kuka.connectivity.fastRobotInterface.FRIConfiguration;
10 import com.kuka.connectivity.fastRobotInterface.FRIJointOverlay;
11 import com.kuka.connectivity.fastRobotInterface.FRISession;
12 import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
13 import com.kuka.roboticsAPI.controllerModel.Controller;
14 import com.kuka.roboticsAPI.deviceModel.LBR;
15 import com.kuka.roboticsAPI.geometricModel.CartDOF;
16 import com.kuka.roboticsAPI.motionModel.controlModeModel.CartesianImpedanceControlMode;
17 import com.kuka.roboticsAPI.motionModel.controlModeModel.JointImpedanceControlMode;
18 import com.kuka.roboticsAPI.motionModel.controlModeModel.PositionControlMode;
19 
20 /**
21  * Creates a FRI Session.
22  */
23 public class FRIHoldsPosition_Command extends RoboticsAPIApplication
24 {
25  private Controller _lbrController;
26  private LBR _lbr;
27  private String _hostName;
28 
29  @Override
30  public void initialize()
31  {
32  _lbrController = (Controller) getContext().getControllers().toArray()[0];
33  _lbr = (LBR) _lbrController.getDevices().toArray()[0];
34  // **********************************************************************
35  // *** change next line to the FRIClient's IP address ***
36  // **********************************************************************
37  _hostName = "192.170.10.100";
38  }
39 
40  @Override
41  public void run()
42  {
43  // configure and start FRI session
44  FRIConfiguration friConfiguration = FRIConfiguration.createRemoteConfiguration(_lbr, _hostName);
45  friConfiguration.setSendPeriodMilliSec(4);
46  FRISession friSession = new FRISession(friConfiguration);
47  FRIJointOverlay motionOverlay = new FRIJointOverlay(friSession);
48 
49  try {
50  friSession.await(10, TimeUnit.SECONDS);
51  } catch (TimeoutException e) {
52  // TODO Automatisch generierter Erfassungsblock
53  e.printStackTrace();
54  friSession.close();
55  return;
56  }
57  //CartesianImpedanceControlMode controlMode = new CartesianImpedanceControlMode();
58  //controlMode.parametrize(CartDOF.X).setStiffness(500.0);
59  //controlMode.parametrize(CartDOF.ALL).setDamping(0.7);
60 // JointImpedanceControlMode controlMode = new JointImpedenceControlMode();
61 // controlMode.setDampingForAllJoints(0.7);
62 // controlMode.setStiffnessForAllJoints(500);
63  PositionControlMode controlMode = new PositionControlMode();
64  // TODO: remove default start pose
65  // move to default start pose
66  _lbr.move(ptp(Math.toRadians(10), Math.toRadians(10), Math.toRadians(10), Math.toRadians(-90), Math.toRadians(10), Math.toRadians(10),Math.toRadians(10)));
67 
68  // sync move for infinite time with overlay ...
69  _lbr.move(positionHold(controlMode, -1, TimeUnit.SECONDS).addMotionOverlay(motionOverlay));
70  //_lbr.moveAsync(ptp(Math.toRadians(-90), .0, .0, Math.toRadians(90), .0, Math.toRadians(-90), .0));
71 
72  // TODO: remove default start pose
73  // move to default start pose
74  _lbr.move(ptp(Math.toRadians(10), Math.toRadians(10), Math.toRadians(10), Math.toRadians(-90), Math.toRadians(10), Math.toRadians(10),Math.toRadians(10)));
75 
76  // done
77  friSession.close();
78  }
79 
80  /**
81  * main.
82  *
83  * @param args
84  * args
85  */
86  public static void main(final String[] args)
87  {
89  app.runApplication();
90  }
91 
92 }
static void main(final String[] args)