How do I capture the robot's current position

I am developing an application and I am having a problem where I can’t capture the robot’s current position when clicking a button on the screen. After that, I will assign this position to a subnode, Everything in a single click without extra confirmation screens.

setPositionButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(final MouseEvent e) {
				if (setPositionButton.isEnabled()) {
					apiProvider.getUserInterfaceAPI().getUserInteraction()
							.getUserDefinedRobotPosition(new RobotPositionCallback2() {

								@Override
								public void onOk(final PositionParameters parameters) {
									provider.get().onPositionSet(parameters.getPose(), parameters.getJointPositions());
								}
							});
				}
				super.mouseClicked(e);
			}
		});

I realize in your post you say “One click with no additional confirmations screens.” What I’ve shown you here is the method used to invoke the position capture that is the same as the Default Waypoint nodes. Consider that doing this will make your CAP look and feel the same to the end user as normal Polyscope. It’s also worth noting that you should save both the POSE variable and the JOINTPOSITIONS variable. There is NO WAY to recover one or the other after the fact if you decide you need them.

If you’re trying to, say, use a hardware button on the end of the flange to trigger a position capture, I would probably end up using socket communication to send and execute the URScript and return the result to Java. URCap Sample: URCap-ScriptCommunicator

See the link above for the classes and an explanation on how it works. Adding this to your toolbelt as a CAP developer will open quite a few doors.