Toolbar hand - mode

No sure what you mean by “hand mode” exactly, but it sounds like you’d like to be able to Jog the external axis forward or backward via the toolbar? Or more generally, send script to the robot via the toolbar?

If this is the case, please see this post: URCap Sample: URCap-ScriptCommunicator

in which Ebbe has provided a class that allows you to send an execute script from Java.

Below is an example of some code I’ve written to do exactly this when pressing the “Forward” or “Reverse” buttons on my toolbar:

reverseButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				//create a new instance of the ScriptCommand class
				final ScriptCommand jogToSlidePosition = new ScriptCommand();
				//create a new String to hold the command
				String setPosition = "write_output_integer_register(11, 0)";
				String setSpeed = "write_output_integer_register(12, floor(170 * read_input_float_register(0)))";
				String setAcc = "write_output_integer_register(13, 100)";
				String unlockRunstate = "set_runstate_gp_boolean_output_to_value(16, 0)";
				String enableServo = "write_output_boolean_register(16, True)";
				//assign the newly created command as Primary. Secondary commands cannot consume robot time
				jogToSlidePosition.setAsPrimaryProgram();
				//add the created string to the command
				jogToSlidePosition.appendLine(setPosition);
				jogToSlidePosition.appendLine(setSpeed);
				jogToSlidePosition.appendLine(setAcc);
				jogToSlidePosition.appendLine(unlockRunstate);
				jogToSlidePosition.appendLine(enableServo);
				System.out.println(jogToSlidePosition);
				//create a new instance of a ScriptSender
				final ScriptSender sender = new ScriptSender();
				//send the created script using the newly created sender
				sender.sendScriptCommand(jogToSlidePosition);
			}

These classes are incredibly helpful. One thing to note is that it uses socket commands, which are really good at lagging the robot BADLY if you send several requests quickly. You’ll notice this when you use them. They are somewhat slow to respond.

1 Like