Thanks kiiwa for your approach!
I found my own way to implement it like shown in the following code snippet:
Code
getLogger().info("Setting ESM state to 2 and start handguiding motion asyncrounous");
lbr.setESMState("2");
IMotionContainer handGuideContainer = lbr.moveAsync(
handGuiding()
.setAxisLimitsMax(+1.407, +0.872, +0.87, -0.785, +0.87, +1.571, +0.87)
.setAxisLimitsMin(-1.407, +0.175, -0.87, -1.571, -0.87, -1.571, -0.87)
.setAxisLimitsEnabled(true, true, true, true, true, true, true)
.setAxisLimitViolationFreezesAll(true)
.setPermanentPullOnViolationAtStart(false)
.setAxisSpeedLimit(0.5)
);
ArrayList<com.kuka.roboticsAPI.geometricModel.Frame> frameRecording = new ArrayList<>();
getLogger().info("Waiting for the handguiding switch to be activated...");
while(lbr.getSafetyState().getEnablingDeviceState() != SunriseSafetyState.EnablingDeviceState.HANDGUIDING){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
do {
frameRecording.add(lbr.getCurrentCartesianPosition(gripper.getFrame("/Gripper_Tip")));
try {
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (lbr.getSafetyState().getEnablingDeviceState() == SunriseSafetyState.EnablingDeviceState.HANDGUIDING);
getLogger().info("Handguiding switch was activated and released. Motion has been recorded.");
handGuideContainer.cancel();
getLogger().info("Resetting ESM state to 1.");
lbr.setESMState("1");
getLogger().info("Frames recorded: " + frameRecording.size());
Display More