3 import static com.kuka.roboticsAPI.motionModel.BasicMotions.positionHold;
4 import static com.kuka.roboticsAPI.motionModel.MMCMotions.handGuiding;
6 import java.util.concurrent.TimeUnit;
7 import java.util.concurrent.TimeoutException;
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.connectivity.fastRobotInterface.FRIChannelInformation.FRISessionState;
13 import com.kuka.roboticsAPI.deviceModel.LBR;
14 import com.kuka.roboticsAPI.executionModel.CommandInvalidException;
15 import com.kuka.roboticsAPI.geometricModel.Tool;
16 import com.kuka.roboticsAPI.motionModel.HandGuidingMotion;
17 import com.kuka.roboticsAPI.motionModel.IMotionContainer;
18 import com.kuka.roboticsAPI.motionModel.controlModeModel.AbstractMotionControlMode;
19 import com.kuka.roboticsAPI.motionModel.controlModeModel.JointImpedanceControlMode;
20 import com.kuka.task.ITaskLogger;
27 public class FRIMode implements Runnable {
33 private AbstractMotionControlMode _activeMotionControlMode;
34 private FRISession _friSession = null;
35 private FRIJointOverlay _motionOverlay = null;
36 private static volatile boolean useHandGuidingMotion;
38 private static volatile boolean stop =
false;
40 IMotionContainer currentMotion = null;
41 ITaskLogger _logger = null;
50 public FRIMode(LBR lbr, FRISession friSession) {
52 _friSession = friSession;
53 useHandGuidingMotion =
false;
65 _activeMotionControlMode = teachModeControlMode;
71 useHandGuidingMotion =
true;
81 public synchronized boolean stop(){
82 if(!isEnableEnded)
return false;
85 if(currentMotion !=null) currentMotion.cancel();
100 useHandGuidingMotion =
false;
102 if(currentMotion !=null) currentMotion.cancel();
128 private void warn(String str) {
129 if (_logger != null) {
140 useHandGuidingMotion =
false;
142 _motionOverlay = null;
152 if (!useHandGuidingMotion) {
155 if(!isEnableEnded && _logger!=null)
157 _logger.info(
"FRI Joint Overlay Complete!");
159 isEnableEnded =
true;
161 }
catch (InterruptedException e) {
162 warn(
"Interruption in FRIMode: " + e.toString());
167 warn(
"creating FRI Joint Overlay " + useHandGuidingMotion);
168 isEnableEnded =
false;
169 _motionOverlay =
new FRIJointOverlay(_friSession);
175 isEnableEnded =
false;
179 if( _friSession.getFRIChannelInformation().getFRISessionState().compareTo(FRISessionState.COMMANDING_ACTIVE) != 0
180 && _friSession.getFRIChannelInformation().getFRISessionState().compareTo(FRISessionState.COMMANDING_WAIT) != 0)
182 _logger.info(
"FRI Joint Overlay starting...");
185 _friSession.await(10, TimeUnit.SECONDS);
187 currentMotion = _lbr.move(positionHold(_activeMotionControlMode, -1, TimeUnit.SECONDS).addMotionOverlay(_motionOverlay));
189 }
catch (TimeoutException e) {
190 _logger.error(
"FRISession timed out, closing...");
200 }
catch (CommandInvalidException e) {
201 currentMotion = null;
204 }
catch (IllegalStateException e) {
205 currentMotion = null;
211 warn(
"Teach Mode Thread Exiting");
void setLogger(ITaskLogger logger)
void setControlMode(AbstractMotionControlMode teachModeControlMode)
FRIMode(LBR lbr, FRISession friSession)
synchronized boolean isEnableEnded()
true there are no outstanding calls made to enable() and you can switch modes
synchronized boolean stop()