How do I add custom modbus code to my URScript via Robots plugin?

This is a Robots plugin and URScript question

Using the Robots plugin for grasshopper we are able to generate movement commands easily. However, we have a custom extruder that uses Modbus register. First we need a code similar to this at the initialization.

modbus_add_signal("127.0.0.1", 255, 0, 16, "output2", False, 10)
list_var:=[10,9,8,7,6,5,4,3,2,1]

This part can be added easily using the Init commands input to the Create Program component.

Then at every movement we would need to set the extruder speed and orientation (our extruder orientation changes) using a custom code like this:

modbus_set_output_register("extruder_speed", 1500 , false)
modbus_set_output_register("extruder_orientation", 45 , false)

Is there a way from inside the robot plugin to add our custom extruder code to every line movement? This of course has to run in parallel to the movement and not cause interruptions in the movement of the robot.

Any help will be appreciated!

Note: the program below is incorrect because modbus_set_output_register only runs once during initialization

Right click on the “Create Target” Component.
There you can add an input for a command.

Note that the command is executed after the robot reached the target.

2 Likes

@robin_gdwl thank you so much for your quick reply and also for all the great tutorials you make!

I am wondering if I did not explain my question well, or maybe I do not understand the problem well enough.

Here is an example UR Script of what I think I need to be creating:

def Program():
    DefaultToolTcp = p[0, 0, 0, 0, 0, 1.5708]
    DefaultToolWeight = 0
    DefaultToolCog = [0, 0, 0]
    DefaultSpeed = 0.1
    DefaultZone = 0

    modbus_add_signal("127.0.0.1", 255, 0, 16, "auger", False, 10)

    set_tcp(DefaultToolTcp)
    set_payload(DefaultToolWeight, DefaultToolCog)

    modbus_set_output_register("auger", 523, false)  
    movej([0.8233, -0.3309, 1.3827, 0.519, -1.5708, 2.3183], a=3.1416, v=0.3142, r=DefaultZone)

    modbus_set_output_register("auger", 320, false)  
    movej(p[-0.34976, -0.62209, 0, 0, 0, 0], a=3.1416, v=0.2475, r=DefaultZone)

    modbus_set_output_register("auger", 101, false)  
    movej(p[-0.30511, -0.60227, 0, 0, 0, 0], a=3.1416, v=0.1844, r=DefaultZone)

end

I tried using the command input with the create target component as you suggested, but I am unable to even create a single line such as modbus_set_output_register("auger", 523, false) let alone how to integrate it with the movej commands.

I have not been able to find any good documentation on this topic. Any further help is much appreciated!

1 Like


Is this what you are trying to do?

2 Likes

@robin_gdwl thank you so much! This was VERY helpful. We should be able to test our custom end-effector clay extruder very soon.

2 Likes