Hello,
I am using the UR10e and have installed the RTDE and am able to run the control_loop_example.py provided in the RTDE_Python_Client_Library. I am now trying to write my own program and want to use the “servoj” function to move the arm but am not sure how to configure the .urp file such that the registers for it listen to such a command. I am not sure how to structure the file in the teaching pendant and whether a thread needs to be running simultaneously. I have also been reading the UR Script Manual but haven’t figured out how to write the .urp file. Perhaps I could see a sample .urp line that enables me to send servoj commands and the corresponding python code? Using example code has not worked since I need the .urp code as well. Thank you very much, any help is appreciated.
Here is an example URscript that uses servoJ with RTDE values:
You do not need a thread, if you do not want to do other tasks while the control loop is running.
def realtime_control():
while (True):
new_pose = p[read_input_float_register(0),
read_input_float_register(1),
read_input_float_register(2),
read_input_float_register(3),
read_input_float_register(4),
read_input_float_register(5)]
servoj(get_inverse_kin(new_pose), t=0.2, lookahead_time= 0.1, gain=350)
sync()
end
end
The while(True)
can be exchanged for any other condition with which you want to start or stop the control loop.
In your program on the pendant you add this as a script component. Then just add another script component that simply calls the realtime_control() function.
It reads the joint values from the float registers and moves there according to the servoJ parameters.
On the python side you need to adjust the control loop example
This really depends on how you want to control the robot positions and how the joint values are created.
Be careful with servorJ, it can cause quite sudden robot motions.
Thank you very much for your response, I have tried implementing this however I have not been able to send commands from my python script. Perhaps the register is not aware of the command I am sending? Do I have to make changes to the recipes in the xml file? I have kept the defaults used in the control_loop_configuration.xml
I am using the sample code provided by this servoj python file.
I have not been able to send commands from my python script
what do you mean by this? What error do you get or what is the result?
Thank you for the question @robin_gdwl, sorry for the late response, I have tried multiple things now including moving the robot to multiple locations by just adding setpoints in the example_control_loop.py from the previously cited RTDE_Python_Client_Library. This works fine but if I want to conditionally move to a setpoint based on user input like so:
final_setpoint = [0.30, -0.25, 0.18, 0, 3.10, 0.05]
def move_robot(setp_values):
global setp, watchdog, con
for i in range(6):
setp.__dict__[f"input_double_register_{i}"] = setp_values[i]
con.send(setp)
watchdog.input_int_register_0 = 1
con.send(watchdog)
def on_enter_press():
print("Moving to final setpoint")
move_robot(final_setpoint)
This does not work and I do not even get an error message.
When I use the script that you provided in the script format in the main porgram section of the polyscope program:
I also disconnect from the fieldbus and the script does not seem to be running. I get an error when I implement sample code such as posted in this servoj example. I have also tried using the text file as script input from the respective polyscope script text . I would really appreciate all the help I can get on this. Thanks again!