@@ -214,3 +214,57 @@ are a couple of things to know:
214214 additional tool configured on the Teach pendant (TP), this should be equivalent to ``tool0 `` given that
215215 the URDF uses the specific robot's :ref: `calibration <calibration_extraction >`. If a tool is
216216 configured on the TP, then the additional transformation will show in ``base `` -> ``tool0 ``.
217+
218+ Custom URScript commands
219+ ------------------------
220+
221+ The driver's package contains a ``urscript_interface `` node that allows sending URScript snippets
222+ directly to the robot. It gets started in the driver's launchfiles by default. To use it, simply
223+ publish a message to its interface:
224+
225+ .. code-block :: bash
226+
227+ # simple popup
228+ ros2 topic pub /urscript_interface/script_command std_msgs/msg/String ' {data: popup("hello")}' --once
229+
230+ Be aware, that running a program on this interface (meaning publishing script code to that interface) stops any running program on the robot.
231+ Thus, the motion-interpreting program that is started by the driver gets stopped and has to be
232+ restarted again. Depending whether you use headless mode or not, you'll have to call the
233+ ``resend_program `` service or press the ``play `` button on the teach panel to start the
234+ external_control program again.
235+
236+ Multi-line programs
237+ ^^^^^^^^^^^^^^^^^^^
238+
239+ When you want to define multi-line programs, make sure to check that newlines are correctly
240+ interpreted from your message. For this purpose the driver prints the program as it is being sent to
241+ the robot. When sending a multi-line program from the command line, you can use an empty line
242+ between each statement:
243+
244+ .. code-block :: bash
245+
246+ ros2 topic pub --once /urscript_interface/script_command std_msgs/msg/String ' {data:
247+ "def my_prog():
248+
249+ set_digital_out(1, True)
250+
251+ movej(p[0.2, 0.3, 0.8, 0, 0, 3.14], a=1.2, v=0.25, r=0)
252+
253+ textmsg(\"motion finished\")
254+
255+ end"}'
256+
257+ Non-interrupting programs
258+ ^^^^^^^^^^^^^^^^^^^^^^^^^
259+
260+ To prevent interrupting the main program, you can send certain commands as `secondary programs
261+ <https://www.universal-robots.com/articles/ur/programming/secondary-program/> `_.
262+
263+ .. code-block :: bash
264+
265+ ros2 topic pub --once /urscript_interface/script_command std_msgs/msg/String ' {data:
266+ "sec my_prog():
267+
268+ textmsg(\"This is a log message\")
269+
270+ end"}'
0 commit comments