UniversalRobots / Universal_Robots_ROS2_Driver

Universal Robots ROS2 driver supporting CB3 and e-Series
BSD 3-Clause "New" or "Revised" License
403 stars 210 forks source link

urscript_interface unexpected behaviour #786

Open Hytac opened 1 year ago

Hytac commented 1 year ago

Using the Humble branch in Ubuntu 22.04, I am connected to a real UR (5.11.11.1010533) and a URSim (5.13.1).

Executing the ur_robot_driver: ros2 launch ur_robot_driver ur10e.launch.py robot_ip:=xxxxx

After publishing the script to the topic, this is what the interface displays in the terminal:

[urscript_interface-4] [INFO 1693300316.661508772] [urscript_interface]: def root(): [urscript_interface-4] textmsg("Configure") [urscript_interface-4] write_output_boolean_register(80, False) [urscript_interface-4] write_output_boolean_register(70, False) [urscript_interface-4] write_output_boolean_register(71, True) [urscript_interface-4] write_output_boolean_register(72, False) [urscript_interface-4] write_output_boolean_register(73, False) [urscript_interface-4] write_output_boolean_register(74, True) [urscript_interface-4] sleep(1) [urscript_interface-4] textmsg("While") [urscript_interface-4] #while (read_input_boolean_register(70) == False): [urscript_interface-4] # sleep(0.01) [urscript_interface-4] #end [urscript_interface-4] [urscript_interface-4] textmsg("Run") [urscript_interface-4] write_output_boolean_register(70, True) [urscript_interface-4] sleep(1) [urscript_interface-4] [urscript_interface-4] textmsg("end") [urscript_interface-4] write_output_boolean_register(80, True) [urscript_interface-4] end [urscript_interface-4] root() [urscript_interface-4] [urscript_interface-4] [urscript_interface-4] (operator()() at /home/USER/ros/base/src/Universal_Robots_ROS2_Driver/ur_robot_driver/src/urscript_interface.cpp:55)

The URSim Log displays nothing, image

However, the real system displays everything as expected:

program root started
Configure
Run
end
Program root stopped

Also, the boolean registers are set properly.

Things change when I uncomment the while loop:

[urscript_interface-4] [INFO 1693300857.186712038] [urscript_interface]: def root(): [urscript_interface-4] textmsg("Configure") [urscript_interface-4] write_output_boolean_register(80, False) [urscript_interface-4] write_output_boolean_register(70, False) [urscript_interface-4] write_output_boolean_register(71, True) [urscript_interface-4] write_output_boolean_register(72, False) [urscript_interface-4] write_output_boolean_register(73, False) [urscript_interface-4] write_output_boolean_register(74, True) [urscript_interface-4] sleep(1) [urscript_interface-4] textmsg("While") [urscript_interface-4] while (read_input_boolean_register(70) == False): [urscript_interface-4] sleep(0.01) [urscript_interface-4] end [urscript_interface-4] [urscript_interface-4] textmsg("Run") [urscript_interface-4] write_output_boolean_register(70, True) [urscript_interface-4] sleep(1) [urscript_interface-4] [urscript_interface-4] textmsg("end") [urscript_interface-4] write_output_boolean_register(80, True) [urscript_interface-4] end [urscript_interface-4] root() [urscript_interface-4] [urscript_interface-4] [urscript_interface-4] (operator()() at /home/USER/ros/base/src/Universal_Robots_ROS2_Driver/ur_robot_driver/src/urscript_interface.cpp:55)

Executing this in URSim displays nothing—no errors, no log traces. Executing this in the real UR system displays:

program read_input_boolean_register started
Program read_input_boolean_register stopped

Also, the output boolean registers are not set.

This behavior doesn't make sense to me; similar behavior occurs when I define other functions.

This is what the script looks like, showing all the symbols image

Using Polyscope, I'm able to load and run this script and many others with no problem.

VinDp commented 4 months ago

Hey @Hytac, sorry for the long delay in answering. Regarding your issue: