URScript: Dynamic Force Control - 20571

Example is valid for:                                              

CB2 Software version: 1.8.16941                          
CB3 Software version: 3.2.19293                         
Note that older or newer software versions may behave differently.

This example can be used for both CB2 and for CB3

All moves grouped under the FORCE wizard on the Polyscope, are bound by the force parameters specified in the force command. In order to control the force parameters dynamically at runtime you will have to get into UR scripting.

Scripting Syntax

The function to set the force is: 

force_mode(Feature, Compliance, Force, Type, Limits) 

Feature is the reference frame,

Compliance defines the compliant axes,

Force specifies the force along each axes of the Feature, and

Limits specifies the position deviation limits for compliance all specified as poses shown in the example below.


force_mode( tool_pose(), [0, 0, 1, 0, 0, 0], [0.0, 0.0, 10.0, 0.0, 0.0, 0.0], 2, [0.1, 0.1, 0.15, 0.17, 0.17, 0.17])

The Polyscope equivalent of the Force settings in the above example would look similar to the screen shot below.


In the above example,

Feature Frame is the Tool frame (tool_pose(): dropdown on top left in Polyscope) 

Compliant axis is Z-axis ([0, 0, 1, 0, 0, 0])   

Force is 10N along Z axis ([0, 0, 10.0, 0, 0, 0])

Type is 2 for Simple or Frame (1 for point, 3 for Motion) (dropdown on top right on Polyscope)

Limits is 100mm along x and y (because non-compliant) 150mm/s along z (because compliance added) and 10degrees about Rx, Ry and Rz (rotational twist)

In order to dynamically change the force you will need to change the Force variable. You would call this function as a thread when you want to get into Force mode and terminate it when you no longer want to run in force mode.


    thread Force_properties_calculation_thread_1():

      while (True):

        force_mode(tool_pose(), [0, 0, 1, 0, 0, 0], [0.0, 0.0, 10.0, 0.0, 0.0, 0.0], 2, [0.1, 0.1, 0.15, 0.17, 0.17, 0.17])




    global thread_handler_1 = run Force_properties_calculation_thread_1()

    $ "Waypoint_1"

    movej([-1.6007, -1.7271, -2.203, -0.808, 1.5951, -0.031], a=1.39, v=1.04)

    $ "Waypoint_2"

    movej([-1.6, -1.45, -1.69, -1.58, 1.59, -0.031], a=1.39, v=1.04)


    movej([-1.6, -1.52, -2.01, -1.20, 1.59, -0.031], a=1.39, v=1.04)

    kill thread_handler_1



Force Control settings on POLYSCOPE



  • Specify force control relative to coordinate system
  • Specify force control relative to motion
  • Define force in single axis or multiple axes
  • Limit tool velocity in compliant axes
  • Easy testing using the freedrive button (Teach Test + Freedrive)



  • Force precision            ± 10 N
  • Torque precision          ± 5 Nm
  • Position precision        ± 5 mm
  • Orientation precision   ± 0.5 °

Want to get notified about updates?

You are welcome to sign up for notifications about new relevant information and articles that could be interesting for you.

Universal Robots A/S needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at anytime. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, check out our Privacy Policy.

Need help?

Did you find what you needed on this site? For additional information please contact one of our distributors.