ROS Driver - Sending script command with ROS still connected


I tried to send script and it worked - rostopic pub /ur_hardware_interface/script_command std_msgs/String “data: ‘set_digital_out(2,True)’”

Reference (ROS Driver - Dashboard/RawRequest)

But I found sending script made ROS disconnected.
Is there any way to send script command with ROS still connected?

Robot : UR10 CB3
URCaps : External Control for ROS

There can only be one primary program running on the controller. See URScript via topic cancels robot program on controller · Issue #33 · UniversalRobots/Universal_Robots_ROS_Driver · GitHub for details on how to circumvent this in certain situations.

1 Like

really thx, I added script secondary option “sec” and it worked without ros disconnected.

sec secondaryProgram():
  set_digital_out(1, True)

Actually, what I was trying to do is sending urscript for Onrobot VG10, not the UR10 robot. I extracted script code from .urp file from teach pendant and send it via python socket communication code $(robot_ip):30002. it worked without secondary option but it cause the ROS disconnection as said in the link you gave.

I tried it again with secondary option like below. However, the urscript for vg10 doesn’t seem to work with script secondary option.

sec secondaryProgram():
  ...(about 1422 lines for VG10 to grip)

I know, it’s kinda weird to ask here, this forum but Onrobot and Universal Robots are cooperative one another?
So, I’m posting here just in case…

Please see the documentation on secondary programs. Whether your script code will work as a secondary program is highly depending on the actual script code you’re trying to execute.

I imagine that a script of 1422 lines will consume controller time at some point…

Note, that you can also have a program flow on the TP contaiing the nodes for your gripper and then go into external control. Also, control from ROS side can be stopped by calling the hand_back_control service. This will end the external program node on the TP continuing with the next program node in your program tree. You can also have multiple instances of the external_control node inside your program tree.

Also, if you prefer a ROS-centric application flow, you can send a primary script to the robot for execution, which will stop your external_control program from running. You can rerun it by calling the dashboard server’s play service. Stopping the external_control node (e.g. by running another script code) will not terminate the ROS connection to your robot, it will only disable controlling the robot’s motions using ROS. Re-running the program containing the external_control node will bring the ROS driver to a full working state again.

1 Like

Thank you so much.

yeah… I agree with that point, I’m really afraid to analyze all the script code. it could be a waste of time for now.

I didn’t know about the hand_back_control service. is it same with the dashboard server stop service? I actually tested with the ‘play’ ‘stop’ service before. Thanks for mentioning that!

I really prefer a ROS-centric application flow, even it doesn’t terminate the ROS connection totally.
So I should try hand_back_control service and look for the other methods to operate the VG10.

Everything I was curious about was solved. Thank you again!

No, they are not the same. stop will terminate the program, while hand_back_control will only end executing the external_control node. If you have other nodes inside your program tree after the external_control node, they won’t get executed, when calling stop while being inside the external_control node. If hand_back_control is used, the program will continue with the nodes coming after the external_control node.

1 Like

Hey @along893 , I am also trying to control the VGC10 gripper.
I was wondering how did you solved the issue in the end.

Did you follow the approach of extracting the grip.urp and sending it to the UR via python socket?
Or did you send

set_digital_out(1, True)


What about the ROS termination?
I would be grateful if you could attach here the python file for gripping

@mauch I read carefully the suggestions in the forums for how controlling the UR via ROS.
I have a UR3e and I run the drivers on ROS2.
My task is to move the robot via ROS (so I have to run external control node) and also activate a vacuum gripper, which I managed by generating a .script and calling it from python (which needs remote control mode).
In ROS2 hand_back_control service seems to not be implemented yet.

How can I run seamlessly a program that needs either the external control node on (for controlling via ROS2) and either the remote control mode on (for sending .script)

(I tried also headless mode but didn’t work)

I’m afraid, this is not fully supported, yet. We have some things left for feature parity, please see ROS1 feature parity Milestone · GitHub.