Hi there,
As a newbie in the URCAP - I’ve got question that might be silly.
I would like to to import current robot pose into the array - I’ve tried two options:
1/
private Pose pose;
private PositionParameters positionparameters;
private Unit unit = Length.Unit.MM;
System.out.print(x1);
System.out.println(y)
double x1 = positionParameters.getPose().getPosition().getX(unit);
double y = pose.getPosition().getX(unit);
In each case I’ve return “:null” as an output. Could you gime me some hints?
I’ll be greatfull.
Hi @IMS.Control ,
Welcome to the UR community!
Your variable “positionparameters” seems to be unassigned. You can utilize the RobotPositionCallback2 Callback in the package “com.ur.urcap.api.domain.userinteraction” to initialize it.
Best regards
Ebbe
Hi Ebbe,
Thank you for your feedback - much appreciate it. I’ve tried as you mentioned however I still get NullPointer. Code is below - I will be greatful for any feedback.
public void executeChanges() {
//SetRecordingOn();
//Record(1);
UserInterfaceAPI uiapi = apiProvider.getUserInterfaceAPI();
uiapi.getUserInteraction().getUserDefinedRobotPosition(new RobotPositionCallback2() {
@Override
public void onOk(PositionParameters positionParameters) {
model.set(JP, positionParameters.getPose());
removeNodes();
//PrintPos(positionParameters);
}
});
Unit unit = Length.Unit.MM;
Pose centerPose = datamodel.get(JP, (Pose) null);
System.out.print(centerPose.getPosition().getX(unit));
}
});
Hi @IMS.Control,
Have the callback been executed? And was the pose also null during the execution?
Ebbe
Dear @Ebbe,
Thank you for your help - finally I get there
However with code below to get the position I need to confirm by clicking OK on the pendant - can I just print it without user interaction ?
UserInterfaceAPI uiapi = apiProvider.getUserInterfaceAPI();
uiapi.getUserInteraction().getUserDefinedRobotPosition(new RobotPositionCallback2() {
@Override
public void onOk(PositionParameters positionParameters) {
model.set(JP, positionParameters.getPose());
removeNodes();
PrintPos(positionParameters);
}
});
}
private void PrintPos(PositionParameters positionParameters) {
Unit unit = Length.Unit.MM;
model.set(JP, positionParameters.getPose());
System.out.println(positionParameters.getPose().getPosition().getX(unit));
}
HI @IMS.Control
In the project URCap Sample: URCap-ScriptCommunicator you can utialize the method get_actual_tcp_pose() that is member of the class ScriptProxy in the com.jbm.urcap.sample.scriptCommunicator.communicator package.
That should give you the current Pose of the robot including the TCP offset.
Ebbe