Freemode with urscript

hello dear community, I am trying to implement by software the free movement with axis restriction, as you are implementing in polyscope and the free mode button of the programming tablet (attached image).

You can help me to find the right way to do it. I have tried the following options:
force_mode() command, restricting axes where force is applied.


def FreeDrive_force(register_flag):
  
	global for_thrd = run force_thread(register_flag)
	global for_thrd = run getForces()
end

##############################################

def end_FreeDrive_force():
	kill for_thrd
	kill for_thrd
end

##############################################

thread force_thread(register_flag):
	limits = [0.1, 0.1, 0.1, 10, 10, 10]
	frame = p[0.0,0.0,0.0,0.0,0.0,0.0]
      #list to select axis move
	selection = [0, 0, 0, 1, 1, 1]
	type=2
	wrench = [0, 0, 0, 0.1, 0.1, 0.1]

	while (not(read_input_boolean_register(register_flag) ==   True  )):	  
	  force_mode(frame,selection , wrench, type, limits)
	  sync()
	end #while
	
	end_FreeDrive_force()
end   #thread define
###############################################

thread getForces():
  zero_ftsensor()
  while True:
    global forces = get_tcp_force()
    sync()
  end  
end  

Force sensing with get_tcp_force() and get a proportional value of force to convert it into speed for speedl()



def admitance_mode(register_flag):
 #list to select axis move
  global speed_limits = [0, 0, 0, 0.5, 0.5, 0.5]
  
  global pose_thrd = run getForce()
  global ad_thrd = run admitance_thread(register_flag)
  
end

###############################################################################

def end_admitance_mode():
	kill ad_thrd
	kill pose_thrd
end
###############################################################################

thread admitance_thread(register_flag):




	while (not(read_input_boolean_register(register_flag) ==   True  )):
	
		l = speed_limits
		f =  force
		fn = force_nom
		acc = 0.25
		result = [l[0]*(f[0]/fn), l[1]*(f[1]/fn), l[2]*(f[2]/fn), l[3]*f[3], l[4]*f[4], l[5]*f[5]]
		speedl(result, acc)
		sync()
	end #while
	
	end_admitance_mode()
end   #thread define

thread getForce():
  zero_ftsensor()
  while True:
    global force = get_tcp_force()
	global force_nom = force()
    sync()
  end  
end  

thanks for your help

Congrats on the first post.

I’ve played with it doing it both ways. I think the best result I had was using force_mode(). Using speedl and a timer was too jerky.

To make it move by hand in the x,y,z my selection was:
[1, 1, 1, 0, 0, 0]

and my limit was:
[0, 0, 0, 0, 0, 0]

If I remember right, it tries to exert 0 force in those vectors and so if you push it, it goes where you want.

I think a better structure would be to go into force mode, and then use your Bool test to decide when to run the end_force_mode() command rather than calling force mode repeatedly.

1 Like

Thank you very much, I will try it out and share the code.